A
A
Andrey2019-11-22 12:32:39
elasticsearch
Andrey, 2019-11-22 12:32:39

How to search in ElasticSearch only when all words match?

I have a product catalog. Elastic stores all attributes and description. When I search for a phrase, I only want to see products that match all of the attributes. For example now, when I search for "black jacket xxl", in addition to a complete match, I also get those who have "black jacket", "black xxl" and the like. I'm looking for a design like this:

'match' => [
  'message' => [
    'query'    => 'black jacket xxl',
    'operator' => 'and'
  ]
]

And yes, "black jacket xxl" is essentially a 3 field search - color, type and size.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question