Hi,
Here is the recreation steps:
PUT /product
{
"mappings" : {
"properties" : {
"product_id": { "type" : "long" },
"product_name": { "type" : "keyword" }
}}}
POST product/_doc
{
"product_id": 22,
"product_name": "abc"
}
POST product/_doc
{
"product_id": 36,
"product_name": "mobile"
}
POST product/_doc
{
"product_id": 58,
"product_name": "tablet"
}
POST product/_doc
{
"product_id": 87,
"product_name": "watch"
}
POST product/_doc
{
"product_id": 100,
"product_name": "footwear"
}
Execute below query-
GET product/_search?size=100
{
"query": {
"bool": {
"must": [
{
"range": {
"product_id": {
"from": 1,
"to": "99"
}
}
}
],
"should": [
{
"term": {
"product_id": {
"value": "100"
}
}
}
]
}
}
}
Result:
{
"took" : 735,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "product",
"_type" : "_doc",
"_id" : "P0GzcYgB6QnR66-pMZvJ",
"_score" : 1.0,
"_source" : {
"product_id" : 36,
"product_name" : "mobile"
}
},
{
"_index" : "product",
"_type" : "_doc",
"_id" : "3_CycYgBdvuNheCty-RK",
"_score" : 1.0,
"_source" : {
"product_id" : 22,
"product_name" : "abc"
}
},
{
"_index" : "product",
"_type" : "_doc",
"_id" : "4PCzcYgBdvuNheCtsuTl",
"_score" : 1.0,
"_source" : {
"product_id" : 87,
"product_name" : "watch"
}
},
{
"_index" : "product",
"_type" : "_doc",
"_id" : "QEGzcYgB6QnR66-pbptD",
"_score" : 1.0,
"_source" : {
"product_id" : 58,
"product_name" : "tablet"
}
}
]
}
}
Expected result: Result should also display the record with product_id - 100.
Actual Result: Result doesn't have the record with product_id - 100.