Understanding cross_fields and "AND" operator

I'm honing on a default search query for a client's commerce site. It's looking like a cross_fields multi_match with "AND" operator is producing the most relevant results (at least to me, in testing).

However, I am trying to understand why some "AND" queries don't match. For example, I want customer to be able to enter their name and the product they wish to order like "brennan shot glass". "shot" and "glass" will match on name, and "brennan" will match on options_description (a list of names).

since cross_fields treats queried fields as "one big field", and I took care to index all the queried fields with the same analyzer...I cannot figure out for the life of my why this query returns no results:

curl -XGET 'http://localhost:9200/shop/_search?&pretty=1&size=18' -d ' { "query" : { "multi_match" : { "operator" : "and", "fields" : [ "name", "search_words", "description", "skuid", "backend_skuid", "options_descriptions" ], "query" : "brennan shot glass", "type" : "cross_fields" } } } '

the document that I want to match appears to have all the goods:

"name" : "Personalized Shot Glass", "options_descriptions" : "Name Boyle Brady Brennan Burke Byrne Callahan Carroll Casey Clarke Collins Connolly Cullen Daly Doherty Donnelly Donovan Doyle Duffy Dunne Farrell Fitzgerald Fitzpatrick Flanagan Flynn Foley Gallagher Griffin Hayes Healy Higgins Hogan Kavnaugh Kelly Kennedy Lynch Maguire Mahony Maloney Martin McCarthy McDermott McGrath McMahon Moore Moran Murphy Murray NolanO'Brien O'Connell O'Connor O'Donnell O'Leary O'Mara O'Neill O'Reilly O'Shea O'Sullivan Power Quinn(Clare) Regan Shanahan Sweeney Walsh"

(I ran those strings thru the analyzer and the outputted tokens appear all correct to me..."brennan", "shot" and "glass" are all tokens)

I changed the operator to "OR" and that document does get returned, but along with many other less relevant items like "glass nightlight". Which is why I don't really want to use "OR" in general.

( also can't figure out how to preformat text on this forum, I am pasting the code between backticks but it's still showing up weird!)

1 Like

I have the same issue, but my field's with different analyzers.

The query goes right. To use operator and for @tokens@ in multi_match you must choose query string.