I wrote a patch to MultiMatch query that provides more natural andprocessing when considering multiple fields.
Consider document with fields:
- title: Something
- description: featured on their 1969 album *Abbey Roadhttp://en.wikipedia.org/wiki/Abbey_Road
- author: Beatles
Now if I take user's input and run a query to match my documents, it would
be natural to consider ether the dreaded _all field or a multi_match query
like:
multi_match:{"query":"Something Beatles", "fields":["title",
"description", "author"], "operator":"and"}
Which would get transformed into a boolean query such as:
(+title:something +title:beatles) (+description:something
+description:beatles) (+author:something +author: beatles)
There is no match for our document! From human input perspective often the
most natural way to AND multi-field search is to ensure each term is
matched somewhere across all fields such as:
+(title:something description:something author:something) +(title:beatles
description:beatles author:beatles)
My patch does exactly that and it also accounts for use of multiple
analyzers which may remove tokens from some fields (ex: The Beatles). If a
token is skipped by an analyzer it will be turned into a should requirement
on remaining fields instead of a must.
I am using facilities of match query for minimum should match as well as
fuzzy processing so a new match type felt natural.
multi_match:{"query":"Something Beatles", "fields":["title",
"description", "author"], "type":"across"}
You can see the patch
here: https://github.com/tarass/elasticsearch/commit/8f9fe6c51172f00901b42be621670dd6b2e211ee
I would like a little feedback if others find this useful and if adding it
to MultiMatch is the right approach vs writing a plugin. I will also be
adding more unit tests, but this passes with flying colors on our site.
-Taras
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.