-1

i am very new to the Elastic search. Like to know how to search partial multi word search. \

for ex : My document { "title":"harry porter" } i need this document with search with following string 1.)har por same as sql query (select * from books where title like '%har%' or title like '%por%')

  • Be aware that Elasticsearch is nothing like others databases, not only because it's NoSql, but also because it is mainly a search engine. I suggest that you get familiar with Elasticsearch's core concepts ([this](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/intro.html)) before starting to use it: Elasticsearch is designed for full text search which is similar but in many ways more powerful than what you are asking here – Mario Trucco May 07 '17 at 07:21
  • Its one of my search use case. any way i got a solution using 'ngram ' – Gibs mds May 15 '17 at 06:28

2 Answers2

0

Using a completion suggester will provide most of the feature you want. It will find words starting with an arbitrary string, like "har" or "por".

Check out this question for a full example on how to set up a completion suggester.

As described in the documentation, you can achieve multi-word search (i.e. returning "harry horter" from a search for "por") by creating your analyzer with the option preserve_position_increments set to false

PUT books
{
    "mappings": {
        "book" : {
            "properties" : {
                "suggest" : {
                    "type" : "completion",
                    "preserve_position_increments": false
                },
                "title" : {
                    "type": "keyword"
                }
            }
        }
    }
}
Community
  • 1
  • 1
Aurélien Gasser
  • 3,043
  • 1
  • 20
  • 25
0

Refer to this : Edge NGram Tokenizer

This helps in partial multi-word search (similar to autocomplete suggestions). Hope this helps!

Partha
  • 310
  • 3
  • 17