# Analyzed prefix filter

**URL:** <https://discuss.elastic.co/t/analyzed-prefix-filter/10917>\
**Category:** Elasticsearch\
**Created:** [February 27, 2013, 2:26am UTC](https://discuss.elastic.co/t/analyzed-prefix-filter/10917 "2013-02-27T02:26:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveey](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@daveey](https://discuss.elastic.co/u/daveey)\
**Post date:** [February 27, 2013, 2:26am UTC](https://discuss.elastic.co/t/analyzed-prefix-filter/10917/1 "2013-02-27T02:26:52Z")

</div>

is there a way to have prefix filter get analyzed? i want to somehow get

query: "hel wor" to match {name: "hello world"}

currently, i construct an {and: [{prefix: {name: "hel"}}, {prefix: {name: "wor"}}]}

but this means i have to tokenize the query myself. i'd love to use the same analyzer as i used for indexing.

i considered using the analyze API call to first get the tokens from the query, and then use them to construct the prefix clauses, but it would be nice to avoid the second roundtrip

thanks in advance for any ideas!

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 27, 2013, 2:18pm UTC](https://discuss.elastic.co/t/analyzed-prefix-filter/10917/2 "2013-02-27T14:18:54Z")

</div>

On Tue, 2013-02-26 at 18:26 -0800, daveey wrote:

> is there a way to have prefix filter get analyzed? i want to somehow get
> 
> query: "hel wor" to match {name: "hello world"}
> 
> currently, i construct an {and: [{prefix: {name: "hel"}}, {prefix: {name:  
> "wor"}}]}
> 
> but this means i have to tokenize the query myself. i'd love to use the same  
> analyzer as i used for indexing.
> 
> i considered using the analyze API call to first get the tokens from the  
> query, and then use them to construct the prefix clauses, but it would be  
> nice to avoid the second roundtrip

Best is just to avoid the prefix filter 🙂

Analyze your text with edge-ngrams or ngrams, and you can achieve the  
same thing, but with more efficient queries.

Search this list for questions about ngrams - there are lots of threads  
about how to use them

clint

--  
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:49am UTC](https://discuss.elastic.co/t/analyzed-prefix-filter/10917/3 "2017-07-06T02:49:20Z")

</div>


