Building an index for faster search

Hi everyone,
I have one question.
How should I build my index to reduce the time of searching?
In my case, using aggregations for distinct search really increases the time of searching.

You have not provided a lot of information, so it is hard to give anything but general advice.

Which version of Elasticsearch are you using?

Have you looked at the section in the docs around tuning for search speed?

Have you tried using profiling?

1 Like

Hi, thank you for the answer. I'm using Version 7.17.5.
I've built an index for the list of clients. This index includes 6253156 docs. Each doc has 8 fields of different types (text, long and date). I need to have a distinct result of searching clients and sort the list of distinct clients in alphabetical order. This sort must include full name sort. So, I decided to use an aggregation in my search and it looks like this:

 GET clientindex/_search
{
"size": 0,
"query" : {
"bool" : {
"should" : [
{ "term" : { "full_name" : "name surname" } }
]
}
},
"aggs": {
"distinct_full_name": {
"terms": {
"field": "full_name.keyword",
"order": {"_key": "asc"},
"size": 1000
}
}
}
}

This search gives me distinct search with docs count, but it takes too much time for searching, sorting and counting. So the question is: how can I build an index to decrease the time of searching? Or, if it'll be better to use another search, please, give some advices. Thank you!

I haven't seen the section in the docs around tuning for search speed and profiling yet. I will look for useful information for my case there, thank you a lot.

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