To search for multiple data streams and indexes, add them as comma-separated values to the search API’s request path.

The following request searches for indexes my-index-000001 and My-index-000002.

GET /my-index-000001,my-index-000002/_search
{
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}
Copy the code

You can also search multiple data streams and indexes using index patterns.

The following request is for the my-index-* index mode. This request searches all data streams or indexes in the cluster starting with my-index-.

GET /my-index-*/_search
{
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}
Copy the code

To search for all data flows and indexes in the cluster, omit the target from the request path. Or you can use _all or *.

The following request is equivalent and searches all data flows and indexes in the cluster.

GET /_search
{
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}

GET /_all/_search
{
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}

GET /*/_search
{
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}
Copy the code

Index boost

When searching for multiple indexes, you can use the indexs_Boost parameter to improve the results of one or more specified indexes. This is useful when matches from some indexes are more important than those from others.

NOTE: You cannot use Indexs_Boost for data streams.

GET /_search {"indices_boost": [{"my-index-000001": 1.4}, {"my-index-000002": 1.3}]}Copy the code

Index aliases and index schemas can also be used:

GET / _search {" indices_boost ": [{" my - alias", 1.4}, {" my - index * ": 1.3}]}Copy the code

If more than one match is found, the first match is used. For example, if alias1 contains indexes and matches the my-index* pattern, the 1.4 boost is applied.

See the website: www.elastic.co/guide/en/el…