small renames here and there
This commit is contained in:
parent
8365e7ba0b
commit
b5d9d3dbee
|
@ -19,25 +19,17 @@
|
|||
|
||||
package org.elasticsearch.action.explain;
|
||||
|
||||
import org.elasticsearch.ElasticSearchGenerationException;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.ValidateActions;
|
||||
import org.elasticsearch.action.support.single.shard.SingleShardOperationRequest;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Explain request encapsulating the explain query and document identifier to get an explanation for.
|
||||
|
@ -55,7 +47,7 @@ public class ExplainRequest extends SingleShardOperationRequest {
|
|||
|
||||
private String[] filteringAlias = Strings.EMPTY_ARRAY;
|
||||
|
||||
ExplainRequest(){
|
||||
ExplainRequest() {
|
||||
}
|
||||
|
||||
public ExplainRequest(String index, String type, String id) {
|
||||
|
@ -127,8 +119,8 @@ public class ExplainRequest extends SingleShardOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ExplainRequest source(BytesReference querySource, boolean unsafe) {
|
||||
this.source = querySource;
|
||||
public ExplainRequest source(BytesReference source, boolean unsafe) {
|
||||
this.source = source;
|
||||
this.sourceUnsafe = unsafe;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,8 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A builder for {@link ExplainRequest}.
|
||||
*/
|
||||
|
@ -97,13 +94,24 @@ public class ExplainRequestBuilder extends BaseRequestBuilder<ExplainRequest, Ex
|
|||
/**
|
||||
* Sets the query to get a score explanation for.
|
||||
*/
|
||||
public ExplainRequestBuilder setQuery(QueryBuilder queryBuilder) {
|
||||
sourceBuilder().query(queryBuilder);
|
||||
public ExplainRequestBuilder setQuery(QueryBuilder query) {
|
||||
sourceBuilder().query(query);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExplainRequestBuilder setSource(BytesReference querySource, boolean unsafe) {
|
||||
request().source(querySource, unsafe);
|
||||
/**
|
||||
* Sets the query to get a score explanation for.
|
||||
*/
|
||||
public ExplainRequestBuilder setQuery(BytesReference query) {
|
||||
sourceBuilder().query(query);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the full source of the explain request (for example, wrapping an actual query).
|
||||
*/
|
||||
public ExplainRequestBuilder setSource(BytesReference source, boolean unsafe) {
|
||||
request().source(source, unsafe);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
package org.elasticsearch.action.explain;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.Explanation;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.action.support.single.shard.TransportShardSingleOperationAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
|
@ -29,14 +28,12 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
|
||||
import org.elasticsearch.index.query.ParsedQuery;
|
||||
|
@ -44,15 +41,12 @@ import org.elasticsearch.index.service.IndexService;
|
|||
import org.elasticsearch.index.shard.service.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchParseElement;
|
||||
import org.elasticsearch.search.internal.InternalSearchRequest;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.search.query.QueryParseElement;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Explain transport action. Computes the explain on the targeted shard.
|
||||
|
@ -105,11 +99,12 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
|
|||
scriptService
|
||||
);
|
||||
SearchContext.setCurrent(context);
|
||||
context.parsedQuery(retrieveParsedQuery(request, indexService));
|
||||
context.preProcess();
|
||||
int topLevelDocId = result.docIdAndVersion().docId + result.docIdAndVersion().docStart;
|
||||
|
||||
try {
|
||||
context.parsedQuery(parseQuery(request, indexService));
|
||||
context.preProcess();
|
||||
int topLevelDocId = result.docIdAndVersion().docId + result.docIdAndVersion().docStart;
|
||||
|
||||
Explanation explanation = context.searcher().explain(context.query(), topLevelDocId);
|
||||
return new ExplainResponse(true, explanation);
|
||||
} catch (IOException e) {
|
||||
|
@ -120,7 +115,7 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
|
|||
}
|
||||
}
|
||||
|
||||
private ParsedQuery retrieveParsedQuery(ExplainRequest request, IndexService indexService) {
|
||||
private ParsedQuery parseQuery(ExplainRequest request, IndexService indexService) {
|
||||
try {
|
||||
XContentParser parser = XContentHelper.createParser(request.source());
|
||||
for (XContentParser.Token token = parser.nextToken(); token != XContentParser.Token.END_OBJECT; token = parser.nextToken()) {
|
||||
|
|
Loading…
Reference in New Issue