Skip to content

CCS: field collapsing doesn't work when minimizing roundtrips and remote index is empty #40067

@chrisronline

Description

@chrisronline

Elasticsearch version (bin/elasticsearch --version): latest master snapshot (hash: 8839a72)

Plugins installed: []

JVM version (java -version): java version "11.0.1" 2018-10-16 LTS

OS version (uname -a if on a Unix-like system): Darwin Kernel Version 18.2.0

Description of the problem including expected versus actual behavior:

When performing a CCS search request, an error occurs if there is field collapsing in the query.

The exact error is:

java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, org.apache.lucene.search.grouping.CollapseTopFieldDocs
	at java.util.ArrayList.toArray(ArrayList.java:432) ~[?:?]
	at org.elasticsearch.action.search.SearchPhaseController.mergeTopDocs(SearchPhaseController.java:236) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
	at org.elasticsearch.action.search.SearchResponseMerger.getMergedResponse(SearchResponseMerger.java:190) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
	at org.elasticsearch.action.search.TransportSearchAction$3.createFinalResponse(TransportSearchAction.java:389) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
	at org.elasticsearch.action.search.TransportSearchAction$3.createFinalResponse(TransportSearchAction.java:379) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]

Steps to reproduce:

  1. Start two ES instances, ensuring they have unique cluster.names
  2. Configure one ES instance to talk to the other through CCS
POST _cluster/settings
{
  "persistent": {
    "cluster": {
      "remote": {
        "other": {
          "seeds": [
            "{other_es_instance_address}"
          ]
        }
      }
    }
  }
}
  1. Put data in the an index on the ES cluster you ran the above query:
POST _bulk
{ "index": { "_index": "sales" } }
{ "price": 30, "payment_type": "credit_card" }
{ "index": { "_index": "sales" } }
{ "price": 40, "payment_type": "cash" }
  1. DO NOT put any data into the other ES cluster
  2. Perform a CCS search that uses field collapsing from the same ES instance
POST *:sales*,sales*/_search
{
  "collapse": {
    "field": "payment_type.keyword"
  }
}

This error also happens if you modify step 4 to only put the index (but do not index documents into it) on the other ES instance:

PUT sales
{
  "mappings": {
    "properties" : {
      "payment_type" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "price" : {
        "type" : "long"
      }
    }
  }
}

The error DOES NOT happen if you actually index documents into the index on the other ES cluster:

POST _bulk
{ "index": { "_index": "sales" } }
{ "price": 30, "payment_type": "credit_card" }
{ "index": { "_index": "sales" } }
{ "price": 40, "payment_type": "cash" }

This is currently BREAKING the Kibana Stack Monitoring app, as we run these sorts of field collapsing which are currently broken with CCS enabled.

Related to #40059

Metadata

Metadata

Assignees

Labels

:Search/SearchSearch-related issues that do not fall into other categories>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions