# Help with optimizing search queries

**URL:** <https://discuss.elastic.co/t/help-with-optimizing-search-queries/65968>\
**Category:** Elasticsearch\
**Created:** [November 14, 2016, 11:39am UTC](https://discuss.elastic.co/t/help-with-optimizing-search-queries/65968 "2016-11-14T11:39:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IdanAdar](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IdanAdar](https://discuss.elastic.co/u/IdanAdar)\
**Post date:** [November 14, 2016, 11:39am UTC](https://discuss.elastic.co/t/help-with-optimizing-search-queries/65968/1 "2016-11-14T11:39:56Z")

</div>

Hello,

We're using Elastic search in the following manner:

> <https://github.com/MobileFirst-Platform-Developer-Center/DevCenter/blob/master/js/search.js#L146>

You can experience the search live here:  
[https://mobilefirstplatform.ibmcloud.com/search/](https://mobilefirstplatform.ibmcloud.com/search/)

Example search query: "security checks"

One issue that we're experiencing is differences in search results when searching for the following:

1. "authorizationContext"
2. "authorizationContext.getActiveUser()"

As you can see, the results are not the same.  
My question here is how should I update the queries being run (see top-most link) so that they will account for both queries.

Thanks!

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [November 14, 2016, 2:34pm UTC](https://discuss.elastic.co/t/help-with-optimizing-search-queries/65968/2 "2016-11-14T14:34:02Z")

</div>

Hi @IdanAdar,

you are searching for two different terms? Why do you expect the same results? If the second query should also return the results of the first query you could - for example - configure an analyzer that produces (during **indexing** ) the two tokens "authorizationContext" and "getActiveUser" for the input text "authorizationContext.getActiveUser()".

See the [Definitive Guide](https://www.elastic.co/guide/en/elasticsearch/guide/master/custom-analyzers.html) and the [reference docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/analyzer.html) on how to achieve that.

Daniel

---

<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:** [December 12, 2016, 2:34pm UTC](https://discuss.elastic.co/t/help-with-optimizing-search-queries/65968/3 "2016-12-12T14:34:30Z")

</div>

Closed on December 12, 2016, 2:34pm UTC

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