13. Match¶
Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.
The match query is the standard query for performing a full-text search, including options for fuzzy matching.
A sample search with Match
1<?php
2
3$elastic = new ElasticSearch();
4
5$match = $elastic->match()
6 ->index('my-index')
7 ->field([
8 'name' => [
9 'query' => 'Şêro',
10 'fuzziness' => 1
11 ]
12 ])
13 ->search();
14
15// You can merge with other features:
16
17 $match = $elastic->match()
18 ->index('my-index')
19 ->field([
20 'name' => [
21 'query' => 'Şêro',
22 'fuzziness' => 1
23 ]
24 ])
25 ->mergeWith('elastic.sort', function(){
26 return $this->field('age')
27 ->order('desc')
28 ->getMap();
29 })
30 ->mergeWith('elastic.highlight', function(){
31 return $this
32 ->content('name', '<div>', '</div>')
33 ->getMap();
34 })
35 ->search();
36
37return $match;