# Es search optimizing question

**URL:** <https://discuss.elastic.co/t/es-search-optimizing-question/23712>\
**Category:** Elasticsearch\
**Created:** [May 28, 2015, 5:56pm UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712 "2015-05-28T17:56:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaydanielian](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jaydanielian](https://discuss.elastic.co/u/jaydanielian)\
**Post date:** [May 28, 2015, 5:56pm UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712/1 "2015-05-28T17:56:08Z")

</div>

I know its dangerous to get general answers when talking about performance,  
as the answer usually is "it depends". But I am going to try anyway 🙂 My  
question is as a general rule of thumb is it better to have a list of items  
in an array stored and the query only has to issue a single matching term?  
Or store a single value per document and create various terms in an array  
passing in those generated terms for the query?

My example use case is this. I am trying to find contacts by name and  
email. Emails usually fall into several common patterns (first.last@domain,  
first\_last@domain, firstinitial\_last@domain, etc), so I want to be able to  
search against all of those possible combinations in trying to find this  
contact in our index. The queries are all filter terms, no wildcard, etc.  
The fields are all not\_analyzed, so its basically an exact term match that  
I am looking for. So, I can either store the extra possible combinations in  
the document, and have the query syntax only need to pass in one term (as  
the field stored is an array). Or I can pass in the multiple combinations  
in a term array in the query syntax, and search against the single email we  
have stored in the index.

I know its never a perfect answer, but even general rule of thumb response  
from someone with deep internal knowledge of lucene/ES would be  
appreciated.

Thanks!

J

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ef1b1d61-96b6-4dcd-a658-1385aa3f380f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ef1b1d61-96b6-4dcd-a658-1385aa3f380f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![sureshadapa](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sureshadapa](https://discuss.elastic.co/u/sureshadapa)\
**Post date:** [March 3, 2016, 8:25am UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712/2 "2016-03-03T08:25:47Z")

</div>

I have data loaded in ES using logstash, and i am using elasticsearch.js in my App to query and fetch the data. I am looking for an optimum solution in which my search is quick and Data File-Size is reduced.

In the present set up search - took 647, - hits total=45806 and Data/FileSize: 14.1MB, browser download Time:6.85s, Which was originally - took 3153, - hits total=45806 and Data/FileSize: 31.9MB, browser download Time:14.77s

I have tried to optimize the JSON search request as below.I need suggestion if there is better one then Ver1.3. I guess the problem in my App is on client side with filedownload option where Data/FileSize is hugh.

Ver1.0  
GET k00125\_car/\_search  
{"query":{"filtered":{"query":{"query\_string":{"analyze\_wildcard":true,"query":"_"}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"gte":1286952143643}}}],"must\_not":[]}}}},"highlight":{"pre\_tags":["@kibana-highlighted-field@"],"post\_tags":["@/kibana-highlighted-field@"],"fields":{"_":{}},"fragment\_size":2147483647},"size":1000000,"sort":[{"focus\_tier":{"order":"desc","unmapped\_type":"boolean"}}],"aggs":{"2":{"date\_histogram":{"field":"@timestamp","interval":"1M","pre\_zone":"+05:30","pre\_zone\_adjust\_large\_interval":true,"min\_doc\_count":0,"extended\_bounds":{"min":1286952143643,"max":1444718543643}}}},"fields":["\*","\_source"],"script\_fields":{},"fielddata\_fields":["@timestamp"]}

Ver1.1  
GET k00125\_car/\_search  
{  
"query": { "match\_all": {} },  
"size":1000000,  
"\_source": ["bunit","company\_code","customer\_number","focus\_tier","name","contact\_phone","service\_address","sum\_svchrg"]  
}

Ver1.2  
GET k00125\_car/\_search  
{  
"size":1000000  
}

Ver1.3  
GET k00125\_car/\_search  
{  
"fields": ["bunit","company\_code","customer\_number","focus\_tier","name","contact\_phone","service\_address","sum\_svchrg"],  
"size":1000000

}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 3, 2016, 8:40am UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712/3 "2016-03-03T08:40:03Z")

</div>

This thread is 9 months old. Please create a new thread for your question.

---

<div class="post-metadata">

**Author:** ![sureshadapa](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sureshadapa](https://discuss.elastic.co/u/sureshadapa)\
**Post date:** [March 3, 2016, 9:13am UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712/4 "2016-03-03T09:13:39Z")

</div>

Done

> [@Search Optimization and FileDownload](https://discuss.elastic.co/t/search-optimization-and-filedownload/43347):
>
> I have data loaded in ES using logstash, and i am using elasticsearch.js in my App to query and fetch the data. I am looking for an optimum solution in which my search is quick and Data File-Size is reduced. In the present set up search - took 647, - hits total=45806 and Data/FileSize: 14.1MB, browser download Time:6.85s, Which was originally - took 3153, - hits total=45806 and Data/FileSize: 31.9MB, browser download Time:14.77s I have tried to optimize the JSON search request as below.I need …

---

<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, 11:11pm UTC](https://discuss.elastic.co/t/es-search-optimizing-question/23712/5 "2017-07-05T23:11:43Z")

</div>


