Partial phrase match


#1

Say we have a search query Vacuum cleaner WSP 6666 C 22 C 2 KW rubber which we want to match against our index. Of of the indexed products is:

 ...
"categories": [
    "Vacuum cleaner",
    "Blender",
],
"modelnumbers": [
    "WSP 6666 C 22 C 2 KW",
    "ABST 23",
    "2h28f7h2i3f",
]

Now I want to match on both category as modelnumber

{
  "query": {
      "function_score": {
        "query": {
          "bool": {
            "should": [
              {
                "query_string": {
                  "query": "Vacuum cleaner WSP 6666 C 22 C 2 KW rubber",
                  "default_operator": "OR",
                  "default_field": "categories",
                  "boost": "10"
                }
              },
              {
                "query_string": {
                  "query": "Vacuum cleaner WSP 6666 C 22 C 2 KW rubber",
                  "default_operator": "OR",
                  "default_field": "modelnumbers",
                  "boost": "10"
                }
              }
          }
     }
}

This shows me the correct result. However now it matches on all of the following:

  • Vacuum
  • cleaner
  • WSP
  • 666666
  • C
  • 22
  • C
  • 2
  • KW

Is there a possible way with tokenisers or another possibility which makes it possible it only finds matches?:

  • Vacuum cleaner
  • WSP 6666 C 22 C 2 KW

As you can see not all regexes have the same format, so there is no possibility to use the regex tokeniser.


(Val Crettaz) #2

I didn't see this was cross-posted, but you can find an answer here:


(system) #3

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