# How can I search for word parts with operator AND

**URL:** <https://discuss.elastic.co/t/how-can-i-search-for-word-parts-with-operator-and/249342>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [September 21, 2020, 11:09am UTC](https://discuss.elastic.co/t/how-can-i-search-for-word-parts-with-operator-and/249342 "2020-09-21T11:09:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martind/32/95675_2.png) [@MartinD](https://discuss.elastic.co/u/MartinD)\
**Post date:** [September 21, 2020, 11:09am UTC](https://discuss.elastic.co/t/how-can-i-search-for-word-parts-with-operator-and/249342/1 "2020-09-21T11:09:36Z")

</div>

I have a field in my index which is using hyphenation decompounder for german.

When I index a document with the value "Anfrage-7078437-991506 (1).P93" this leads to the tokens "Anfrage", "frage", "7078437", "991506", "1" and "P93".

A search with MatchQuery for "Preisanfrage" and the operator AND has this document as result.  
"Preisanfrage" leads to the tokens "Preisanfrage" and "frage".

My question is: Why isn't AND used and only a document with "Preisanfrage" and "frage" is returned?  
Or is there something I can do to get this result.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 21, 2020, 11:46am UTC](https://discuss.elastic.co/t/how-can-i-search-for-word-parts-with-operator-and/249342/2 "2020-09-21T11:46:26Z")

</div>

So, the reason for this is, that a single input term `Preisanfrage` generates more than one output term `Preisanfrage & frage` and those will be combined with an or (as it would be confusing if an additional generated term during analysis would lead to a document not being returned at all, despite being an exact match for the term that was typed in).

The operator `AND` refers to the case when two input terms are send in the search request like `spam eggs` - then this will become a `spam AND eggs` query, regardless to what a single term expands to after analysis.

Hope that helps to understand. the issue.

---

<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:** [October 19, 2020, 11:46am UTC](https://discuss.elastic.co/t/how-can-i-search-for-word-parts-with-operator-and/249342/3 "2020-10-19T11:46:32Z")

</div>

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