# "No Added Sugar" and "Added Sugar" term match

**URL:** <https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730>\
**Category:** Elasticsearch\
**Created:** [March 18, 2021, 11:26pm UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730 "2021-03-18T23:26:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan88](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alan88/32/85777_2.png) [@Alan88](https://discuss.elastic.co/u/Alan88)\
**Post date:** [March 18, 2021, 11:26pm UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730/1 "2021-03-18T23:26:18Z")

</div>

I'm looking for a way to tell elasticsearch that "no added sugar" and "added sugar" are separate phrases and should be indexed accordingly. I do not want them to conflate or conflict with each other.

Docs example:  
"Cola No Added Sugar"  
"Pepsi Added Sugar"

At the moment, when I search "added sugar", I get results that include "no added sugar". I've looked at various ways to acheive this including synomyms but I'm struggling.

How would I go about achieving this? Any advice is much appreciated.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 18, 2021, 11:41pm UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730/2 "2021-03-18T23:41:51Z")

</div>

How do you search?  
What is your index looking like?  
Mapping?  
More details, please.

---

<div class="post-metadata">

**Author:** ![Alan88](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alan88/32/85777_2.png) [@Alan88](https://discuss.elastic.co/u/Alan88)\
**Post date:** [March 19, 2021, 10:15am UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730/3 "2021-03-19T10:15:12Z")

</div>

Thank you for your reply. My mappings setup is pretty basic as follows:

```auto
  "mappings": {
    "properties": {
      "product_sku": {
        "type": "keyword"
      },
      "product_name": {
      	 "type": "text"
      }
    }
  }

```

I've indexed circa 10k products. With regards to search, I'm performing a "match" on the field "product\_name" with a "minimum\_should\_match" of 50%.

The search works fine and most products show up quite accurately.

The issue is with 2-3 word phrases that elastic mismatches. For example:

- "Added Sugar" should NOT show products with "No Added Sugar"
- "Low Fat" should NOT show products with "Reduced Fat"

I hope the above helps give you a better idea what I'm trying to achieve.

Thanks

Alan

---

<div class="post-metadata">

**Author:** ![Abbass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abbass/32/85817_2.png) [@Abbass](https://discuss.elastic.co/u/Abbass)\
**Post date:** [March 19, 2021, 3:17pm UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730/4 "2021-03-19T15:17:01Z")

</div>

@Alan88 If you want to match your "product\_name" as a keyword (exact match), then you must index it as "keyword" in your mapping and use [Term query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html) instead of Match query.

A match query behaves depending one the Analyzer/Tokenizer being in action. "Sugar" will match "Cola No Added Sugar" in your example.

---

<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:** [April 16, 2021, 3:17pm UTC](https://discuss.elastic.co/t/no-added-sugar-and-added-sugar-term-match/267730/5 "2021-04-16T15:17:23Z")

</div>

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