# Searching for strings by substring

**URL:** <https://discuss.elastic.co/t/searching-for-strings-by-substring/61596>\
**Category:** Elasticsearch\
**Created:** [September 27, 2016, 10:57am UTC](https://discuss.elastic.co/t/searching-for-strings-by-substring/61596 "2016-09-27T10:57:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavlo/32/12176_2.png) [@Pavlo](https://discuss.elastic.co/u/Pavlo)\
**Post date:** [September 27, 2016, 10:57am UTC](https://discuss.elastic.co/t/searching-for-strings-by-substring/61596/1 "2016-09-27T10:57:03Z")

</div>

I am looking for way to search all possible substrings in index for the word specified in query. This task comes from searching locations that I want to encode in the following way: "USCACity1Zip1". I suppose that string search must work faster than locations.  
I want to find the following matching result strings in indes: "USCACity1Zip1", "USCACity1", "USCA", "USCA", when the following value is specified in query: "USCACity1Zip1".  
Wildcard Query or match with type:"phrase\_prefix" does not work in this case, because arguments are in oposit direction.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [September 27, 2016, 2:42pm UTC](https://discuss.elastic.co/t/searching-for-strings-by-substring/61596/2 "2016-09-27T14:42:29Z")

</div>

It seems to me that making it a generic string issue makes the problem more complicated, wouldn't you be able to generate a query looking like `USCACity1Zip1 OR USCACity1 OR USCA` on the client side?

---

<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:** [July 5, 2017, 10:16pm UTC](https://discuss.elastic.co/t/searching-for-strings-by-substring/61596/3 "2017-07-05T22:16:56Z")

</div>


