/** * The index the search failed on. */ @Override public String index() { if (shardTarget != null) { return shardTarget.index(); } return null; }
@Override public String index() { return shard.index(); }
public String getIndex() { return index(); }
@Override public int compareTo(SearchShardTarget o) { int i = index.string().compareTo(o.index()); if (i == 0) { i = shardId - o.shardId; } return i; }
@Override public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { String indexName = parser.currentName(); if (indexName.equals(context.shardTarget().index())) { parser.nextToken(); // move to the value // we found our query boost context.queryBoost(parser.floatValue()); } } } } }
.filterRoutingTable(true) .filterNodes(true) .filteredIndices(context.shardTarget().index());
@Override public void parse(XContentParser parser, SearchContext context) throws Exception { SuggestionSearchContext suggestionSearchContext = parseInternal(parser, context.mapperService(), context.queryParserService(), context.shardTarget().index(), context.shardTarget().shardId(), context); context.suggest(suggestionSearchContext); }
public WriterResult execute(SearchIntoContext context) throws WriterException { logger.info("writing {}/{}", context.shardTarget().index(), context.shardTarget().getShardId()); Query query = context.query(); context.version(true); WriterCollector wc = collectors.get(context.targetType()).create( context); wc.open(); try { context.searcher().search(query, wc); } catch (IOException e) { throw new WriterException(context, "Failed to write docs", e); } wc.close(); WriterResult res = wc.getResult(); logger.info("exported {} docs from {}/{}", res.getTotalWrites(), context.shardTarget().index(), context.shardTarget().getShardId()); return res; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (scrollId != null) { builder.field(Fields._SCROLL_ID, scrollId); } builder.field(Fields.TOOK, tookInMillis); builder.field(Fields.TIMED_OUT, timedOut()); builder.startObject(Fields._SHARDS); builder.field(Fields.TOTAL, totalShards()); builder.field(Fields.SUCCESSFUL, successfulShards()); builder.field(Fields.FAILED, failedShards()); if (shardFailures.length > 0) { builder.startArray(Fields.FAILURES); for (ShardSearchFailure shardFailure : shardFailures) { builder.startObject(); if (shardFailure.shard() != null) { builder.field(Fields.INDEX, shardFailure.shard().index()); builder.field(Fields.SHARD, shardFailure.shard().shardId()); } builder.field(Fields.STATUS, shardFailure.status().getStatus()); builder.field(Fields.REASON, shardFailure.reason()); builder.endObject(); } builder.endArray(); } builder.endObject(); internalResponse.toXContent(builder, params); return builder; }