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

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!

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 Partial Matching | Elasticsearch: The Definitive Guide [2.x] | Elastic

Thank you so much

Hi,

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

Thank you so much!

Ngram instead of edge ngram

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

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

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