# Partial phrase match

**URL:** <https://discuss.elastic.co/t/partial-phrase-match/118872>\
**Category:** Elasticsearch\
**Created:** [February 7, 2018, 3:33pm UTC](https://discuss.elastic.co/t/partial-phrase-match/118872 "2018-02-07T15:33:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pp911](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pp911](https://discuss.elastic.co/u/pp911)\
**Post date:** [February 7, 2018, 3:33pm UTC](https://discuss.elastic.co/t/partial-phrase-match/118872/1 "2018-02-07T15:33:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [February 8, 2018, 3:31am UTC](https://discuss.elastic.co/t/partial-phrase-match/118872/2 "2018-02-08T03:31:40Z")

</div>

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

> <https://stackoverflow.com/questions/48666627/query-match-pattern-tokeniser/48668463#48668463>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 8, 2018, 3:32am UTC](https://discuss.elastic.co/t/partial-phrase-match/118872/3 "2018-03-08T03:32:05Z")

</div>

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