I have a number field on my index which works as a count and the problem is when I try to query that field equals 0, I don't get any value.
I'm sure about possible values in the Index because If I execute the query without any filter it returns at least 50 occurrences where the field equals 0.
I tried with term:
GET contacts/_search
{
"query": {
"term": {
"investmentsCount": {
"value": 0
}
}
}
}
or using range
GET contacts/_search
{
"query": {
"range": {
"investmentsCount": {
"lte": 0
}
}
}
}
Also, I tried with range with "lt": 1 and it didn't return anything. Even if I try less_than < 2, I receive just the ones with count = 1 but not the 0 ones. Any tips?
Sample Document:
GET contacts/_search
{
"query": {
"term": {
"investmentsCount": {
"value": 1
}
}
}
}
"hits" : {
"total" : {
"value" : 432,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "contacts",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"id" : "1",
"accountId" : "1",
"committed" : 7500000,
"contributed" : 7500000,
"investedMax" : "2020-03-18T01:53:31.160Z",
"investedMin" : "2020-03-18T01:53:31.160Z",
"investmentsCount" : 1,
"status" : "ACTIVE",
"updated" : "2020-03-18T01:43:39.854Z",
"userId" : "1",
"withdrawnMax" : "2020-03-18T01:53:58.092Z",
"withdrawnMin" : "2020-03-18T01:53:58.092Z"
}
}
]
}
"investmentsCount" : 0