Fuzzy search with space


(mr_max) #1

How can i search with space
my query:
$params = [
'index' => 'port',
'type' => 'contact',
'size' => 50,
'body' => [
'query' => [
'fuzzy' => [
'full_name' => [
'value' => $value,
"boost" => 1.0,
"fuzziness" => 1,
"prefix_length" => 0,
"max_expansions" => 100,
'operator' => 'and'
]
]
]
]
];


(Doug Turnbull) #2

You need to control analysis, either at query time or index time, to not tokenize on spaces. Lucene-based search is token first. Fuzzy queries generate wildcard and term queries to search that leverage the underlying term-base index.


(mr_max) #3

I use this variant.
$params = [
'index' => 'portal',
'type' => 'contact',
'size' => 50,
'body' => [
'query' => [
'match' => [
'full_name' => [
'query' => $value,
'operator' => 'and',
'fuzziness' => 1
]
]
]
]
];

It's ok?


(system) #4