Wildcard query returns null when Uppercase Letters are used


#1

Hi, I am developing a search site which calls elasticsearch internally. I am using wildcard query to match entered text. everything works well when lowercase letters are entered. But when Uppercase letters are entered the results come up only for the complete word and not for the partial letters.
The word is queried in the below fashion.

var query=
			{
				"wildcard":{
					_all:"* "+term+"*"
					}
			};

I have not used any custom filters or analyzers for the index. I just create an index and insert strings into the types.

Please could someone tell me what is wrong with my approach. Or any alternate suggestions are also welcome.

Thanks


(David Pilato) #2

Don't use wildcard queries. At least don't use them with a wildcard * at the beginning of your query. It will be extremely slow!

Wildcard queries are not analyzed. It means that we compare exactly the term with the inverted index.

For example, with default analyzer, Foo BAR will be indexed as foo, bar.
If you search with a wildcard for *BAR*, BAR is not bar. So it won't match.


#3

Thank you David!

So what do you suggest me to use. I need search results on every string entered in the search bar. I tried using match, but it did not work as expected.


(David Pilato) #4

Use another analyzer. Such as ngram or edge ngram based analyzers.


(system) #5