Remove ParseFieldMatcher usages from MoreLikeThisQueryBuilder & MultiMatchQueryBuilder
This commit is contained in:
parent
c06d00dce1
commit
648ed46f01
|
@ -36,7 +36,6 @@ import org.elasticsearch.action.termvectors.TermVectorsResponse;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.ParsingException;
|
import org.elasticsearch.common.ParsingException;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -352,7 +351,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
|
||||||
/**
|
/**
|
||||||
* Parses and returns the given item.
|
* Parses and returns the given item.
|
||||||
*/
|
*/
|
||||||
public static Item parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, Item item) throws IOException {
|
public static Item parse(XContentParser parser, Item item) throws IOException {
|
||||||
XContentParser.Token token;
|
XContentParser.Token token;
|
||||||
String currentFieldName = null;
|
String currentFieldName = null;
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
|
@ -895,7 +894,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
|
||||||
if (token != XContentParser.Token.START_OBJECT) {
|
if (token != XContentParser.Token.START_OBJECT) {
|
||||||
throw new IllegalArgumentException("docs array element should include an object");
|
throw new IllegalArgumentException("docs array element should include an object");
|
||||||
}
|
}
|
||||||
likeItems.add(Item.parse(parser, parseContext.getParseFieldMatcher(), new Item()));
|
likeItems.add(Item.parse(parser, new Item()));
|
||||||
}
|
}
|
||||||
} else if (Field.STOP_WORDS.match(currentFieldName)) {
|
} else if (Field.STOP_WORDS.match(currentFieldName)) {
|
||||||
stopWords = new ArrayList<>();
|
stopWords = new ArrayList<>();
|
||||||
|
@ -956,7 +955,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
|
||||||
if (parser.currentToken().isValue()) {
|
if (parser.currentToken().isValue()) {
|
||||||
texts.add(parser.text());
|
texts.add(parser.text());
|
||||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||||
items.add(Item.parse(parser, parseContext.getParseFieldMatcher(), new Item()));
|
items.add(Item.parse(parser, new Item()));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Content of 'like' parameter should either be a string or an object");
|
throw new IllegalArgumentException("Content of 'like' parameter should either be a string or an object");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.lucene.search.FuzzyQuery;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.ParsingException;
|
import org.elasticsearch.common.ParsingException;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
@ -147,7 +146,7 @@ public class MultiMatchQueryBuilder extends AbstractQueryBuilder<MultiMatchQuery
|
||||||
return parseField;
|
return parseField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type parse(String value, ParseFieldMatcher parseFieldMatcher) {
|
public static Type parse(String value) {
|
||||||
MultiMatchQueryBuilder.Type[] values = MultiMatchQueryBuilder.Type.values();
|
MultiMatchQueryBuilder.Type[] values = MultiMatchQueryBuilder.Type.values();
|
||||||
Type type = null;
|
Type type = null;
|
||||||
for (MultiMatchQueryBuilder.Type t : values) {
|
for (MultiMatchQueryBuilder.Type t : values) {
|
||||||
|
@ -303,7 +302,7 @@ public class MultiMatchQueryBuilder extends AbstractQueryBuilder<MultiMatchQuery
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
throw new IllegalArgumentException("[" + NAME + "] requires type to be non-null");
|
throw new IllegalArgumentException("[" + NAME + "] requires type to be non-null");
|
||||||
}
|
}
|
||||||
this.type = Type.parse(type.toString().toLowerCase(Locale.ROOT), ParseFieldMatcher.EMPTY);
|
this.type = Type.parse(type.toString().toLowerCase(Locale.ROOT));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +597,7 @@ public class MultiMatchQueryBuilder extends AbstractQueryBuilder<MultiMatchQuery
|
||||||
if (QUERY_FIELD.match(currentFieldName)) {
|
if (QUERY_FIELD.match(currentFieldName)) {
|
||||||
value = parser.objectText();
|
value = parser.objectText();
|
||||||
} else if (TYPE_FIELD.match(currentFieldName)) {
|
} else if (TYPE_FIELD.match(currentFieldName)) {
|
||||||
type = MultiMatchQueryBuilder.Type.parse(parser.text(), parseContext.getParseFieldMatcher());
|
type = MultiMatchQueryBuilder.Type.parse(parser.text());
|
||||||
} else if (ANALYZER_FIELD.match(currentFieldName)) {
|
} else if (ANALYZER_FIELD.match(currentFieldName)) {
|
||||||
analyzer = parser.text();
|
analyzer = parser.text();
|
||||||
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
|
} else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.action.termvectors.MultiTermVectorsRequest;
|
||||||
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
|
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
|
||||||
import org.elasticsearch.action.termvectors.TermVectorsRequest;
|
import org.elasticsearch.action.termvectors.TermVectorsRequest;
|
||||||
import org.elasticsearch.action.termvectors.TermVectorsResponse;
|
import org.elasticsearch.action.termvectors.TermVectorsResponse;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||||
import org.elasticsearch.common.lucene.search.MoreLikeThisQuery;
|
import org.elasticsearch.common.lucene.search.MoreLikeThisQuery;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
@ -298,7 +297,7 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
|
||||||
Item expectedItem = generateRandomItem();
|
Item expectedItem = generateRandomItem();
|
||||||
String json = expectedItem.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).string();
|
String json = expectedItem.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).string();
|
||||||
XContentParser parser = createParser(JsonXContent.jsonXContent, json);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, json);
|
||||||
Item newItem = Item.parse(parser, ParseFieldMatcher.STRICT, new Item());
|
Item newItem = Item.parse(parser, new Item());
|
||||||
assertEquals(expectedItem, newItem);
|
assertEquals(expectedItem, newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue