I am currently tuning elasticsearch for search api. The specification are:
- 2 Nodes single cluster with single index on a VM (2 cores 2GB of RAM)
- 5 shards
- 1 replication
- load balanced using nginx
When I test it using Jmeter using Nginx it get throughput about ~220 req/s but when I specify the ?preference=_local it can get to ~320 req/s. That's very good performance improvement. What I want to ask is :
- What
?preference=_localactually do and how it can improve the performance of the query? - What's the tradeoff of using
?preference=_local?
Query :
{
"query": {
"multi_match": {
"query": "trump",
"type": "most_fields",
"operator": "and",
"fields": ["title", "content"]
}
},
"sort": {
"published_at": {
"order": "desc"
},
"_score": {
"order": "desc"
}
},
"from": 0,
"size": 20,
"min_score": 1
}