Skip to content
Snippets Groups Projects
Commit 20848d28 authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add fuzzy query doc.

parent e33ec3b1
No related branches found
No related tags found
No related merge requests found
# Fuzzy Query
> More info about fuzzy query is in the [official elasticsearch docs][1]
The fuzzy query uses similarity based on Levenshtein edit distance for string fields, and a +/- margin on numeric and
date fields.
## Simple example
```JSON
{
"fuzzy" : { "user" : "ki" }
}
```
In DSL:
```php
$fuzzyQuery = new FuzzyQuery('user', 'ki');
$search = new Search();
$search->addQuery($fuzzyQuery);
$queryArray = $search->toArray();
```
## With more advanced settings
```JSON
{
"fuzzy" : {
"user" : {
"value" : "ki",
"boost" : 1.0,
"fuzziness" : 2,
"prefix_length" : 0,
"max_expansions": 100
}
}
}
```
In DSL
```php
$fuzzyQuery = new FuzzyQuery(
'user',
'ki',
[
'boost' => 1,
'fuzziness' => 2,
'prefix_length' => 0,
'max_expansions' => 100,
]
);
$search = new Search();
$search->addQuery($fuzzyQuery);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment