Sameera De Silva
3 min readAug 4, 2021

Esrally search in multiple indexes simultaneously by executing multiple search quires simultaneously.

Imagine a situation where that you wanna perform a multiple search queries simultaneously in multiple indices.

So the multiple search queries are running on all the indexes in the ElasticSearch.

{
"version": 2,
"description": "Tutorial benchmark for Rally Search",
"indices": [
{
"name": "geocustom",
"types": [
"docs"
]
},
{
"name": "customrecords",
"types": [
"docs"
]
},
{
"name": "banks",
"types": [
"docs"
]
}
],
"schedule": [
{
"parallel": {
"clients": 4,
"warmup-iterations": 1000,
"iterations": 4000,
"tasks": [
{
"operation": {
"name": "01-term-search",
"index": "_all",
"operation-type": "search",
"body": {
"query": {
"term": {
"key_architecture": "RODSozpcCCyoYXIUPIsAVfnoubWyYNcMFpWtbQkXxUxEeiNGKa"
}
}
}
}
},
{
"operation": {
"index": "_all",
"name": "02-match-all-query",
"operation-type": "search",
"body": {
"query": {
"match_all": {}
}
}
}
},
{
"operation": {
"name": "03-past-sixtymins-query",
"index": "_all",
"operation-type": "search",
"body": {
"query": {
"bool": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-90d",
"lte": "now"
}
}
}
}
}
}
}
},
{
"operation": {
"name": "04-must-query-with-time-filter",
"index": "_all",
"operation-type": "search",
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"description.keyword": "desccrption 1034"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-90d",
"lte": "now"
}
}
}
]
}
}
}
}
},
{
"operation": {
"name": "05-String-query AND",
"index": "_all",
"operation-type": "search",
"body": {
"query": {
"query_string": {
"default_field": "key1",
"query": "sNYhzYdjkwjeVVunliSVMwxpaJAoDbpf",
"default_operator": "AND"
}
}
}
}
},
{
"operation": {
"name": "06-String-query-OR",
"index": "_all",
"operation-type": "search",
"body": {
"query": {
"query_string": {
"default_field": "key1",
"query": "700 701",
"default_operator": "OR"
}
}
}
}
}
]
}
}
]
}

Since I gave “index”: “_all” , it searches in all the indices. This is not what I want I want to run only on the indexes which I mentioned only.

So I created 3 indexes like below. pref-index-01,pref-index-02 and pref-index-03

PUT /pref-index-01
{
“settings”: {
“number_of_shards”: 1,
“number_of_replicas”: 1,
“index.requests.cache.enable”: false
}
}

“index.requests.cache.enable”: false means cache is disabled.

Also just gave one index , and this time I gave the index pattern so it matches all the three indices.
“name”: “pref-index-*”,

Full track.json is given below.

{
"version": 2,
"description": "Tutorial benchmark for Rally Search",
"indices": [
{
"name": "pref-index-*",
"types": [
"docs"
]
}
],
"schedule": [
{
"parallel": {
"clients": 4,
"warmup-iterations": 1000,
"iterations": 40000,
"tasks": [
{
"operation": {
"name": "01-term-search",
"operation-type": "search",
"body": {
"query": {
"term": {
"key_architecture": "RODSozpcCCyoYXIUPIsAVfnoubWyYNcMFpWtbQkXxUxEeiNGKa"
}
}
}
}
},
{
"operation": {
"name": "02-match-all-query",
"operation-type": "search",
"body": {
"query": {
"match_all": {}
}
}
}
},
{
"operation": {
"name": "03-size-limit--match-all-query",
"operation-type": "search",
"size": 100,
"body": {
"query": {
"match_all": {}
}
}
}
},
{
"operation": {
"name": "04-past-sixtymins-query",
"operation-type": "search",
"body": {
"query": {
"bool": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-90d",
"lte": "now"
}
}
}
}
}
}
}
},
{
"operation": {
"name": "05-must-query-with-time-filter",
"operation-type": "search",
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"description.keyword": "desccrption 1034"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-90d",
"lte": "now"
}
}
}
]
}
}
}
}
},
{
"operation": {
"name": "06-String-query AND",
"operation-type": "search",
"body": {
"query": {
"query_string": {
"default_field": "key1",
"query": "sNYhzYdjkwjeVVunliSVMwxpaJAoDbpf",
"default_operator": "AND"
}
}
}
}
},
{
"operation": {
"name": "07-String-query-OR",
"operation-type": "search",
"body": {
"query": {
"query_string": {
"default_field": "key1",
"query": "700 701",
"default_operator": "OR"
}
}
}
}
}
]
}
}
]
}

It’s searches on the all the 3 indices that I mentioned

Source-https://discuss.elastic.co/t/esrally-when-gave-index-all-it-executes-search-queries-on-all-the-indices-instead-of-search-only-the-defined-indices/280207

https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html

No responses yet