# Search term vs Product Category mapping

**URL:** https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220
**Category:** Elastic Search
**Tags:** elastic-site-search
**Created:** [March 27, 2024, 5:28am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220 "2024-03-27T05:28:21Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Mohandass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohandass/32/130808_2.png) [@Mohandass](https://discuss.elastic.co/u/Mohandass)
#### Post date: [March 27, 2024, 5:28am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/1 "2024-03-27T05:28:21Z")

</div>

We are implementing Site search using Elastic Search standalone version.  
We need to know how can we direct a search term to a category and list products from that category  
\*\*For example : \*\* Search term is "wash basin tap"

1. Should match **wash basin tap & basin tap** in documents
2. Should **not** match \*\*wash basin, washbasin alone \*\* in documents
3. As wash basin taps type products are mapped under **Faucets, Long Bib Taps, Automatic Wash Taps** , Need to show products from these categories- How to pull based on "wash basin tap" category ?

Thank & Appreciate all your support & help !

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 27, 2024, 8:36am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/2 "2024-03-27T08:36:48Z")

</div>

If you need all of the queried terms to match, have a look at the [terms set query](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/query-dsl-terms-set-query.html).

---

<div class="post-metadata">

### Author: ![Mohandass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohandass/32/130808_2.png) [@Mohandass](https://discuss.elastic.co/u/Mohandass)
#### Post date: [March 27, 2024, 8:43am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/3 "2024-03-27T08:43:56Z")

</div>

Thanks @Christian_Dahlqvist, But my concern is how can i route my search term to a category  
Can i have some custom analyser to do this or any other mapping text file ?

Kindly suggest, Thanks !

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 27, 2024, 8:46am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/4 "2024-03-27T08:46:16Z")

</div>

For that part I suspect you will need to use 2 separate queries. First get matching items and then other documents that match the categories retrieved.

---

<div class="post-metadata">

### Author: ![Mohandass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohandass/32/130808_2.png) [@Mohandass](https://discuss.elastic.co/u/Mohandass)
#### Post date: [March 27, 2024, 9:56am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/5 "2024-03-27T09:56:13Z")

</div>

Is any default mapping feature available in ES for this ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 27, 2024, 10:24am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/6 "2024-03-27T10:24:59Z")

</div>

> [@Mohandass](#):
>
> Is any default mapping feature available in ES for this ?

I am not sure that I understand what you mean. It sounds to me like you want to enrich the initial results based on the data retrieved in the search. This will require 2 separate searches as Elasticsearch does not support joins or subqueries.

---

<div class="post-metadata">

### Author: ![Mohandass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohandass/32/130808_2.png) [@Mohandass](https://discuss.elastic.co/u/Mohandass)
#### Post date: [March 27, 2024, 10:58am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/7 "2024-03-27T10:58:34Z")

</div>

Hi @Christian_Dahlqvist,

If i search for **"wash basin taps"** , I need to add **Faucets, Long Bib Taps, Automatic Wash Taps** categories to my search query against category filed to match & get results.

For this, how can i do a mapping between **search terms vs categories**. Can it be done via custom analyser or any painless function ? - Just a wild guess, correct me if i am wrong !

Thanks !

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 27, 2024, 11:07am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/8 "2024-03-27T11:07:43Z")

</div>

I was assuming you perform the search for **"wash basin taps"** and then extract categories from the results and run a second query to retrieve results matching these categories. Is this not logically what you are looking to do? If you do not get categories from the initial search result, how do you determine them?

If this logically is what you are looking for, I do not see any way of doing that with a single query.

---

<div class="post-metadata">

### Author: ![Mohandass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohandass/32/130808_2.png) [@Mohandass](https://discuss.elastic.co/u/Mohandass)
#### Post date: [March 27, 2024, 11:31am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/9 "2024-03-27T11:31:38Z")

</div>

Actually search alone is not giving relevant matches, because different names are present like **faucets, handbowl bip tap, long bip taps**. Also i should **not** match **"washbasin or wash basin"**. So i was looking an approach where with some kind of a mapping if i get a list of closest categories, I can do it in a single shot !

Even if i want to do it in 2nd query, the matching may not yield all the categories from 1st query.

**FYI:** We are searching through fields like Title, Keywords and 3 level categories mainly in ES query. We have a field which stores possible keywords to define this product.

---

<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 24, 2024, 11:32am UTC](https://discuss.elastic.co/t/search-term-vs-product-category-mapping/356220/10 "2024-04-24T11:32:08Z")

</div>

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