Fuzzy Query

More info about fuzzy query is in the official elasticsearch docs

The fuzzy query uses similarity based on Levenshtein edit distance for string fields, and a +/- margin on numeric and date fields.

Simple example

{
    "fuzzy" : { "user" : "ki" }
}

In DSL:

$fuzzyQuery = new FuzzyQuery('user', 'ki');

$search = new Search();
$search->addQuery($fuzzyQuery);

$queryArray = $search->toArray();

With more advanced settings

{
    "fuzzy" : {
        "user" : {
            "value" :         "ki",
            "boost" :         1.0,
            "fuzziness" :     2,
            "prefix_length" : 0,
            "max_expansions": 100
        }
    }
}

In DSL

$fuzzyQuery = new FuzzyQuery(
    'user',
    'ki',
    [
        'boost' => 1,
        'fuzziness' => 2,
        'prefix_length' => 0,
        'max_expansions' => 100,
    ]
);


$search = new Search();
$search->addQuery($fuzzyQuery);

$queryArray = $search->toArray();