SELECT * FROM TABLE WHERE COL LIKE '%abc%'


(Son Phan) #1

Hi experts,

I'm working on one project which is using Elasticsearch as search engine. For simple case: I need to implement the query that is the same with LIKE '%abc%' which abc is input value. I tried to use wildcard but It's not case insensitive.

Could you please help me to resolve this problem.

Thank you so much!


(David Pilato) #2

You can change your mapping and try to play with ngrams may be.
It will consume much more space on disk but might be more accurate and more efficient.

If you read the doc about wildcard:

Note that this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.

I'd recommend reading https://www.elastic.co/guide/en/elasticsearch/guide/2.x/partial-matching.html


(Son Phan) #3

Thank you so much


(Son Phan) #4

Hi,

I have one question: How could i do if i want to search substring?

Thank you so much!


(David Pilato) #5

Ngram instead of edge ngram


(Son Phan) #6

But Ngram is used only for word. Is that correct?

Because I got the issue:
I have text: "The Timeline: 1984 Comeback"
And I could not find the document with input: Timeline


(David Pilato) #7

It depends on token_chars but by default, no the string won't be split.

See https://www.elastic.co/guide/en/elasticsearch/reference/5.1/analysis-ngram-tokenizer.html


(system) #8

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.