Initially, I had some documents with inner objects in them and I was performing queries that returned reasonable results.
In order to perform queries on those inner objects correctly with multiple required conditions (like ConditionA AND ConditionB
) I have decided to convert some of the inner objects into nested objects and reindex the data.
Now, I am noticing many weird behaviors while performing queries. One is this:
Query:
POST documents\_search
{
"query": {
"term": {
"copies.idOwnedByGroup": 1
}
}
}
Result:
Query:
POST documents\_search
{
"query": {
"match_all": {
}
}
}
One of the results:
The copies
object is a nested object. Here is the mapping:
Why doesn't the first query find this document? This seemed to work with copies
not being a nested object.
I am also using the OpenSearch.Client
library and that also produces similar queries that don't seem to work anymore.
When I try this, it seems to work (it returns many matching results):
POST documents\_search
{
"query": {
"nested": {
"path": "copies",
"query":{
"term": {
"copies.idOwnedByGroup": 1
}
}
}
}
}
But I have some questions:
path
and OpenSearch figures things out when it comes to the inner nested object?I have the answers:
path
.