I've tried the 2 Lucene queries below in my HTTP GET requests, to search documents in my ElasticSearch :

q=(Name:\"20190401_150454_992\" OR \"test video\")

and

q=(Name:\"test video\" OR \"20190401_150454_992\")

The 1st result contains this document only :

"_source": {
    "Name": "test video",
    "Latitude": 25.1062949,
    ...
}

and the 2nd result contains the document above, and

"_source": {
    "Name": "20190401_150454_992",
    "Latitude": 0,
    ...
}

also.

I expected that the results should be the same(they should return the 2 documents in both queries), since I didn't change any other condition, except for the order of query fields in query string, but they were NOT. Could anyone explain why? Thanks!

I'm using ElasticSearch 5.5.2.

1 Answers

0
Karsten R. On

Your question is about the difference of

q=(Name:\"test video\" OR \"20190401_150454_992\")

and

q=(Name:\"20190401_150454_992\" OR \"test video\")

Be aware that the field "Name" is only bind to your first phrase. So please try

q=Name:(\"test video\" OR \"20190401_150454_992\")

because your query is equal to

q=Name:\"test video\" OR _all:\"20190401_150454_992\"

Why? Because there is a default search field: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/mapping-all-field.html#querying-all-field