Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Term Query: Be more strict during parsing #12195

Merged

Conversation

spinscale
Copy link
Contributor

The term query parser was too lenient during parsing and allowed to specify
more than one field, even though this expected to filter only for a single field.

This commit returns an exception if a query has been specified more than once.

Closes #12184

@spinscale spinscale added review :Search/Search Search-related issues that do not fall into other categories labels Jul 12, 2015
@colings86
Copy link
Contributor

LGTM

@@ -63,6 +63,9 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
// skip
} else if (token == XContentParser.Token.START_OBJECT) {
// also support a format of "term" : {"field_name" : { ... }}
if (fieldName != null) {
throw new QueryParsingException(parseContext, "[term] query does not support different field names, use [terms] query");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would modify the error message here, one cannot use the terms query instead against multiple fields, you should rather combine multiple term queries in a bool query I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid. fixed

@javanna
Copy link
Member

javanna commented Jul 13, 2015

LGTM besides a minor comment

The term query parser was too lenient during parsing and allowed to specify
more than one field, even though this expected to filter only for a single field.

This commit returns an exception if a query has been specified more than once.

Closes elastic#12184
@spinscale spinscale force-pushed the 1507-term-filter-parser-issue-12184 branch from a1d6f96 to 195c8ec Compare July 13, 2015 07:59
@spinscale spinscale merged commit 195c8ec into elastic:master Jul 13, 2015
@kevinkluge kevinkluge removed the review label Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants