- Elasticsearch Guide: other versions:
- Elasticsearch basics
- Quick starts
- Set up Elasticsearch
- Run Elasticsearch locally
- Installing Elasticsearch
- Configuring Elasticsearch
- Important Elasticsearch configuration
- Secure settings
- Auditing settings
- Circuit breaker settings
- Cluster-level shard allocation and routing settings
- Miscellaneous cluster settings
- Cross-cluster replication settings
- Discovery and cluster formation settings
- Data stream lifecycle settings
- Field data cache settings
- Local gateway settings
- Health Diagnostic settings
- Index lifecycle management settings
- Index management settings
- Index recovery settings
- Indexing buffer settings
- Inference settings
- License settings
- Machine learning settings
- Monitoring settings
- Node settings
- Networking
- Node query cache settings
- Path settings
- Search settings
- Security settings
- Shard request cache settings
- Snapshot and restore settings
- Transforms settings
- Thread pools
- Watcher settings
- Set JVM options
- Important system configuration
- Bootstrap Checks
- Heap size check
- File descriptor check
- Memory lock check
- Maximum number of threads check
- Max file size check
- Maximum size virtual memory check
- Maximum map count check
- Client JVM check
- Use serial collector check
- System call filter check
- OnError and OnOutOfMemoryError checks
- Early-access check
- All permission check
- Discovery configuration check
- Bootstrap Checks for X-Pack
- Starting Elasticsearch
- Stopping Elasticsearch
- Discovery and cluster formation
- Add and remove nodes in your cluster
- Full-cluster restart and rolling restart
- Remote clusters
- Plugins
- Search your data
- The search API
- Sort search results
- Paginate search results
- Retrieve selected fields
- Search multiple data streams and indices using a query
- Collapse search results
- Filter search results
- Highlighting
- Long-running searches
- Near real-time search
- Retrieve inner hits
- Search shard routing
- Searching with query rules
- Search templates
- Full-text search
- Search relevance optimizations
- Retrievers
- kNN search
- Semantic search
- Retrieval augmented generation
- Search across clusters
- Search with synonyms
- Search Applications
- Search analytics
- The search API
- Re-ranking
- Index modules
- Index templates
- Aliases
- Mapping
- Dynamic mapping
- Explicit mapping
- Runtime fields
- Field data types
- Aggregate metric
- Alias
- Arrays
- Binary
- Boolean
- Completion
- Date
- Date nanoseconds
- Dense vector
- Flattened
- Geopoint
- Geoshape
- Histogram
- IP
- Join
- Keyword
- Nested
- Numeric
- Object
- Pass-through object
- Percolator
- Point
- Range
- Rank feature
- Rank features
- Rank Vectors
- Search-as-you-type
- Semantic text
- Shape
- Sparse vector
- Text
- Token count
- Unsigned long
- Version
- Metadata fields
- Mapping parameters
analyzer
coerce
copy_to
doc_values
dynamic
eager_global_ordinals
enabled
format
ignore_above
index.mapping.ignore_above
ignore_malformed
index
index_options
index_phrases
index_prefixes
meta
fields
normalizer
norms
null_value
position_increment_gap
properties
search_analyzer
similarity
store
subobjects
term_vector
- Mapping limit settings
- Removal of mapping types
- Text analysis
- Overview
- Concepts
- Configure text analysis
- Built-in analyzer reference
- Tokenizer reference
- Token filter reference
- Apostrophe
- ASCII folding
- CJK bigram
- CJK width
- Classic
- Common grams
- Conditional
- Decimal digit
- Delimited payload
- Dictionary decompounder
- Edge n-gram
- Elision
- Fingerprint
- Flatten graph
- Hunspell
- Hyphenation decompounder
- Keep types
- Keep words
- Keyword marker
- Keyword repeat
- KStem
- Length
- Limit token count
- Lowercase
- MinHash
- Multiplexer
- N-gram
- Normalization
- Pattern capture
- Pattern replace
- Phonetic
- Porter stem
- Predicate script
- Remove duplicates
- Reverse
- Shingle
- Snowball
- Stemmer
- Stemmer override
- Stop
- Synonym
- Synonym graph
- Trim
- Truncate
- Unique
- Uppercase
- Word delimiter
- Word delimiter graph
- Character filters reference
- Normalizers
- Ingest pipelines
- Example: Parse logs
- Enrich your data
- Processor reference
- Append
- Attachment
- Bytes
- Circle
- Community ID
- Convert
- CSV
- Date
- Date index name
- Dissect
- Dot expander
- Drop
- Enrich
- Fail
- Fingerprint
- Foreach
- Geo-grid
- GeoIP
- Grok
- Gsub
- HTML strip
- Inference
- IP Location
- Join
- JSON
- KV
- Lowercase
- Network direction
- Pipeline
- Redact
- Registered domain
- Remove
- Rename
- Reroute
- Script
- Set
- Set security user
- Sort
- Split
- Terminate
- Trim
- Uppercase
- URL decode
- URI parts
- User agent
- Ingest pipelines in Search
- Connectors
- Data streams
- Data management
- ILM: Manage the index lifecycle
- Tutorial: Customize built-in policies
- Tutorial: Automate rollover
- Index management in Kibana
- Overview
- Concepts
- Index lifecycle actions
- Configure a lifecycle policy
- Migrate index allocation filters to node roles
- Troubleshooting index lifecycle management errors
- Start and stop index lifecycle management
- Manage existing indices
- Skip rollover
- Restore a managed data stream or index
- Data tiers
- Roll up or transform your data
- Query DSL
- EQL
- ES|QL
- SQL
- Overview
- Getting Started with SQL
- Conventions and Terminology
- Security
- SQL REST API
- SQL Translate API
- SQL CLI
- SQL JDBC
- SQL ODBC
- SQL Client Applications
- SQL Language
- Functions and Operators
- Comparison Operators
- Logical Operators
- Math Operators
- Cast Operators
- LIKE and RLIKE Operators
- Aggregate Functions
- Grouping Functions
- Date/Time and Interval Functions and Operators
- Full-Text Search Functions
- Mathematical Functions
- String Functions
- Type Conversion Functions
- Geo Functions
- Conditional Functions And Expressions
- System Functions
- Reserved keywords
- SQL Limitations
- Scripting
- Aggregations
- Bucket aggregations
- Adjacency matrix
- Auto-interval date histogram
- Categorize text
- Children
- Composite
- Date histogram
- Date range
- Diversified sampler
- Filter
- Filters
- Frequent item sets
- Geo-distance
- Geohash grid
- Geohex grid
- Geotile grid
- Global
- Histogram
- IP prefix
- IP range
- Missing
- Multi Terms
- Nested
- Parent
- Random sampler
- Range
- Rare terms
- Reverse nested
- Sampler
- Significant terms
- Significant text
- Terms
- Time series
- Variable width histogram
- Subtleties of bucketing range fields
- Metrics aggregations
- Pipeline aggregations
- Average bucket
- Bucket script
- Bucket count K-S test
- Bucket correlation
- Bucket selector
- Bucket sort
- Change point
- Cumulative cardinality
- Cumulative sum
- Derivative
- Extended stats bucket
- Inference bucket
- Max bucket
- Min bucket
- Moving function
- Moving percentiles
- Normalize
- Percentiles bucket
- Serial differencing
- Stats bucket
- Sum bucket
- Bucket aggregations
- Geospatial analysis
- Watcher
- Monitor a cluster
- Secure the Elastic Stack
- Elasticsearch security principles
- Start the Elastic Stack with security enabled automatically
- Manually configure security
- Updating node security certificates
- User authentication
- Built-in users
- Service accounts
- Internal users
- Token-based authentication services
- User profiles
- Realms
- Realm chains
- Security domains
- Active Directory user authentication
- File-based user authentication
- LDAP user authentication
- Native user authentication
- OpenID Connect authentication
- PKI user authentication
- SAML authentication
- Kerberos authentication
- JWT authentication
- Integrating with other authentication systems
- Enabling anonymous access
- Looking up users without authentication
- Controlling the user cache
- Configuring SAML single-sign-on on the Elastic Stack
- Configuring single sign-on to the Elastic Stack using OpenID Connect
- User authorization
- Built-in roles
- Defining roles
- Role restriction
- Security privileges
- Document level security
- Field level security
- Granting privileges for data streams and aliases
- Mapping users and groups to roles
- Setting up field and document level security
- Submitting requests on behalf of other users
- Configuring authorization delegation
- Customizing roles and authorization
- Enable audit logging
- Restricting connections with IP filtering
- Securing clients and integrations
- Operator privileges
- Troubleshooting
- Some settings are not returned via the nodes settings API
- Authorization exceptions
- Users command fails due to extra arguments
- Users are frequently locked out of Active Directory
- Certificate verification fails for curl on Mac
- SSLHandshakeException causes connections to fail
- Common SSL/TLS exceptions
- Common Kerberos exceptions
- Common SAML issues
- Internal Server Error in Kibana
- Setup-passwords command fails due to connection failure
- Failures due to relocation of the configuration files
- Limitations
- Set up a cluster for high availability
- Optimizations
- Autoscaling
- Snapshot and restore
- Cross-cluster replication
- Data store architecture
- REST APIs
- API conventions
- Common options
- REST API compatibility
- Autoscaling APIs
- Behavioral Analytics APIs
- Compact and aligned text (CAT) APIs
- cat aliases
- cat allocation
- cat anomaly detectors
- cat component templates
- cat count
- cat data frame analytics
- cat datafeeds
- cat fielddata
- cat health
- cat indices
- cat master
- cat nodeattrs
- cat nodes
- cat pending tasks
- cat plugins
- cat recovery
- cat repositories
- cat segments
- cat shards
- cat snapshots
- cat task management
- cat templates
- cat thread pool
- cat trained model
- cat transforms
- Cluster APIs
- Cluster allocation explain
- Cluster get settings
- Cluster health
- Health
- Cluster reroute
- Cluster state
- Cluster stats
- Cluster update settings
- Nodes feature usage
- Nodes hot threads
- Nodes info
- Prevalidate node removal
- Nodes reload secure settings
- Nodes stats
- Cluster Info
- Pending cluster tasks
- Remote cluster info
- Task management
- Voting configuration exclusions
- Create or update desired nodes
- Get desired nodes
- Delete desired nodes
- Get desired balance
- Reset desired balance
- Cross-cluster replication APIs
- Connector APIs
- Create connector
- Delete connector
- Get connector
- List connectors
- Update connector API key id
- Update connector configuration
- Update connector index name
- Update connector features
- Update connector filtering
- Update connector name and description
- Update connector pipeline
- Update connector scheduling
- Update connector service type
- Create connector sync job
- Cancel connector sync job
- Delete connector sync job
- Get connector sync job
- List connector sync jobs
- Check in a connector
- Update connector error
- Update connector last sync stats
- Update connector status
- Check in connector sync job
- Claim connector sync job
- Set connector sync job error
- Set connector sync job stats
- Data stream APIs
- Document APIs
- Enrich APIs
- EQL APIs
- ES|QL APIs
- Features APIs
- Fleet APIs
- Graph explore API
- Index APIs
- Alias exists
- Aliases
- Analyze
- Analyze index disk usage
- Clear cache
- Clone index
- Close index
- Create index
- Create or update alias
- Create or update component template
- Create or update index template
- Create or update index template (legacy)
- Delete component template
- Delete dangling index
- Delete alias
- Delete index
- Delete index template
- Delete index template (legacy)
- Exists
- Field usage stats
- Flush
- Force merge
- Get alias
- Get component template
- Get field mapping
- Get index
- Get index settings
- Get index template
- Get index template (legacy)
- Get mapping
- Import dangling index
- Index recovery
- Index segments
- Index shard stores
- Index stats
- Index template exists (legacy)
- List dangling indices
- Open index
- Refresh
- Resolve index
- Resolve cluster
- Advantages of using this endpoint before a cross-cluster search
- Rollover
- Shrink index
- Simulate index
- Simulate template
- Split index
- Update index settings
- Update mapping
- Index lifecycle management APIs
- Create or update lifecycle policy
- Get policy
- Delete policy
- Move to step
- Remove policy
- Retry policy
- Get index lifecycle management status
- Explain lifecycle
- Start index lifecycle management
- Stop index lifecycle management
- Migrate indices, ILM policies, and legacy, composable and component templates to data tiers routing
- Inference APIs
- Delete inference API
- Get inference API
- Perform inference API
- Chat completion inference API
- Create inference API
- Stream inference API
- Update inference API
- Elastic Inference Service (EIS)
- AlibabaCloud AI Search inference integration
- Amazon Bedrock inference integration
- Anthropic inference integration
- Azure AI studio inference integration
- Azure OpenAI inference integration
- Cohere inference integration
- Elasticsearch inference integration
- ELSER inference integration
- Google AI Studio inference integration
- Google Vertex AI inference integration
- HuggingFace inference integration
- JinaAI inference integration
- Mistral inference integration
- OpenAI inference integration
- Watsonx inference integration
- Info API
- Ingest APIs
- Licensing APIs
- Logstash APIs
- Machine learning APIs
- Machine learning anomaly detection APIs
- Add events to calendar
- Add jobs to calendar
- Close jobs
- Create jobs
- Create calendars
- Create datafeeds
- Create filters
- Delete calendars
- Delete datafeeds
- Delete events from calendar
- Delete filters
- Delete forecasts
- Delete jobs
- Delete jobs from calendar
- Delete model snapshots
- Delete expired data
- Estimate model memory
- Flush jobs
- Forecast jobs
- Get buckets
- Get calendars
- Get categories
- Get datafeeds
- Get datafeed statistics
- Get influencers
- Get jobs
- Get job statistics
- Get model snapshots
- Get model snapshot upgrade statistics
- Get overall buckets
- Get scheduled events
- Get filters
- Get records
- Open jobs
- Post data to jobs
- Preview datafeeds
- Reset jobs
- Revert model snapshots
- Start datafeeds
- Stop datafeeds
- Update datafeeds
- Update filters
- Update jobs
- Update model snapshots
- Upgrade model snapshots
- Machine learning data frame analytics APIs
- Create data frame analytics jobs
- Delete data frame analytics jobs
- Evaluate data frame analytics
- Explain data frame analytics
- Get data frame analytics jobs
- Get data frame analytics jobs stats
- Preview data frame analytics
- Start data frame analytics jobs
- Stop data frame analytics jobs
- Update data frame analytics jobs
- Machine learning trained model APIs
- Clear trained model deployment cache
- Create or update trained model aliases
- Create part of a trained model
- Create trained models
- Create trained model vocabulary
- Delete trained model aliases
- Delete trained models
- Get trained models
- Get trained models stats
- Infer trained model
- Start trained model deployment
- Stop trained model deployment
- Update trained model deployment
- Migration APIs
- Node lifecycle APIs
- Query rules APIs
- Reload search analyzers API
- Repositories metering APIs
- Rollup APIs
- Root API
- Script APIs
- Search APIs
- Search Application APIs
- Searchable snapshots APIs
- Security APIs
- Authenticate
- Change passwords
- Clear cache
- Clear roles cache
- Clear privileges cache
- Clear API key cache
- Clear service account token caches
- Create API keys
- Create or update application privileges
- Create or update role mappings
- Create or update roles
- Bulk create or update roles API
- Bulk delete roles API
- Create or update users
- Create service account tokens
- Delegate PKI authentication
- Delete application privileges
- Delete role mappings
- Delete roles
- Delete service account token
- Delete users
- Disable users
- Enable users
- Enroll Kibana
- Enroll node
- Get API key information
- Get application privileges
- Get builtin privileges
- Get role mappings
- Get roles
- Query Role
- Get service accounts
- Get service account credentials
- Get Security settings
- Get token
- Get user privileges
- Get users
- Grant API keys
- Has privileges
- Invalidate API key
- Invalidate token
- OpenID Connect prepare authentication
- OpenID Connect authenticate
- OpenID Connect logout
- Query API key information
- Query User
- Update API key
- Update Security settings
- Bulk update API keys
- SAML prepare authentication
- SAML authenticate
- SAML logout
- SAML invalidate
- SAML complete logout
- SAML service provider metadata
- SSL certificate
- Activate user profile
- Disable user profile
- Enable user profile
- Get user profiles
- Suggest user profile
- Update user profile data
- Has privileges user profile
- Create Cross-Cluster API key
- Update Cross-Cluster API key
- Snapshot and restore APIs
- Snapshot lifecycle management APIs
- SQL APIs
- Synonyms APIs
- Text structure APIs
- Transform APIs
- Usage API
- Watcher APIs
- Definitions
- Command line tools
- elasticsearch-certgen
- elasticsearch-certutil
- elasticsearch-create-enrollment-token
- elasticsearch-croneval
- elasticsearch-keystore
- elasticsearch-node
- elasticsearch-reconfigure-node
- elasticsearch-reset-password
- elasticsearch-saml-metadata
- elasticsearch-service-tokens
- elasticsearch-setup-passwords
- elasticsearch-shard
- elasticsearch-syskeygen
- elasticsearch-users
- Troubleshooting
- Fix common cluster issues
- Diagnose unassigned shards
- Add a missing tier to the system
- Allow Elasticsearch to allocate the data in the system
- Allow Elasticsearch to allocate the index
- Indices mix index allocation filters with data tiers node roles to move through data tiers
- Not enough nodes to allocate all shard replicas
- Total number of shards for an index on a single node exceeded
- Total number of shards per node has been reached
- Troubleshooting corruption
- Fix data nodes out of disk
- Fix master nodes out of disk
- Fix other role nodes out of disk
- Start index lifecycle management
- Start Snapshot Lifecycle Management
- Restore from snapshot
- Troubleshooting broken repositories
- Addressing repeated snapshot policy failures
- Troubleshooting an unstable cluster
- Troubleshooting discovery
- Troubleshooting monitoring
- Troubleshooting transforms
- Troubleshooting Watcher
- Troubleshooting searches
- Troubleshooting shards capacity health issues
- Troubleshooting an unbalanced cluster
- Capture diagnostics
- Upgrade Elasticsearch
- Migration guide
- Release notes
- Dependencies and versions
Search across clusters
editSearch across clusters
editCross-cluster search lets you run a single search request against one or more remote clusters. For example, you can use a cross-cluster search to filter and analyze log data stored on clusters in different data centers.
Supported APIs
editThe following APIs support cross-cluster search:
- Search
- Async search
- Multi search
- Search template
- Multi search template
- Field capabilities
- Painless execute API
- Resolve Index API
- [preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. EQL search
- [preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. SQL search
- [preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Vector tile search
- [preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. ES|QL
Prerequisites
edit-
Cross-cluster search requires remote clusters. To set up remote clusters on Elasticsearch Service, see configure remote clusters on Elasticsearch Service. If you run Elasticsearch on your own hardware, see Remote clusters.
To ensure your remote cluster configuration supports cross-cluster search, see Supported cross-cluster search configurations.
- For full cross-cluster search capabilities, the local and remote cluster must be on the same subscription level.
-
The local coordinating node must have the
remote_cluster_client
node role.
-
If you use sniff mode, the local coordinating node must be able to connect to seed and gateway nodes on the remote cluster.
We recommend using gateway nodes capable of serving as coordinating nodes. The seed nodes can be a subset of these gateway nodes.
-
If you use proxy mode, the local coordinating node must be able
to connect to the configured
proxy_address
. The proxy at this address must be able to route connections to gateway and coordinating nodes on the remote cluster. - Cross-cluster search requires different security privileges on the local cluster and remote cluster. See Configure privileges for cross-cluster search and Remote clusters.
Cross-cluster search examples
editRemote cluster setup
editThe following cluster update settings API request
adds three remote clusters: cluster_one
, cluster_two
, and cluster_three
.
resp = client.cluster.put_settings( persistent={ "cluster": { "remote": { "cluster_one": { "seeds": [ "35.238.149.1:9300" ], "skip_unavailable": True }, "cluster_two": { "seeds": [ "35.238.149.2:9300" ], "skip_unavailable": False }, "cluster_three": { "seeds": [ "35.238.149.3:9300" ] } } } }, ) print(resp)
response = client.cluster.put_settings( body: { persistent: { cluster: { remote: { cluster_one: { seeds: [ '35.238.149.1:9300' ], skip_unavailable: true }, cluster_two: { seeds: [ '35.238.149.2:9300' ], skip_unavailable: false }, cluster_three: { seeds: [ '35.238.149.3:9300' ] } } } } } ) puts response
const response = await client.cluster.putSettings({ persistent: { cluster: { remote: { cluster_one: { seeds: ["35.238.149.1:9300"], skip_unavailable: true, }, cluster_two: { seeds: ["35.238.149.2:9300"], skip_unavailable: false, }, cluster_three: { seeds: ["35.238.149.3:9300"], }, }, }, }, }); console.log(response);
PUT _cluster/settings { "persistent": { "cluster": { "remote": { "cluster_one": { "seeds": [ "35.238.149.1:9300" ], "skip_unavailable": true }, "cluster_two": { "seeds": [ "35.238.149.2:9300" ], "skip_unavailable": false }, "cluster_three": { "seeds": [ "35.238.149.3:9300" ] } } } } }
Since |
Search a single remote cluster
editIn the search request, you specify data streams and indices on a remote cluster
as <remote_cluster_name>:<target>
.
The following search API request searches the
my-index-000001
index on a single remote cluster, cluster_one
.
resp = client.search( index="cluster_one:my-index-000001", size=1, query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
response = client.search( index: 'cluster_one:my-index-000001', body: { size: 1, query: { match: { 'user.id' => 'kimchy' } }, _source: [ 'user.id', 'message', 'http.response.status_code' ] } ) puts response
const response = await client.search({ index: "cluster_one:my-index-000001", size: 1, query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
GET /cluster_one:my-index-000001/_search { "size": 1, "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
The API returns the following response. Note that when you
search one or more remote clusters, a _clusters
section is
included to provide information about the search on each cluster.
{ "took": 150, "timed_out": false, "_shards": { "total": 12, "successful": 12, "failed": 0, "skipped": 0 }, "_clusters": { "total": 1, "successful": 1, "skipped": 0, "running": 0, "partial": 0, "failed": 0, "details": { "cluster_one": { "status": "successful", "indices": "my-index-000001", "took": 148, "timed_out": false, "_shards": { "total": 12, "successful": 12, "skipped": 0, "failed": 0 } } } }, "hits": { "total" : { "value": 1, "relation": "eq" }, "max_score": 1, "hits": [ { "_index": "cluster_one:my-index-000001", "_id": "0", "_score": 1, "_source": { "user": { "id": "kimchy" }, "message": "GET /search HTTP/1.1 200 1070000", "http": { "response": { "status_code": 200 } } } } ] } }
This section of counters shows all possible cluster search states and how many cluster
searches are currently in that state. The clusters can be one of the following statuses: running,
successful (searches on all shards were successful), partial (searches on at least
one shard of the cluster was successful and at least one failed), skipped (the search
failed on a cluster marked with |
|
The |
|
The index expression supplied by the user. If you provide a wildcard such as |
|
How long (in milliseconds) the sub-search took on that cluster. |
|
The shard details for the sub-search on that cluster. |
|
The search response body includes the name of the remote cluster in the
|
Search multiple remote clusters
editThe following search API request searches the my-index-000001
index on
three clusters:
- The local ("querying") cluster, with 10 shards
-
Two remote clusters,
cluster_one
, with 12 shards andcluster_two
with 6 shards.
resp = client.search( index="my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
response = client.search( index: 'my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001', body: { query: { match: { 'user.id' => 'kimchy' } }, _source: [ 'user.id', 'message', 'http.response.status_code' ] } ) puts response
const response = await client.search({ index: "my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
GET /my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001/_search { "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
The API returns the following response:
{ "took": 150, "timed_out": false, "num_reduce_phases": 4, "_shards": { "total": 28, "successful": 28, "failed": 0, "skipped": 0 }, "_clusters": { "total": 3, "successful": 3, "skipped": 0, "running": 0, "partial": 0, "failed": 0, "details": { "(local)": { "status": "successful", "indices": "my-index-000001", "took": 21, "timed_out": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "successful", "indices": "my-index-000001", "took": 48, "timed_out": false, "_shards": { "total": 12, "successful": 12, "skipped": 0, "failed": 0 } }, "cluster_two": { "status": "successful", "indices": "my-index-000001", "took": 141, "timed_out": false, "_shards": { "total" : 6, "successful" : 6, "skipped": 0, "failed": 0 } } } }, "hits": { "total" : { "value": 3, "relation": "eq" }, "max_score": 1, "hits": [ { "_index": "my-index-000001", "_id": "0", "_score": 2, "_source": { "user": { "id": "kimchy" }, "message": "GET /search HTTP/1.1 200 1070000", "http": { "response": { "status_code": 200 } } } }, { "_index": "cluster_one:my-index-000001", "_id": "0", "_score": 1, "_source": { "user": { "id": "kimchy" }, "message": "GET /search HTTP/1.1 200 1070000", "http": { "response": { "status_code": 200 } } } }, { "_index": "cluster_two:my-index-000001", "_id": "0", "_score": 1, "_source": { "user": { "id": "kimchy" }, "message": "GET /search HTTP/1.1 200 1070000", "http": { "response": { "status_code": 200 } } } } ] } }
The local (querying) cluster is identified as "(local)". |
|
This document’s |
|
This document came from |
|
This document came from |
Using async search for cross-cluster search with ccs_minimize_roundtrips=true
editRemote clusters can be queried asynchronously using the async search API.
A cross-cluster search accepts a ccs_minimize_roundtrips
parameter. For
asynchronous searches it defaults to false
. (Note: for synchronous searches it defaults to true
.)
See Considerations for choosing whether to minimize roundtrips in a cross-cluster search to learn more about this option.
The following request does an asynchronous search of the my-index-000001
index using
ccs_minimize_roundtrips=true
against three clusters (same ones as the previous example).
resp = client.async_search.submit( index="my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", ccs_minimize_roundtrips=True, query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
response = client.async_search.submit( index: 'my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001', ccs_minimize_roundtrips: true, body: { query: { match: { 'user.id' => 'kimchy' } }, _source: [ 'user.id', 'message', 'http.response.status_code' ] } ) puts response
const response = await client.asyncSearch.submit({ index: "my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", ccs_minimize_roundtrips: "true", query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
POST /my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001/_async_search?ccs_minimize_roundtrips=true { "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
The API returns the following response:
{ "id": "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", "is_partial": true, "is_running": true, "start_time_in_millis": 1685563581380, "expiration_time_in_millis": 1685995581380, "response": { "took": 1020, "timed_out": false, "num_reduce_phases": 0, "_shards": { "total": 10, "successful": 0, "failed": 0, "skipped": 0 }, "_clusters": { "total" : 3, "successful" : 0, "skipped": 0, "running": 3, "partial": 0, "failed": 0, "details": { "(local)": { "status": "running", "indices": "my-index-000001", "timed_out": false }, "cluster_one": { "status": "running", "indices": "my-index-000001", "timed_out": false }, "cluster_one": { "status": "running", "indices": "my-index-000001", "timed_out": false } } }, "hits": { "total" : { "value": 0, "relation": "eq" }, "max_score": null, "hits": [] } } }
The async search id. |
|
When |
|
The |
If you query the get async search endpoint while the query is
still running, you will see an update in the _clusters
and _shards
section of
the response as each cluster finishes its search.
If you set ccs_minimize_roundtrips=false
, then you will also see partial aggregation
results from shards (from any cluster) that have finished, but no results are shown in
"hits" section until the search has completed.
If you set ccs_minimize_roundtrips=true
, then you will also see partial results
in the "hits" and "aggregations" section of the response from all clusters that have
completed so far. (Note: you can also see partial aggregation results from the local cluster
even before it finishes.) The example below shows the ccs_minimize_roundtrips=true
case.
resp = client.async_search.get( id="FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", ) print(resp)
response = client.async_search.get( id: 'FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=' ) puts response
const response = await client.asyncSearch.get({ id: "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", }); console.log(response);
GET /_async_search/FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=
Response:
{ "id": "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", "is_partial": true, "is_running": true, "start_time_in_millis": 1685564911108, "expiration_time_in_millis": 1685996911108, "response": { "took": 11164, "timed_out": false, "terminated_early": false, "_shards": { "total": 22, "successful": 22, "skipped": 0, "failed": 0 }, "_clusters": { "total": 3, "successful": 2, "skipped": 0, "running": 1, "partial": 0, "failed": 0, "details": { "(local)": { "status": "successful", "indices": "my-index-000001", "took": 2034, "timed_out": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "successful", "indices": "my-index-000001", "took": 9039, "timed_out": false, "_shards": { "total": 12, "successful": 12, "skipped": 0, "failed": 0 } }, "cluster_two": { "status": "running", "indices": "my-index-000001", "timed_out": false } } }, "hits": { "total": { "value": 542, "relation": "eq" }, "max_score": 1.7232, "hits": [...list of hits here...] } } }
Searches on all shards of the local cluster and remote |
|
Since two clusters have completed the search, the "successful" clusters entry
is set to 2 and "running" clusters entry is reduced to 1. The |
|
Number of hits from the completed searches so far. Final hits are not shown until searches on all clusters have been completed and merged. Thus, the "hits" section can change as you call this endpoint until the search is completely done. |
After searches on all the clusters have completed, querying the
get async search endpoint will show the final
status of the _clusters
and _shards
section as well as the hits
and any aggregation results.
resp = client.async_search.get( id="FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", ) print(resp)
response = client.async_search.get( id: 'FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=' ) puts response
const response = await client.asyncSearch.get({ id: "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", }); console.log(response);
GET /_async_search/FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=
Response:
{ "id": "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", "is_partial": false, "is_running": false, "start_time_in_millis": 1685564911108, "expiration_time_in_millis": 1685996911108, "completion_time_in_millis": 1685564938727, "response": { "took": 27619, "timed_out": false, "num_reduce_phases": 4, "_shards": { "total": 28, "successful": 28, "skipped": 0, "failed": 0 }, "_clusters": { "total": 3, "successful": 3, "skipped": 0, "running": 0, "partial": 0, "failed": 0, "details": { "(local)": { "status": "successful", "indices": "my-index-000001", "took": 2034, "timed_out": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "successful", "indices": "my-index-000001", "took": 9039, "timed_out": false, "_shards": { "total": 12, "successful": 12, "skipped": 0, "failed": 0 } }, "cluster_two": { "status": "successful", "indices": "my-index-000001", "took": 27550, "timed_out": false, "_shards": { "total": 6, "successful": 6, "skipped": 0, "failed": 0 } } } }, "hits": { "total": { "value": 1067, "relation": "eq" }, "max_score": 1.8293576, "hits": [...list of hits here...] } } }
Once the search has finished, the completion_time is present. |
|
The |
|
The |
Cross-cluster search failures
editFailures during a cross-cluster search can result in one of two conditions:
- partial results (2xx HTTP status code)
- a failed search (4xx or 5xx HTTP status code)
Failure details will be present in the search response in both cases.
A search will be failed if a cluster marked with skip_unavailable
=false
is unavailable, disconnects during the search, or has search failures on
all shards. In all other cases, failures will result in partial results.
Search failures on individual shards will be present in both the _shards
section and the _clusters
section of the response.
A failed search will have an additional top-level errors
entry in the response.
Here is an example of a search with partial results due to a failure on one shard
of one cluster. The search would be similar to ones shown previously. The
_async_search/status
endpoint is used here to show the completion status and
not show the hits.
resp = client.async_search.status( id="FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw", ) print(resp)
response = client.async_search.status( id: 'FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw' ) puts response
const response = await client.asyncSearch.status({ id: "FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw", }); console.log(response);
GET /_async_search/status/FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw
Response:
{ "id": "FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw", "is_partial": true, "is_running": false, "start_time_in_millis": 1692106901478, "expiration_time_in_millis": 1692538901478, "completion_time_in_millis": 1692106903547, "response": { "took": 2069, "timed_out": false, "num_reduce_phases": 4, "_shards": { "total": 28, "successful": 27, "skipped": 0, "failed": 1, "failures": [ { "shard": 1, "index": "cluster_two:my-index-000001", "node": "LMpUnAu0QEeCUMfg_56sAg", "reason": { "type": "query_shard_exception", "reason": "failed to create query: [my-index-000001][1] exception message here", "index_uuid": "4F2VWx8RQSeIhUE-nksvCQ", "index": "cluster_two:my-index-000001", "caused_by": { "type": "runtime_exception", "reason": "runtime_exception: [my-index-000001][1] exception message here" } } } ] }, "_clusters": { "total": 3, "successful": 2, "skipped": 0, "running": 0, "partial": 1, "failed": 0, "details": { "(local)": { "status": "successful", "indices": "my-index-000001", "took": 1753, "timed_out": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "successful", "indices": "my-index-000001", "took": 2054, "timed_out": false, "_shards": { "total": 12, "successful": 12, "skipped": 0, "failed": 0 } }, "cluster_two": { "status": "partial", "indices": "my-index-000001", "took": 2039, "timed_out": false, "_shards": { "total": 6, "successful": 5, "skipped": 0, "failed": 1 }, "failures": [ { "shard": 1, "index": "cluster_two:my-index-000001", "node": "LMpUnAu0QEeCUMfg_56sAg", "reason": { "type": "query_shard_exception", "reason": "failed to create query: [my-index-000001][1] exception message here", "index_uuid": "4F2VWx8RQSeIhUE-nksvCQ", "index": "cluster_two:my-index-000001", "caused_by": { "type": "runtime_exception", "reason": "runtime_exception: [my-index-000001][1] exception message here" } } } ] } } }, "hits": { } } }
The search results are marked as partial, since at least one shard search failed. |
|
The |
|
Clusters that have partial results are still marked as "partial". They are marked with status "skipped" (or "failed") only if no data was returned from the search. |
|
The |
|
The failed shard count is shown. |
|
The shard failures are listed under the cluster/details entry also. |
Here is an example where both cluster_one
and cluster_two
lost connectivity
during a cross-cluster search. Since cluster_one
is marked as skip_unavailable
=true
,
its status is skipped
and since cluster_two
is marked as skip_unavailable
=false
,
its status is failed
. Since there was a failed
cluster, a top level error
is also present and this returns an HTTP status of 500 (not shown).
If you want the search to still return results even when a cluster is
unavailable, set skip_unavailable
=true
for all the remote clusters.
resp = client.async_search.get( id="FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4", ) print(resp)
response = client.async_search.get( id: 'FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4' ) puts response
const response = await client.asyncSearch.get({ id: "FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4", }); console.log(response);
GET /_async_search/FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4
Response:
{ "id": "FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4", "is_partial": true, "is_running": false, "start_time_in_millis": 1692112102650, "expiration_time_in_millis": 1692544102650, "completion_time_in_millis": 1692112106177, "response": { "took": 3527, "timed_out": false, "terminated_early": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 }, "_clusters": { "total": 3, "successful": 1, "skipped": 1, "running": 0, "partial": 0, "failed": 1, "details": { "(local)": { "status": "successful", "indices": "my-index-000001", "took": 1473, "timed_out": false, "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "skipped", "indices": "my-index-000001", "timed_out": false, "failures": [ { "shard": -1, "index": null, "reason": { "type": "node_disconnected_exception", "reason": "[myhostname1][35.238.149.1:9300][indices:data/read/search] disconnected" } } ] }, "cluster_two": { "status": "failed", "indices": "my-index-000001", "timed_out": false, "failures": [ { "shard": -1, "index": null, "reason": { "type": "node_disconnected_exception", "reason": "[myhostname2][35.238.149.2:9300][indices:data/read/search] disconnected" } } ] } } }, "hits": { }, } "error": { "type": "status_exception", "reason": "error while executing search", "caused_by": { "type": "node_disconnected_exception", "reason": "[myhostname2][35.238.149.2:9300][indices:data/read/search] disconnected" } } }
The shard accounting will often be only partial when errors like this occur, since we need to be able to get shard info from remote clusters on each search. |
|
|
|
The failures list shows that the remote cluster node disconnected from the querying cluster. |
|
|
|
A top level |
Excluding clusters or indices from a cross-cluster search
editIf you use a wildcard to include a large list of clusters and/or indices,
you can explicitly exclude one or more clusters or indices with a -
minus
sign in front of the cluster or index.
To exclude an entire cluster, you would put the minus sign in front of the
cluster alias, such as: -mycluster:*
. When excluding a cluster, you must
use *
in the index position or an error will be returned.
To exclude a specific remote index, you would put the minus sign in front
of the index, such as mycluster:-myindex
.
Exclude a remote cluster
Here’s how you would exclude cluster_three
from a
cross-cluster search that uses a wildcard to specify a list of clusters:
resp = client.async_search.submit( index="my-index-000001,cluster*:my-index-000001,-cluster_three:*", query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
const response = await client.asyncSearch.submit({ index: "my-index-000001,cluster*:my-index-000001,-cluster_three:*", query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
POST /my-index-000001,cluster*:my-index-000001,-cluster_three:*/_async_search { "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
The |
Exclude a remote index
Suppose you want to search all indices matching my-index-*
but you want to exclude
my-index-000001
on cluster_three
. Here’s how you could do that:
resp = client.async_search.submit( index="my-index-000001,cluster*:my-index-*,cluster_three:-my-index-000001", query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
const response = await client.asyncSearch.submit({ index: "my-index-000001,cluster*:my-index-*,cluster_three:-my-index-000001", query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
POST /my-index-000001,cluster*:my-index-*,cluster_three:-my-index-000001/_async_search { "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
This will not exclude |
Using async search for cross-cluster search with ccs_minimize_roundtrips=false
editThe _shards
and _clusters
section of the response behave
differently when ccs_minimize_roundtrips
is false
.
Key differences are:
-
The
_shards
section total count will be accurate immediately as the total number of shards is gathered from all clusters before the search starts. -
The
_shards
section will be incrementally updated as searches on individual shards complete, whereas when minimizing roundtrips, the shards section will be updated as searches on shards complete on the local cluster and then as each remote cluster reports back its full search results. -
The
_cluster
section starts off listing all of its shard counts, since they are also obtained before the query phase begins.
Example using the same setup as in the previous section (ccs_minimize_roundtrips=true
):
resp = client.async_search.submit( index="my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", ccs_minimize_roundtrips=False, query={ "match": { "user.id": "kimchy" } }, source=[ "user.id", "message", "http.response.status_code" ], ) print(resp)
const response = await client.asyncSearch.submit({ index: "my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001", ccs_minimize_roundtrips: "false", query: { match: { "user.id": "kimchy", }, }, _source: ["user.id", "message", "http.response.status_code"], }); console.log(response);
POST /my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001/_async_search?ccs_minimize_roundtrips=false { "query": { "match": { "user.id": "kimchy" } }, "_source": ["user.id", "message", "http.response.status_code"] }
The API returns the following response if the query takes longer than
the wait_for_completion_timeout
duration (see Async search).
{ "id": "FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=", "is_partial": true, "is_running": true, "start_time_in_millis": 1685563581380, "expiration_time_in_millis": 1685995581380, "response": { "took": 1020, "timed_out": false, "_shards": { "total": 28, "successful": 0, "failed": 0, "skipped": 0 }, "_clusters": { "total" : 3, "successful": 0, "skipped": 0, "running": 3, "partial": 0, "failed": 0, "details": { "(local)": { "status": "running", "indices": "my-index-000001", "timed_out": false, "_shards": { "total": 10, "successful": 0, "skipped": 0, "failed": 0 } }, "cluster_one": { "status": "running", "indices": "my-index-000001", "timed_out": false, "_shards": { "total": 12, "successful": 0, "skipped": 0, "failed": 0 } }, "cluster_two": { "status": "running", "indices": "my-index-000001", "timed_out": false, "_shards": { "total": 6, "successful": 0, "skipped": 0, "failed": 0 } } } }, "hits": { "total" : { "value": 0, "relation": "eq" }, "max_score": null, "hits": [] } } }
All shards from all clusters in scope for the search are listed here. Watch this section and/or the _clusters section for updates to monitor search progress. |
|
From the |
|
The |
Optional remote clusters
editBy default, a cross-cluster search fails if a remote cluster in the request is unavailable
or returns an error where the search on all shards failed. Use the
skip_unavailable
cluster setting to mark a specific remote cluster as
either optional or required for cross-cluster search.
In Elasticsearch 8.15, the default value for skip_unavailable
was
changed from false
to true
. Before Elasticsearch 8.15, if you want a cluster
to be treated as optional for a cross-cluster search, then you need to set that configuration.
From Elasticsearch 8.15 forward, you need to set the configuration in order to
make a cluster required for the cross-cluster search.
If skip_unavailable
is true
, a cross-cluster search:
-
Skips the remote cluster if its nodes are unavailable during the search. The
response’s
_clusters.skipped
value contains a count of any skipped clusters and the_clusters.details
section of the response will show askipped
status. -
Ignores errors returned by the remote cluster, such as errors related to
unavailable shards or indices. This can include errors related to search
parameters such as
allow_no_indices
andignore_unavailable
. -
Ignores the
allow_partial_search_results
parameter and the relatedsearch.default_allow_partial_results
cluster setting when searching the remote cluster. This means searches on the remote cluster may return partial results.
You can modify the skip_unavailable
setting by editing the cluster.remote.<cluster_alias>
settings in the elasticsearch.yml config file. For example:
cluster: remote: cluster_one: seeds: 35.238.149.1:9300 skip_unavailable: false cluster_two: seeds: 35.238.149.2:9300 skip_unavailable: true
Or you can set the cluster.remote settings via the cluster update settings API as shown here.
When a remote cluster configured with skip_unavailable: true
(such as
cluster_two
above) is disconnected or unavailable during a cross-cluster search, Elasticsearch won’t
include matching documents from that cluster in the final results and the
search will be considered successful (HTTP status 200 OK).
If at least one shard from a cluster provides search results, those results will
be used and the search will return partial data. This is true regardless of
the skip_unavailable
setting of the remote cluster. (If doing cross-cluster search using async
search, the is_partial
field will be set to true
to indicate partial results.)
How cross-cluster search handles network delays
editBecause cross-cluster search involves sending requests to remote clusters, any network delays can impact search speed. To avoid slow searches, cross-cluster search offers two options for handling network delays:
- Minimize network roundtrips
-
By default, Elasticsearch reduces the number of network roundtrips between remote clusters. This reduces the impact of network delays on search speed. However, Elasticsearch can’t reduce network roundtrips for large search requests, such as those including a scroll or inner hits.
See Considerations for choosing whether to minimize roundtrips in a cross-cluster search to learn how this option works.
- Don’t minimize network roundtrips
-
For search requests that include a scroll or inner hits, Elasticsearch sends multiple outgoing and ingoing requests to each remote cluster. You can also choose this option by setting the
ccs_minimize_roundtrips
parameter tofalse
. While typically slower, this approach may work well for networks with low latency.See Don’t minimize network roundtrips to learn how this option works.
The vector tile search API always minimizes
network roundtrips and doesn’t include the ccs_minimize_roundtrips
parameter.
The Approximate kNN search doesn’t support minimizing
network roundtrips, and sets the parameter ccs_minimize_roundtrips
to false
.
Considerations for choosing whether to minimize roundtrips in a cross-cluster search
editAdvantages of minimizing roundtrips:
- For cross-cluster searches that query a large number of shards, the minimize roundtrips option typically provides much better performance. This is especially true if the clusters being searched have high network latency (e.g., distant geographic regions).
-
When doing an async cross-cluster search, the
GET _async_search/<search_id>
endpoint will provide both top hits and aggregations from all clusters that have reported back results even while the search is still running on other clusters. In other words, it provides "incremental" partial results as the search progresses. Note that if the local cluster is included in the search, it has special handling in that it can show partial aggregations (but not partial top hits) while the search on the local cluster is still running.
Not minimizing roundtrips when using async-search allows you to get back incremental results of any aggregations in your query as individual shards complete (rather than whole clusters) while the search is still running, but top hits are not shown until the search has completed on all clusters.
By default, synchronous searches minimize roundtrips, while asynchronous searches
do not. You can override the default by using the ccs_minimize_roundtrips
parameter,
setting it to either true
or false
, as shown in several examples earlier in this
document.
Minimize network roundtrips
editHere’s how cross-cluster search works when you minimize network roundtrips.
-
You send a cross-cluster search request to your local cluster. A coordinating node in that cluster receives and parses the request.
-
The coordinating node sends a single search request to each cluster, including the local cluster. Each cluster performs the search request independently, applying its own cluster-level settings to the request.
-
Each remote cluster sends its search results back to the coordinating node.
-
After collecting results from each cluster, the coordinating node returns the final results in the cross-cluster search response.
Don’t minimize network roundtrips
editHere’s how cross-cluster search works when you don’t minimize network roundtrips.
-
You send a cross-cluster search request to your local cluster. A coordinating node in that cluster receives and parses the request.
-
The coordinating node sends a "search shards" transport layer request to each remote cluster to have them to perform a "can match" search to determine which shards on each cluster should be searched.
-
Each remote cluster sends its response back to the coordinating node. This response contains information about the indices and shards the cross-cluster search request will be executed on.
-
The coordinating node sends a search request to each shard, including those in its own cluster. Each shard performs the search request independently.
When network roundtrips aren’t minimized, the search is executed as if all data were in the coordinating node’s cluster. We recommend updating cluster-level settings that limit searches, such as
action.search.shard_count.limit
,pre_filter_shard_size
, andmax_concurrent_shard_requests
, to account for this. If these limits are too low, the search may be rejected. -
Each shard sends its search results back to the coordinating node.
-
After collecting results from each cluster, the coordinating node returns the final results in the cross-cluster search response.
Supported cross-cluster search configurations
editIn 8.0+, Elastic supports searches from a local cluster to a remote cluster running:
- The previous minor version.
- The same version.
- A newer minor version in the same major version.
Elastic also supports searches from a local cluster running the last minor version of a major version to a remote cluster running any minor version in the following major version. For example, a local 7.17 cluster can search any remote 8.x cluster.
Remote cluster version |
|||||||||||||||||||||
Local cluster version |
6.8 |
7.1–7.16 |
7.17 |
8.0 |
8.1 |
8.2 |
8.3 |
8.4 |
8.5 |
8.6 |
8.7 |
8.8 |
8.9 |
8.10 |
8.11 |
8.12 |
8.13 |
8.14 |
8.15 |
8.16 |
8.17 |
6.8 |
|||||||||||||||||||||
7.1–7.16 |
|||||||||||||||||||||
7.17 |
|||||||||||||||||||||
8.0 |
|||||||||||||||||||||
8.1 |
|||||||||||||||||||||
8.2 |
|||||||||||||||||||||
8.3 |
|||||||||||||||||||||
8.4 |
|||||||||||||||||||||
8.5 |
|||||||||||||||||||||
8.6 |
|||||||||||||||||||||
8.7 |
|||||||||||||||||||||
8.8 |
|||||||||||||||||||||
8.9 |
|||||||||||||||||||||
8.10 |
|||||||||||||||||||||
8.11 |
|||||||||||||||||||||
8.12 |
|||||||||||||||||||||
8.13 |
|||||||||||||||||||||
8.14 |
|||||||||||||||||||||
8.15 |
|||||||||||||||||||||
8.16 |
|||||||||||||||||||||
8.17 |
For the EQL search API, the local and remote clusters must use the same Elasticsearch version if they have versions prior to 7.17.7 (included) or prior to 8.5.1 (included).
For example, a local 8.0 cluster can search a remote 7.17 or any remote 8.x cluster. However, a search from a local 8.0 cluster to a remote 7.16 or 6.8 cluster is not supported.
Only features that exist across all searched clusters are supported. Using a feature with a remote cluster where the feature is not supported will result in undefined behavior.
A cross-cluster search using an unsupported configuration may still work. However, such searches aren’t tested by Elastic, and their behavior isn’t guaranteed.
Ensure cross-cluster search support
editThe simplest way to ensure your clusters support cross-cluster search is to keep each cluster on the same version of Elasticsearch. If you need to maintain clusters with different versions, you can:
- Maintain a dedicated cluster for cross-cluster search. Keep this cluster on the earliest version needed to search the other clusters. For example, if you have 7.17 and 8.x clusters, you can maintain a dedicated 7.17 cluster to use as the local cluster for cross-cluster search.
- Keep each cluster no more than one minor version apart. This lets you use any cluster as the local cluster when running a cross-cluster search.
Cross-cluster search during an upgrade
editYou can still search a remote cluster while performing a rolling upgrade on the local cluster. However, the local coordinating node’s "upgrade from" and "upgrade to" version must be compatible with the remote cluster’s gateway node.
Running multiple versions of Elasticsearch in the same cluster beyond the duration of an upgrade is not supported.
For more information about upgrades, see Upgrading Elasticsearch.
On this page
- Supported APIs
- Prerequisites
- Cross-cluster search examples
- Remote cluster setup
- Search a single remote cluster
- Search multiple remote clusters
- Using async search for cross-cluster search with ccs_minimize_roundtrips=true
- Cross-cluster search failures
- Excluding clusters or indices from a cross-cluster search
- Using async search for cross-cluster search with ccs_minimize_roundtrips=false
- Optional remote clusters
- How cross-cluster search handles network delays
- Considerations for choosing whether to minimize roundtrips in a cross-cluster search
- Minimize network roundtrips
- Don’t minimize network roundtrips
- Supported cross-cluster search configurations
- Ensure cross-cluster search support
- Cross-cluster search during an upgrade