/** * Ensure that the {@link IndexRequest}'s content type is supported by the Bulk API and that it conforms to the * current {@link BulkRequest}'s content type (if it's known at the time of this method get called). * * @return the {@link IndexRequest}'s content type */ static XContentType enforceSameContentType(IndexRequest indexRequest, @Nullable XContentType xContentType) { XContentType requestContentType = indexRequest.getContentType(); if (requestContentType != XContentType.JSON && requestContentType != XContentType.SMILE) { throw new IllegalArgumentException("Unsupported content-type found for request with content-type [" + requestContentType + "], only JSON and SMILE are supported"); } if (xContentType == null) { return requestContentType; } if (requestContentType != xContentType) { throw new IllegalArgumentException("Mismatching content-type found for request with content-type [" + requestContentType + "], previous requests have content-type [" + xContentType + "]"); } return xContentType; }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return resultsMapper.mapResults(response, clazz, Pageable.unpaged()); }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, SearchResultMapper mapper) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return mapper.mapResults(response, clazz, Pageable.unpaged()); }
/** * Operating System level information. */ @Nullable public OsInfo getOs() { return this.os; }
/** * Process level statistics. */ @Nullable public ProcessStats getProcess() { return process; }
/** * An optional version stored with the pipeline so that it can be used to determine if the pipeline should be updated / replaced. * * @return {@code null} if not supplied. */ @Nullable public Integer getVersion() { return version; }
/** * Returns snapshot state; {@code null} if the state is unknown. * * @return snapshot state */ @Nullable public SnapshotState state() { return state; }
/** * Returns the index name of the shard to explain, or {@code null} to use any unassigned shard (see {@link #useAnyUnassignedShard()}). */ @Nullable public String getIndex() { return this.index; }
/** * Sets the text to provide suggestions for. The suggest text is a required option that needs * to be set either via this setter or via the {@link org.elasticsearch.search.suggest.SuggestionBuilder#text(String)} method. * <p> * The suggest text gets analyzed by the suggest analyzer or the suggest field search analyzer. * For each analyzed token, suggested terms are suggested if possible. */ public SuggestBuilder setGlobalText(@Nullable String globalText) { this.globalText = globalText; return this; }
/** * Returns the relocating target node, or {@code null} if the shard is not in the {@link ShardRoutingState#RELOCATING} state. */ @Nullable public DiscoveryNode getRelocationTargetNode() { return relocationTargetNode; }
/** * Returns custom headers that have been added, or null if none have been set. */ @Nullable public Map<String, List<String>> getHeaders() { return customHeaders; } }
/** * If set, a string representing that the segment is part of a merge, with the value representing the * group of segments that represent this merge. */ @Nullable public String getMergeId() { return this.mergeId; }
/** * Return the shard with the provided id, or null if there is no such shard. */ @Override @Nullable public IndexShard getShardOrNull(int shardId) { return shards.get(shardId); }
public static XContentBuilder restContentBuilder(RestRequest request, @Nullable BytesReference autoDetectSource) throws IOException { XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type"))); if (contentType == null) { // try and guess it from the auto detect source if (autoDetectSource != null) { contentType = XContentFactory.xContentType(autoDetectSource); } } if (contentType == null) { // default to JSON contentType = XContentType.JSON; } XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput()); if (request.paramAsBoolean("pretty", false)) { builder.prettyPrint().lfAtEnd(); } builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable())); String casing = request.param("case"); if (casing != null && "camelCase".equals(casing)) { builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE); } else { // we expect all REST interfaces to write results in underscore casing, so // no need for double casing builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE); } return builder; }
/** * Returns a NO decision for a delayed shard allocation on a replica shard, with the individual node-level * decisions that comprised the final NO decision, if in explain mode. Instances created with this * method will return {@link AllocationStatus#DELAYED_ALLOCATION} for {@link #getAllocationStatus()}. */ public static AllocateUnassignedDecision delayed(long remainingDelay, long totalDelay, @Nullable List<NodeAllocationResult> decisions) { return no(AllocationStatus.DELAYED_ALLOCATION, decisions, false, remainingDelay, totalDelay); }
public MultiGetRequestBuilder add(String index, @Nullable String type, Iterable<String> ids) { for (String id : ids) { request.add(index, type, id); } return this; }
public TermVectorsFilter(Fields termVectorsByField, Fields topLevelFields, Set<String> selectedFields, @Nullable AggregatedDfs dfs) { this.fields = termVectorsByField; this.topLevelFields = topLevelFields; this.selectedFields = selectedFields; this.dfs = dfs; this.scoreTerms = new HashMap<>(); this.similarity = new ClassicSimilarity(); }
protected BigArrays(PageCacheRecycler recycler, @Nullable final CircuitBreakerService breakerService, String breakerName, boolean checkBreaker) { this.checkBreaker = checkBreaker; this.recycler = recycler; this.breakerService = breakerService; this.breakerName = breakerName; if (checkBreaker) { this.circuitBreakingInstance = this; } else { this.circuitBreakingInstance = new BigArrays(recycler, breakerService, breakerName, true); } }
/** * Initializes the current unassigned shard and moves it from the unassigned list. * * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated. */ public ShardRouting initialize(String nodeId, @Nullable String existingAllocationId, long expectedShardSize, RoutingChangesObserver routingChangesObserver) { nodes.ensureMutable(); innerRemove(); return nodes.initializeShard(current, nodeId, existingAllocationId, expectedShardSize, routingChangesObserver); }
@Override public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize) throws ParseException { double alpha = parseDoubleParam(settings, "alpha", DEFAULT_ALPHA); double beta = parseDoubleParam(settings, "beta", DEFAULT_BETA); checkUnrecognizedParams(settings); return new HoltLinearModel(alpha, beta); } };