Skip to content

Wrong result of "simple_query_search" with prefix query. #28204

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

Closed
lbrzekowski opened this issue Jan 12, 2018 · 3 comments
Closed

Wrong result of "simple_query_search" with prefix query. #28204

lbrzekowski opened this issue Jan 12, 2018 · 3 comments
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@lbrzekowski
Copy link

Elasticsearch version
6.1.0

Plugins installed: []

JVM version (java -version):
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

OS version:
Ubuntu 17.10 with 4.13.0-21-generic

Description of the problem including expected versus actual behavior:
When index's mapping includes text and date properties, result of simple_query_search, which includes asterisk for prefix query,
returns no documents.
When there's no date properties on index's mappping, query works fine.
The same query works fine on 5.6 version.

Steps to reproduce:

  1. Create index "tests" with text and date properties.
curl -XPUT http://localhost:9200/tests -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{
  "mappings": {
    "test": {
      "properties": {
        "date": {
          "type": "date"
        },
        "name": {
          "type": "text",
          "fields": {
            "raw": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}'
  1. Put some data
curl -XPUT http://localhost:9200/tests/test/1 -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
{
  "date": "2018-01-12",
  "name": "test1"
}'
  1. Try to search with simple_query_search and asterisk.
curl -XPOST http://localhost:9200/tests/_search -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
{
  "query": {
    "simple_query_string": {
      "query": "te*"
    }
  }
}'

Received result: no documents found
Expected result: document with id 1 found

Provide logs (if relevant):
there's no errors on logs

@dakrone
Copy link
Member

dakrone commented Jan 12, 2018

I was able to reproduce this on ES 6.1.0 and 6.1.1, for some reason it's being rewritten to "explanation" : "MatchNoDocsQuery(\"empty string passed to query parser\")"

For the meantime, query_string behaves correctly and retrieves the document.

@jimczi jimczi self-assigned this Jan 15, 2018
jimczi added a commit to jimczi/elasticsearch that referenced this issue Jan 15, 2018
This change converts any exception that occurs during the parsing of
a simple_query_string to a match_no_docs query (instead of a null query)
when leniency is activated.

Closes elastic#28204
@lbrzekowski
Copy link
Author

@jimczi I've built elasticsearch from your branch 'bugs/lenient_simple_query_string' and I run steps to reproduce the bug and nothing changes from my perspective. The response is still 0 documents instead of 1 document found. I've noticed that the only change is in "explanation.description" in response of

curl -XPOST http://localhost:9200/tests/test/1/_explain -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
{
  "query": {
    "simple_query_string": {
      "query": "te*"
    }
  }
}'

@jimczi
Copy link
Contributor

jimczi commented Jan 15, 2018

You're right @lbrzekowski, my fix was only to get the expected exceptions. I pushed another commit to continue with the other fields when leniency is on and we hit an exception on a field.

jimczi added a commit that referenced this issue Jan 18, 2018
This change converts any exception that occurs during the parsing of
a simple_query_string to a match_no_docs query (instead of a null query)
when leniency is activated.

Closes #28204
jimczi added a commit that referenced this issue Jan 18, 2018
This change converts any exception that occurs during the parsing of
a simple_query_string to a match_no_docs query (instead of a null query)
when leniency is activated.

Closes #28204
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

4 participants