How can i reduce amount of segments

i have the index of the documents that is constantly updated. The perfomance of the queries i'm running, are depending from amount segment. I can cron merging. I can set merge policy figures to minimum values like 2, but there are still too many segments and queries are still slow.

How many indices/shards/segments/docs do you have?

1 index 6 shards(and 1 replica) 10M docs

And how many segments do you have per shard?

with lowest params (segmentsPerTier = 2) it is ~ 20 segments per shard after indexing all docs. without this settings it was even more

20 segments per shard should be totally fine... I don't think you can have less without killing your index/update rate. I suspect you are running costly multi-term queries like wildcard, fuzzy, range or prefix queries?

i run, more like this. and with multiple segments it is 3x slower than with one. Should i cron merge with number of segment=1. also update rate is not high it is like 2 docs per sec avg, but actually updates not that frequent. so i can have lower indexing/updating speed.

Not unless your indices are static. Otherwise every optimize call will rewrite the entire index, which would incur a lot of I/O.

Hmm this is the first time I hear about this. Out of curiosity could you try to share the output of the nodes hot threads API while you have some MLT queries running in a loop?

what if i set another value for number of segments of the force merge? will it rewrite entire index of just segments that will be merged? By the way it is some testing results not actual production. Regarding hot threads i need to reindex all docs to have more segments cause now i have only one segment per shard (after force merge).

I/O activity will be a little lighter but this might still aften rewrite significant parts of the index.

and can it cause any problems?

Yes. This I/O that is required for merging will compete with search operations, and your disks will have shorter lives.

but if it will speed up my queries the rest of the time, it works for me. if force_merge will take much less time than time interval i have to run it to keep suitable amount of segments.

hot threads for 1 segment per shard
::: {my-es-1}{PF1j_1AKS-apK6WHe9g7Tw}{}{my-es-1/}
Hot threads at 2016-04-11T16:55:09.817Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

14.0% (69.8ms out of 500ms) cpu usage by thread 'elasticsearch[es-1][search][T#25]'
6/10 snapshots sharing following 2 elements

13.7% (68.7ms out of 500ms) cpu usage by thread 'elasticsearch[es-1][search][T#10]'
2/10 snapshots sharing following 34 elements Method)$NIOFSIndexInput.readInternal(
7/10 snapshots sharing following 10 elements
sun.misc.Unsafe.park(Native Method)

10.2% (51.2ms out of 500ms) cpu usage by thread 'elasticsearch[es-1][search][T#21]'
3/10 snapshots sharing following 2 elements

what should i see on hot_threads? sometimes there is no thread in response at all.and some times it contains the following