# How to filter out a few inner objects from search query results

**URL:** <https://discuss.elastic.co/t/how-to-filter-out-a-few-inner-objects-from-search-query-results/203080>\
**Category:** Elasticsearch\
**Created:** [October 10, 2019, 5:50pm UTC](https://discuss.elastic.co/t/how-to-filter-out-a-few-inner-objects-from-search-query-results/203080 "2019-10-10T17:50:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smaheshbhat](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@smaheshbhat](https://discuss.elastic.co/u/smaheshbhat)\
**Post date:** [October 10, 2019, 5:50pm UTC](https://discuss.elastic.co/t/how-to-filter-out-a-few-inner-objects-from-search-query-results/203080/1 "2019-10-10T17:50:03Z")

</div>

Hi,

I have the following schema and two documents and a search query on them. I want to know how can I only display specific language's names and descriptions in each of my search result. For example in the query result for below query, I get all the names and descriptions in all languages. But if I pass a locale as 'fr' I would like names and descriptions only in french. Not in any other languages.  
Thanks,

PUT /product/  
{

```
"mappings": {
    "productTypeA":{
        "dynamic": "strict", 
        "properties":{
            "id": { "type": "keyword" }, 
            "model": { "type": "keyword"}, 
            "version": { "type": "keyword" },  
            "launchDate": { "type": "date", 
                "format": "yyyyMMdd'T'HHmmss.SSSZ",
                "fields": {
                    "keyword": { 
                    "type": "keyword"
                    }
                }
            }, 
            "role" :{"type": "keyword" },
            "updatedBy":{"type": "keyword" },
            "names": { "type": "object",
                                "properties":{
                                  "locale":{"type":"keyword"},
                                  "value":{"type":"keyword"}
                                }},
                    "descriptions": { "type": "object",
                                "properties":{
                                  "locale":{"type":"keyword"},
                                  "value":{"type":"keyword"}
                                }}
        }
    }
}

```

}

POST /product/productTypeA/1  
{  
"id":"1",  
"model":"modelA",  
"version":"1.0",  
"launchDate": "20190924T175212.057+0000",  
"updatedBy":"m1",  
"role": ["role1", "role2"],  
"names":[{"locale":"en", "value":"product one"}, {"locale":"fr", "value":"produit un"},  
{"locale":"de", "value": "Produkt eins"}],  
"descriptions":[{"locale":"en", "value":"product one description"}, {"locale":"fr", "value":"description du produit un"},  
{"locale":"de", "value": "Produkt eins Beschreibung"}]  
}

POST /product/productTypeA/2  
{  
"id":"2",  
"model":"modelB",  
"version":"1.0",  
"launchDate": "20190924T175212.057+0000",  
"updatedBy":"m1",  
"role": ["role1"],  
"names":[{"locale":"en", "value":"product two"}, {"locale":"fr", "value":"produit deux"},  
{"locale":"de", "value": "Produkt zwei"}],  
"descriptions":[{"locale":"en", "value":"product two description"}, {"locale":"fr", "value":"description du produit deux"},  
{"locale":"de", "value": "Produkt zwei Beschreibung"}]  
}

GET /product/productTypeA/\_search  
{  
"query": {  
"bool": {  
"must": [  
{  
"term": {  
"model": "modelA"  
}  
},  
{  
"bool": {  
"should": [  
{  
"bool": {  
"must\_not": {  
"exists": {  
"field": "role"  
}  
}  
}  
},  
{  
"term": {  
"role": "role2"  
}  
}  
]  
}  
}  
]  
}  
}

}

---

<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:** [November 7, 2019, 5:50pm UTC](https://discuss.elastic.co/t/how-to-filter-out-a-few-inner-objects-from-search-query-results/203080/2 "2019-11-07T17:50:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
