0

I want to use like query in Elasticsearch. Can anyone help me with some sample code that includes like query pattern

Have used wildcard in query but it is not working

{
    "query": {
        "bool": {
            "must": {
                "multi_match": {
                    "query": {
                        wildcard : {
                            "title": "searchquery*",
                            "description": "searchquery*"
                        }
                    }
                    "fields": ["title", "description"]
                }
            },
        }
    }
}
Airn5475
  • 2,452
  • 29
  • 51
  • This may help you https://stackoverflow.com/questions/31176000/like-search-in-elasticsearch Again, As you want to use multi-match and 'like' functionality , then quick fix is to use query_string option as given at https://stackoverflow.com/questions/16933800/elasticsearch-how-to-use-multi-match-with-wildcard Or try nGram option. – Vipul Patil Aug 02 '19 at 12:15
  • 1
    Welcome to StackOverflow. As info, this really has nothing to do with AWS, but is just an Elasticsearch question. I would suggest removing the AWS reference including the tag. – Airn5475 Aug 02 '19 at 12:28
  • This can help [elasticsearch-how-to-use-multi-match-with-wildcard](https://stackoverflow.com/questions/16933800/elasticsearch-how-to-use-multi-match-with-wildcard) – bugsb Aug 02 '19 at 14:08

1 Answers1

0

Try this out :

{
  "query": {
    "bool": {
      "must": [
         {"match_phrase": {"title":  "searchquery*"}},
         {"match_phrase": {"description":  "searchquery*"}}
      ]
    }
 }
}
harsh tibrewal
  • 785
  • 6
  • 21