Query with Hyphen (-) at the beginning always returns all documents of the index


#1

Hi all,
I have this problem.
I have an index (ivy_task) with mapping and its field (barCode) like this

PUT ivy_task/_mapping/ElasticTaskInfo
{
"properties" : {
"barCode" : {
"type" : "text",
"fielddata" : true,
"analyzer": "keyword"
}
}
}

Please note that i have 7 documents in this index

And when i use the query like this to search (with the hyphen at the beginning):

POST /ivy_task/ElasticTaskInfo/_search/
{
"query":{"query_string": {
"default_field": "barCode",
"query": "-t"
}},
"size": 99
}

As long as i put hyphen at the beginning of the query, It always returns all 7 documents. (For example: -t. -d, -bbbbbbbbbbbbb. -aaaa1111)
Can someone help me to explain why it returns all 7 documents ?
Here are the barCode of all 7 documents:
almostThere009
a-tinhte001
almostThere0011
almostThere0012
a-almostThere0014
almostThere0010
a-almostThere0013

Thanks.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.