Assuming that you are using standard analyzer, this is what these 5 queries
are translated into on Lucene level:
1: _all:24* - prefix query for terms that start with "24"
2: _all:24 _all:account - query for the term "24" or the term "account"
3: _all:24 _all:a* - query for the term "24" or prefix query for terms
that start with "a"
4: _all:a* - prefix query for terms that start with "a"
5: _all:24/a* - prefix query for terms that start with "24/a"
Cases 2-4 are obvious, but cases 1 and 5, probably, require some
explanation. By default, wildcard terms are not analyzed. This is why 5th
case is getting translated into prefix query with the prefix "24/a". As you
correctly noticed, "24/account" is indexed as two tokens "24" and
"account". So, there are no tokens in the index that start with 24/a and
therefore 5th case doesn't return any results. In the case 1, wildcard
terms are analyzed and "24/a" is getting translated into two tokens "24"
and "a". The token "a*" is a stopword and it's getting dropped and the
query is getting translated into prefix query for terms that start with 24.
On Wednesday, March 21, 2012 6:29:49 PM UTC-4, chimingc wrote:
I've indexed this: "24/account".
I understand that it's been tokenized into "24" and "account", which is not
a problem for me.However, when I query "24/a*", it finds no match.
Then I tried the following cases:
This works
"query_string": {
"analyze_wildcard": true,
"query":"24/a*"
}This works
"query_string": {
"query":"24/account"
}This works
"query_string": {
"query":"24 / a*"
}This works
"query_string": {
"query":"a*"
}This doesn't work
"query_string": {
"query":"24/a*"
}I can't explain why 5 doesn't work. Perhaps without setting
analyze_wildcard
to true, elasticsearch simply removes the slash and searches for "24a*"?What exactly does analyze_wildcard do when set to true?
As you can see 3 and 4 work without setting analyze_wildcard to true. So
when do we need to set it to true?Thanks,
jimmy--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/wildcard-and-slashes-tp3847057p3847057.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.