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

Leniency makes simple_query_string query a match_all #7967

Closed
shoteff opened this issue Oct 3, 2014 · 1 comment · Fixed by #8162
Closed

Leniency makes simple_query_string query a match_all #7967

shoteff opened this issue Oct 3, 2014 · 1 comment · Fixed by #8162
Assignees
Labels

Comments

@shoteff
Copy link

shoteff commented Oct 3, 2014

As far as I can see since 1.3.3 when query is using "lenient" parameter it yelds results when we have format based failures (at least in 1.3.2 it does not return any results).
When searching by non-existing subfields (i.e. "field.nonexisting") no errors and no results are found (which seems to be correct)
The problem comes when I combine queries from both types - with "lenient" and format failure and with non-existing fields in a "should" boolean query
I'm tested with 1.3.4 version and 1.4.0-beta1
Here are the structure, test data and queries I tested with:
Structure
https://gist.github.com/shoteff/3ee9f2ad320410375c91
Data
https://gist.github.com/shoteff/f5c23bd6bb85f6fecdc9
Queries - here I also described what is working and what not
https://gist.github.com/shoteff/20fa2411ede09068ce95

@clintongormley clintongormley changed the title Inconsistent "lenient" behaviour Leniency makes simple_query_string query a match_all Oct 14, 2014
@clintongormley clintongormley added >bug and removed >bug labels Oct 14, 2014
@clintongormley
Copy link

Simple demo:

DELETE t

PUT /t/test/1
{
    "id": 1,
    "title": "this is test1"
}

GET /_validate/query?explain
{
  "query": {
    "bool": {
      "should": [
        {
          "simple_query_string": {
            "query": "this",
            "fields": [
              "id",
              "title"
            ],
            "default_operator": "and",
            "lenient": true
          }
        }
      ]
    }
  }
}

The above results in a match-all query:

{
   "valid": true,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "explanations": [
      {
         "index": "t",
         "valid": true,
         "explanation": "*:*"
      }
   ]
}

@clintongormley clintongormley added the help wanted adoptme label Oct 14, 2014
@dakrone dakrone self-assigned this Oct 20, 2014
@dakrone dakrone removed the help wanted adoptme label Oct 20, 2014
dakrone added a commit to dakrone/elasticsearch that referenced this issue Oct 22, 2014
Previously, the leniency was on a per-query basis, with each query being
parsed into multiple queries, one for each field. If any one of these
queries failed, the entire query was discarded in the name of being
lenient.

Now query parts will only be discarded if they fail for a particular
field, the entire query is not discarded. This helps when performing a
query over a numeric and string field, as only the sub-queries that are
invalid due to format exceptions will be discarded.

Also moves the `simple_query_string` queries out of SimpleQueryTests and
into a dedicated SimpleQueryStringTests class.

Fixes elastic#7967
dakrone added a commit that referenced this issue Oct 22, 2014
Previously, the leniency was on a per-query basis, with each query being
parsed into multiple queries, one for each field. If any one of these
queries failed, the entire query was discarded in the name of being
lenient.

Now query parts will only be discarded if they fail for a particular
field, the entire query is not discarded. This helps when performing a
query over a numeric and string field, as only the sub-queries that are
invalid due to format exceptions will be discarded.

Also moves the `simple_query_string` queries out of SimpleQueryTests and
into a dedicated SimpleQueryStringTests class.

Fixes #7967
dakrone added a commit that referenced this issue Oct 22, 2014
Previously, the leniency was on a per-query basis, with each query being
parsed into multiple queries, one for each field. If any one of these
queries failed, the entire query was discarded in the name of being
lenient.

Now query parts will only be discarded if they fail for a particular
field, the entire query is not discarded. This helps when performing a
query over a numeric and string field, as only the sub-queries that are
invalid due to format exceptions will be discarded.

Also moves the `simple_query_string` queries out of SimpleQueryTests and
into a dedicated SimpleQueryStringTests class.

Fixes #7967
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Previously, the leniency was on a per-query basis, with each query being
parsed into multiple queries, one for each field. If any one of these
queries failed, the entire query was discarded in the name of being
lenient.

Now query parts will only be discarded if they fail for a particular
field, the entire query is not discarded. This helps when performing a
query over a numeric and string field, as only the sub-queries that are
invalid due to format exceptions will be discarded.

Also moves the `simple_query_string` queries out of SimpleQueryTests and
into a dedicated SimpleQueryStringTests class.

Fixes elastic#7967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants