Hi folks,
I have an index with documents that are customer centric. Every document has customer ID, array of orders, within orders array we have an items array. Both orders and items fields are of type nested. There is an issue when I use the SQL translate API.
POST /_sql/translate
{
"query": "Select count(*) FROM \"notusstagingaccount-customer\" where ((orders.items.product_attributes.DepartmentName = 'M Sptwr:Tops' AND orders.items.sale_price > 50) AND (orders.items.product_attributes.DepartmentName = 'M Sptwr:Tops' AND orders.items.quantity > 50))"
}
Resultant query:
{
"size" : 0,
"query" : {
"bool" : {
"must" : [
{
"bool" : {
"must" : [
{
"nested" : {
"query" : {
"term" : {
"orders.items.product_attributes.DepartmentName" : {
"value" : "M Sptwr:Tops",
"boost" : 1.0
}
}
},
"path" : "orders.items",
"ignore_unmapped" : false,
"score_mode" : "none",
"boost" : 1.0
}
},
{
"nested" : {
"query" : {
"range" : {
"orders.items.sale_price" : {
"from" : 50,
"to" : null,
"include_lower" : false,
"include_upper" : false,
"boost" : 1.0
}
}
},
"path" : "orders.items",
"ignore_unmapped" : false,
"score_mode" : "none",
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must" : [
{
"nested" : {
"query" : {
"term" : {
"orders.items.product_attributes.DepartmentName" : {
"value" : "M Sptwr:Tops",
"boost" : 1.0
}
}
},
"path" : "orders.items",
"ignore_unmapped" : false,
"score_mode" : "none",
"boost" : 1.0
}
},
{
"nested" : {
"query" : {
"range" : {
"orders.items.quantity" : {
"from" : 50,
"to" : null,
"include_lower" : false,
"include_upper" : false,
"boost" : 1.0
}
}
},
"path" : "orders.items",
"ignore_unmapped" : false,
"score_mode" : "none",
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"_source" : false,
"stored_fields" : "_none_",
"sort" : [
{
"_doc" : {
"order" : "asc"
}
}
],
"track_total_hits" : 2147483647
}
The nested query appears within the boolean must clause where as the expection is multiple boolean must clauses within a nested query clause with path specified. Any help here is appreciated.