Prefix Query doesn't apply the analyzer used when indexing


(Trym) #1

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
)

Any comments are appreciated and welcome.

Best regards Trym


(Shay Banon) #2

Prefix query will not be analyzed (as documented:
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:
http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html.

On Fri, Oct 7, 2011 at 1:41 PM, Trym 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 (
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


(system) #3