WildcardQuery and case sensitivity


(Manish Pandit) #1

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an
un-analyzed field which I am querying using a wildcardQuery, but for
some reason not getting any results when I change the case of the
search text. Please let me know if I could be doing this wrong or if
this is expected behavior.

-cheers,
Manish


(Karussell) #2

Do you have a lower case token filter for indexing + searching?

Peter.

On Nov 8, 7:41 am, Manish Pandit pandit.man...@gmail.com wrote:

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an
un-analyzed field which I am querying using a wildcardQuery, but for
some reason not getting any results when I change the case of the
search text. Please let me know if I could be doing this wrong or if
this is expected behavior.

-cheers,
Manish


(Manish Pandit) #3

On Nov 7, 11:03 pm, Karussell tableyourt...@googlemail.com wrote:

Do you have a lower case token filter for indexing + searching?

Peter.

On Nov 8, 7:41 am, Manish Pandit pandit.man...@gmail.com wrote:

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an
un-analyzed field which I am querying using a wildcardQuery, but for
some reason not getting any results when I change the case of the
search text. Please let me know if I could be doing this wrong or if
this is expected behavior.

-cheers,
Manish

Nope, everything is default. Not specifying any custom or out of the
box filter or indexer.

-cheers,
Manish


(Shay Banon) #4

The wildcard query does not perform any analysis on the text you provide as
the query. If the field you index on is analyzed, this can be problematic
(like indexing "Snow", but not finding "Sn*").

On Tue, Nov 8, 2011 at 9:08 AM, Manish Pandit pandit.manish@gmail.comwrote:

On Nov 7, 11:03 pm, Karussell tableyourt...@googlemail.com wrote:

Do you have a lower case token filter for indexing + searching?

Peter.

On Nov 8, 7:41 am, Manish Pandit pandit.man...@gmail.com wrote:

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an
un-analyzed field which I am querying using a wildcardQuery, but for
some reason not getting any results when I change the case of the
search text. Please let me know if I could be doing this wrong or if
this is expected behavior.

-cheers,
Manish

Nope, everything is default. Not specifying any custom or out of the
box filter or indexer.

-cheers,
Manish


(Igor Motov) #5

Manish,

It's possible that I misunderstood your question. But if you have a field
that is not analyzed (you have specified "index" : "not_analyzed" in the
mapping), you might be hitting this lucene feature:
http://wiki.apache.org/lucene-java/LuceneFAQ#Are_Wildcard.2C_Prefix.2C_and_Fuzzy_queries_case_sensitive.3F

Basically, if you index word "Snow" in a field that is not analyzed, it's
indexed as "Snow". But if you search for "Sn*", your query is getting
translated into Lucene prefix query for prefix "sn". In other words Lucene
lowercases your wildcard queries by default. As a result, you query for
"Sn*" doesn't return "Snow", but it may return "snow", for example. You can
turn this feature off by specifying "lowercase_expanded_terms": false in
your query:

curl -s -XGET "http://localhost:9200/testindex/_search" -d '{"query":
{"query_string": {"query": "testfield:Sn*", "lowercase_expanded_terms":
false }}}"' ; echo

Igor

On Wed, Nov 9, 2011 at 5:35 AM, Shay Banon kimchy@gmail.com wrote:

The wildcard query does not perform any analysis on the text you provide
as the query. If the field you index on is analyzed, this can be
problematic (like indexing "Snow", but not finding "Sn*").

On Tue, Nov 8, 2011 at 9:08 AM, Manish Pandit pandit.manish@gmail.comwrote:

On Nov 7, 11:03 pm, Karussell tableyourt...@googlemail.com wrote:

Do you have a lower case token filter for indexing + searching?

Peter.

On Nov 8, 7:41 am, Manish Pandit pandit.man...@gmail.com wrote:

Hi,

I wanted to know if the wildcardQueries are case sensitive - I have an
un-analyzed field which I am querying using a wildcardQuery, but for
some reason not getting any results when I change the case of the
search text. Please let me know if I could be doing this wrong or if
this is expected behavior.

-cheers,
Manish

Nope, everything is default. Not specifying any custom or out of the
box filter or indexer.

-cheers,
Manish


(system) #6