# Search with word1 and word2 together in Elastic

**URL:** <https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014>\
**Category:** Elasticsearch\
**Created:** [April 23, 2024, 11:25am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014 "2024-04-23T11:25:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![giribabu\_sunkara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giribabu_sunkara/32/133771_2.png) [@giribabu\_sunkara](https://discuss.elastic.co/u/giribabu_sunkara)\
**Post date:** [April 23, 2024, 11:25am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014/1 "2024-04-23T11:25:18Z")

</div>

Hi,  
We have a document with words lego(word1) and starwars(word2) with the name of the product  
when I search for legostarwars as a single word, we are not getting any results. Is there a way to achieve this search?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 23, 2024, 11:57am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014/2 "2024-04-23T11:57:21Z")

</div>

Welcome!

I don't think there's an ideal answer but may be using vector search capabilities which might be able to catch this up.

Using the classic search, there are several options you could look at:

- Using synonyms: [Search with synonyms | Elasticsearch Guide [8.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-with-synonyms.html)
- Using edge n gram token filters: [Edge n-gram token filter | Elasticsearch Guide [8.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.13/analysis-edgengram-tokenfilter.html)

---

<div class="post-metadata">

**Author:** ![giribabu\_sunkara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giribabu_sunkara/32/133771_2.png) [@giribabu\_sunkara](https://discuss.elastic.co/u/giribabu_sunkara)\
**Post date:** [April 25, 2024, 5:47am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014/3 "2024-04-25T05:47:50Z")

</div>

thanks for the pointers, I have already tried with Synonyms, and it works but unfortunately that comes with some manual maintenance. Trying to see if there is any automatic way to achieve this.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 25, 2024, 6:19am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014/4 "2024-04-25T06:19:08Z")

</div>

I'm not sure there's a tokenizer which does that (indexing foo bar baz as foo, bar, baz, foobar, barbaz). The last option if none of the other options work would be to build your tokenizer.

---

<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:** [May 23, 2024, 6:19am UTC](https://discuss.elastic.co/t/search-with-word1-and-word2-together-in-elastic/358014/5 "2024-05-23T06:19:58Z")

</div>

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