Does sort nested_filter supports term search in array?


(Harpreet Bhatia) #1

We have a query to search against multiple treatment slugs,
the field is nested under each hospital. The hospital-treatment mapping looks like

{
    "properties":{
        "treatments":{
            "properties":{
                "child_of":{
                    "type":"integer"
                },
                "highest_price":{
                    "type":"long"
                },
                "hospital_id":{
                    "type":"integer"
                },
                "hp_low_priority":{
                    "type":"integer"
                },
                "id":{
                    "type":"integer"
                },
                "keywords":{
                    "type":"string"
                },
                "low_priority":{
                    "type":"integer"
                },
                "lowest_price":{
                    "type":"long"
                },
                "lp_low_priority":{
                    "type":"integer"
                },
                "procedure_count":{
                    "type":"long"
                },
                "status":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "treatment_id":{
                    "type":"integer"
                },
                "treatment_name":{
                    "type":"string"
                },
                "treatment_price":{
                    "type":"long"
                },
                "treatment_slug":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "treatment_status":{
                    "index":"not_analyzed",
                    "type":"string"
                }
            }
        }
    }
}

the params for sorting looks like

$params["body"]["sort"] = [
                                                    "treatments.lowest_price" => [
                                                        "mode" => "avg",
                                                        "order" => "$order",
                                                        "nested_filter" => [
                                                            "term" => [
                                                                "treatments.treatment_slug" => $tSlug
                                                            ]
                                                        ]
                                                    ]
                                                ];

the variable

 $tSlug

may have one value ["treatment_one"] or multiple like

["treatment_one", "treatment_two"]

the results I get are no ordered by price. What could be wrong with the query?


(system) #2