This is my question related to my previous question that I asked search stops after the first match
Here I am giving you the mapping.
{
"copy_order_snapshot": {
"properties": {
"line_item_info": {
"dynamic": "true",
"properties": {
"m_product_details": {
"dynamic": "true",
"properties": {
"accessories_colour": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"other_details": {
"dynamic": "true",
"properties": {
"accessories_material_type": {
"type": "string"
}
"status": {
"type": "string"
}
}
},
"product_details": {
"dynamic": "true",
"properties": {
"accessories_colour": {
"type": "string"
},
"status": {
"type": "string"
}
}
}
}
},
"order_data": {
"dynamic": "true",
"properties": {
"state": {
"type": "string"
},
"status": {
"type": "string"
}
}
}
}
}
}
In my previous question I was talking about attribute_set_id , here the same case is with status. The order_details->status is "enabled" while the other status are as "1" and "canceled". When I search for
{
"query":{
"term":{
"status":"enabled"
}
}
}
I get the result
but if I search for
{
"query":{
"term":{
"status":"1"
}
}
}
or
{
"query":{
"term":{
"status":"canceled"
}
}
}
I get no results.
Please help.
It happens because of ambiguous field name “status”. During query processing, elasticsearch resolves the field name “status” into the first fully qualified field name that it matches. When I ran it on my machine, it got resolved into line_item_info.other_details.status.
If you want your query to match all status fields, you might need to use fully qualified names (such as
line_item_info.other_details.status,line_item_info.m_product_details.status, etc.) and combine them using Dis Max or Bool Queries.For example: