# Does sort nested\_filter supports term search in array?

**URL:** <https://discuss.elastic.co/t/does-sort-nested-filter-supports-term-search-in-array/31647>\
**Category:** Elasticsearch\
**Created:** [October 5, 2015, 3:57pm UTC](https://discuss.elastic.co/t/does-sort-nested-filter-supports-term-search-in-array/31647 "2015-10-05T15:57:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harpreet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harpreet/32/3413_2.png) [@harpreet](https://discuss.elastic.co/u/harpreet)\
**Post date:** [October 5, 2015, 3:57pm UTC](https://discuss.elastic.co/t/does-sort-nested-filter-supports-term-search-in-array/31647/1 "2015-10-05T15:57:19Z")

</div>

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

```auto
{
    "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

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

```

the variable

```php
 $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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:46pm UTC](https://discuss.elastic.co/t/does-sort-nested-filter-supports-term-search-in-array/31647/2 "2017-07-05T23:46:41Z")

</div>


