MLT Query: don't fetch unnecessary stats
This commit is contained in:
parent
3d3c2cd760
commit
4ee91cb331
|
@ -159,16 +159,14 @@ public class MoreLikeThisQueryParser implements QueryParser {
|
||||||
if (!token.isValue()) {
|
if (!token.isValue()) {
|
||||||
throw new ElasticsearchIllegalArgumentException("ids array element should only contain ids");
|
throw new ElasticsearchIllegalArgumentException("ids array element should only contain ids");
|
||||||
}
|
}
|
||||||
items.add(new TermVectorRequest().id(parser.text()));
|
items.add(newTermVectorRequest().id(parser.text()));
|
||||||
}
|
}
|
||||||
} else if (Fields.DOCUMENTS.match(currentFieldName, parseContext.parseFlags())) {
|
} else if (Fields.DOCUMENTS.match(currentFieldName, parseContext.parseFlags())) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
if (token != XContentParser.Token.START_OBJECT) {
|
if (token != XContentParser.Token.START_OBJECT) {
|
||||||
throw new ElasticsearchIllegalArgumentException("docs array element should include an object");
|
throw new ElasticsearchIllegalArgumentException("docs array element should include an object");
|
||||||
}
|
}
|
||||||
TermVectorRequest termVectorRequest = new TermVectorRequest();
|
items.add(parseDocuments(parser));
|
||||||
TermVectorRequest.parseRequest(termVectorRequest, parser);
|
|
||||||
items.add(termVectorRequest);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new QueryParsingException(parseContext.index(), "[mlt] query does not support [" + currentFieldName + "]");
|
throw new QueryParsingException(parseContext.index(), "[mlt] query does not support [" + currentFieldName + "]");
|
||||||
|
@ -247,6 +245,21 @@ public class MoreLikeThisQueryParser implements QueryParser {
|
||||||
return mltQuery;
|
return mltQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TermVectorRequest newTermVectorRequest() {
|
||||||
|
return new TermVectorRequest()
|
||||||
|
.positions(false)
|
||||||
|
.offsets(false)
|
||||||
|
.payloads(false)
|
||||||
|
.fieldStatistics(false)
|
||||||
|
.termStatistics(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TermVectorRequest parseDocuments(XContentParser parser) throws IOException {
|
||||||
|
TermVectorRequest termVectorRequest = newTermVectorRequest();
|
||||||
|
TermVectorRequest.parseRequest(termVectorRequest, parser);
|
||||||
|
return termVectorRequest;
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> removeUnsupportedFields(List<String> moreLikeFields, Analyzer analyzer, boolean failOnUnsupportedField) throws IOException {
|
private List<String> removeUnsupportedFields(List<String> moreLikeFields, Analyzer analyzer, boolean failOnUnsupportedField) throws IOException {
|
||||||
for (Iterator<String> it = moreLikeFields.iterator(); it.hasNext(); ) {
|
for (Iterator<String> it = moreLikeFields.iterator(); it.hasNext(); ) {
|
||||||
final String fieldName = it.next();
|
final String fieldName = it.next();
|
||||||
|
|
Loading…
Reference in New Issue