Answer the question
In order to leave comments, you need to log in
How to do precise and non-precise searches in Elasticsearch?
At the moment there is such a request:
$response = $client->search([
'index' => 'shop',
'type' => 'products',
'body' => [
'_source' => ['id'],
'query' => [
'bool' => [
'must' => [
'multi_match' => [
'query' => $text,
'fuzziness' => 'auto',
'operator' => 'and',
'fields' => ['name', 'description']
]
]
]
]
]
]);
Answer the question
In order to leave comments, you need to log in
it is better to use query_string and the $text string to tokenize before that, removing stop words, making a query like word1 AND word2 AND word3 and so on. Can be copied with match_phrase. It is also not clear what kind of mapping you have, how tokenization occurs inside the elastic to search by the basis of the word (to find options with different endings, for example, BUCKETS, on request BUCKET). To search by exact match, if the article field has a numeric form or keyword, then you can use term, if the type is text, then use match, while the analyzer should not change the value of the field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question