How to add LIKE query in Elasticsearch?
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.....
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.