How to add LIKE query in Elasticsearch?

How to add LIKE query in Elasticsearch?

In this post we will give you information about How to add LIKE query in Elasticsearch?. Hear we will give you detail about How to add LIKE query in Elasticsearch?And how to use it also give you demo for it if it is necessary.

I want to use LIKE query as work on sql, i mean If using a SQL or Mysql ‘Like’ query to query data it will return data even if its only partially matched. if i search just ‘t’ then it will return all the records match ‘t’. so you can add LIKE statement by using ‘query_string’.

you can easily implement LIKE statement by using ‘query_string’, in following example you can see how to impletemt:

$search = 't';

$sql = json_decode(' {

"type": "main",

"query_cache": true,

"body": {

"size": 500,

"query": {

"query_string": {

"default_field": "name",

"query": "' . $search . ' OR *' . $search . '*",

"use_dis_max": true,

"fuzzy_max_expansions": 50,

"fuzziness": 1

}

}

}

}

');

Try this…..

Hope this code and post will helped you for implement How to add LIKE query in Elasticsearch?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

4  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US