By inserting the documents without specifying the datatype of the field_name field in the mapping. Elasticsearch will create 2 versions of the field (text and keyword).
If you analyze the field_name field with the value "50%", it's indexed as "50" (text type).
So that means, to get the expected result, you should run the query, with the keyword version :
GET testing_with_percent/_search
{
"query": {
"query_string": {
"query": "field_name.keyword: [50% TO 90%]"
}
}
}
or with the indexed values :
GET testing_with_percent/_search
{
"query": {
"query_string": {
"query": "field_name: [50 TO 90]"
}
}
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.