Query multiple fields with and

Hello back again!
Last time I wrote queries is about 3 years ago, so I am not sure wether something changed for my case ,-)

I have multiple fields in my Index, like MPN (manufacturernumber), manufacturer, title, description,....

So if somebody searches for "Apple iPod 123" I want to search for "apple" + "ipod" + "123" in all fields.
Long times ago i did it with a script splitting the search and searched for "apple" must be in one of all fields, "ipod" must be in one of all fields, "123" must be in one of all fields.

So my question is, wether it is possible to simple search for "apple ipod 123" without splitting it in a script before sending it to ES? My problem was, thar all 3 parts are scattered in many fields.

THANKS a lot!

You can use a multi-match query I believe and also the ^ or boosting to give more weight to specific fields. This seems like it can work for you as long as you know what fields to query and they don't dynamically change.

Thanks, this looks great!!!
Perhaps I have to query two times.... one first query and after that a query with some time of fuzzy, synonyms and something like that.
Or is it possible to combine this multi_query with synonyms and fuzzy?
THANKS in advance!

Most of these queries found in the reference above you can use fuzziness and analyzers. Think you might be referring to cross fields and that is one that you can't use fuzziness with.

I would just start testing these queries and adjusting the parameters to see if they give you the results you are looking for.

hm, perhaps I am to stupid, or dont find the right solution :wink:

Search for: "sony man"

For the sake of simplicity I have only the fields:
title, title.ngram with different analyzer and whitespace tokenizer.
I added "sony walkman" to Index.

Query "multi_match" with "and" doesnt return results, because it searches for sony+ walkman in title.ngram or in title

My only solution at the moment is to split search by Input script before the ES-query, so i can query:

"sony" must be in title or title.ngram
and
"man" must be in title or title.ngram

Its no problem, but if I will extend it to more fields my query would be very very long.....

THANKS in advance and sorry for my bad english :wink:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.