# Correct elasticsearch for google like query

**URL:** <https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680>\
**Category:** Elasticsearch\
**Created:** [September 2, 2019, 11:34am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680 "2019-09-02T11:34:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pd\_tester](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@pd\_tester](https://discuss.elastic.co/u/pd_tester)\
**Post date:** [September 2, 2019, 11:34am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/1 "2019-09-02T11:34:14Z")

</div>

Hi,

Can I ask your recommendation on what query should I use for google-like search on documents. Also I need support for special characters. Whenever we use or if special characters are included, our query doesn't return expected results. Also we are querying across multiple fields (text & keyword field mapping)

Thank you for accommodating my question.

---

<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 2, 2019, 1:10pm UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/2 "2019-09-02T13:10:45Z")

</div>

hey,

can you be more specific what a google like search is? Do you have some examples including the expected behaviour? A google like search can be interpreted very differently by different people.

Also, please include examples if a search is not working as expected along with documents being indexed, otherwise helping will be really hard.

Last but not least, if you expect some more out of the box features, you might want to take a look at [App Search](https://www.elastic.co/products/app-search) - which you can also run for free or use a hosted solution.

---

<div class="post-metadata">

**Author:** ![pd\_tester](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@pd\_tester](https://discuss.elastic.co/u/pd_tester)\
**Post date:** [September 2, 2019, 1:23pm UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/3 "2019-09-02T13:23:26Z")

</div>

Hello Alexander,

Google like search for me is for example i have these data,

Doc 1 = "sample@gmail.com"  
Doc 2 ="test#424235.2525"  
Doc 3 ="account-143441-jkgljds"

if i search @gmail i expect to return doc 1  
if i search 5.25 expectation is to return doc 2  
if i t-143 expectation is to return doc 3

---

<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 2, 2019, 1:42pm UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/4 "2019-09-02T13:42:56Z")

</div>

Hey,

so just in those three requests there a ton of requirements are hidden. I.e. partial matching and splitting on certain characters.

I highly encourage you to the definitive guide and its chapter `Search in depth`, despite being a bit older it's still a great resource about the fundamentals of search.

See [https://www.elastic.co/guide/en/elasticsearch/guide/master/search-in-depth.html](https://www.elastic.co/guide/en/elasticsearch/guide/master/search-in-depth.html)

Another good resource is the analyze API to understand how a term is stored in the inverted index in order to understand what is actually searched for. See [https://www.elastic.co/guide/en/elasticsearch/reference/7.3/indices-analyze.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/indices-analyze.html)

hope this helps as a start!

--Alex

---

<div class="post-metadata">

**Author:** ![jmorph99](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmorph99/32/53466_2.png) [@jmorph99](https://discuss.elastic.co/u/jmorph99)\
**Post date:** [September 3, 2019, 3:52am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/5 "2019-09-03T03:52:12Z")

</div>

You would need to create you own analyzer using the ngram tokenizer for that.

---

<div class="post-metadata">

**Author:** ![pd\_tester](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@pd\_tester](https://discuss.elastic.co/u/pd_tester)\
**Post date:** [September 3, 2019, 5:21am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/6 "2019-09-03T05:21:09Z")

</div>

> [@jmorph99](#):
>
> wn analyzer using

This is a good help for me to start of with. Thank you.

---

<div class="post-metadata">

**Author:** ![pd\_tester](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@pd\_tester](https://discuss.elastic.co/u/pd_tester)\
**Post date:** [September 3, 2019, 5:21am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/7 "2019-09-03T05:21:50Z")

</div>

Thank you so much for your help. Will look into this one. This is a great help for me.

---

<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 1, 2019, 5:21am UTC](https://discuss.elastic.co/t/correct-elasticsearch-for-google-like-query/197680/8 "2019-10-01T05:21:56Z")

</div>

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