# Prefix Query doesn't apply the analyzer used when indexing

**URL:** <https://discuss.elastic.co/t/prefix-query-doesnt-apply-the-analyzer-used-when-indexing/5540>\
**Category:** Elasticsearch\
**Created:** [October 7, 2011, 11:41am UTC](https://discuss.elastic.co/t/prefix-query-doesnt-apply-the-analyzer-used-when-indexing/5540 "2011-10-07T11:41:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trym](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@Trym](https://discuss.elastic.co/u/Trym)\
**Post date:** [October 7, 2011, 11:41am UTC](https://discuss.elastic.co/t/prefix-query-doesnt-apply-the-analyzer-used-when-indexing/5540/1 "2011-10-07T11:41:06Z")

</div>

Hi

I cannot figure out why the prefix query doesn't apply the same analyzer  
that has been used when indexing the document.  
E.g. indexing "ReaLise" puts "realise" into the index but searcing using a  
prefix query like QueryBuilders.prefixQuery("fieldName", "ReaLise") doesn't  
return anything as opposed to QueryBuilders.prefixQuery("fieldName",  
"realise"), note the lower-case.

I will only be able to find terms that are in the index (that is terms which  
have had the analyser applied), so why can the prefix query not apply it?  
Is there any way in the Java API to specify that the prefix query should use  
the analyser?  
I read that Lucene had a method to say the prefix term was case in sensitive  
(  
[http://wiki.apache.org/lucene-java/LuceneFAQ#Are\_Wildcard.2C\_Prefix.2C\_and\_Fuzzy\_queries\_case\_sensitive.3F](http://wiki.apache.org/lucene-java/LuceneFAQ#Are_Wildcard.2C_Prefix.2C_and_Fuzzy_queries_case_sensitive.3F)  
)

Any comments are appreciated and welcome.

Best regards Trym

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 8, 2011, 6:39pm UTC](https://discuss.elastic.co/t/prefix-query-doesnt-apply-the-analyzer-used-when-indexing/5540/2 "2011-10-08T18:39:41Z")

</div>

Prefix query will not be analyzed (as documented:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html)).  
You can use one of the variance of the text query to have a prefix query  
that is analyzed:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html).

On Fri, Oct 7, 2011 at 1:41 PM, Trym [trym@sigmat.dk](mailto:trym@sigmat.dk) wrote:

> Hi
> 
> I cannot figure out why the prefix query doesn't apply the same analyzer  
> that has been used when indexing the document.  
> E.g. indexing "ReaLise" puts "realise" into the index but searcing using a  
> prefix query like QueryBuilders.prefixQuery("fieldName", "ReaLise") doesn't  
> return anything as opposed to QueryBuilders.prefixQuery("fieldName",  
> "realise"), note the lower-case.
> 
> I will only be able to find terms that are in the index (that is terms  
> which have had the analyser applied), so why can the prefix query not apply  
> it?  
> Is there any way in the Java API to specify that the prefix query should  
> use the analyser?  
> I read that Lucene had a method to say the prefix term was case in  
> sensitive (  
> [LuceneFAQ - Apache Lucene (Java) - Apache Software Foundation](http://wiki.apache.org/lucene-java/LuceneFAQ#Are_Wildcard.2C_Prefix.2C_and_Fuzzy_queries_case_sensitive.3F)  
> )
> 
> Any comments are appreciated and welcome.
> 
> Best regards Trym

---

<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, 3:52am UTC](https://discuss.elastic.co/t/prefix-query-doesnt-apply-the-analyzer-used-when-indexing/5540/3 "2017-07-06T03:52:33Z")

</div>


