# Facet array field autocompletion

**URL:** <https://discuss.elastic.co/t/facet-array-field-autocompletion/12680>\
**Category:** Elasticsearch\
**Created:** [July 5, 2013, 3:02pm UTC](https://discuss.elastic.co/t/facet-array-field-autocompletion/12680 "2013-07-05T15:02:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Molnar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samuel_molnar/32/2253_2.png) [@Samuel\_Molnar](https://discuss.elastic.co/u/Samuel_Molnar)\
**Post date:** [July 5, 2013, 3:02pm UTC](https://discuss.elastic.co/t/facet-array-field-autocompletion/12680/1 "2013-07-05T15:02:24Z")

</div>

I want to create autocompletition for facets. For example, you filter  
document by value of some field using wildcard query like this:  
{  
"query": {  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": "foobar\* ",  
"default\_operator": "and",  
"analyze\_wildcard": true,  
"fields": [  
"foo\_field.analyzed"  
]  
}  
}  
]  
}  
}  
}

Autocomplete values are created as terms facet on foo\_field.untouched  
(not\_analyzed field).

If the foo\_field is an array and consists of [foobar, bar], autocomplete  
facet values are foobar, bar - but i only want to get matching value -  
foobar.

I used suggest feature and suggester plugin already, but i need to  
constrain the documents with query and filter (for facet using  
facet\_filter) and also i need to include facet counts, so my only options  
is to use facets with facet filter.

Is there any way to create facet on values of document only matching the  
given value if the field is an array without using facet script? Can i use  
facets on nested attributes or object to achieve this somehow?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:28am UTC](https://discuss.elastic.co/t/facet-array-field-autocompletion/12680/2 "2017-07-06T02:28:00Z")

</div>


