Hi everyone,
first of all, saying that I'm quite new with Elasticsearch. I was diving into other similar issues related with my problem, but none of the solutions worked for me.
My code has a query which says:
failed to create query: maxClauseCount is set to 1024
I've created a fresh new Deployment and a new index in there:
PUT /portcalls
{
"aliases" : { },
"mappings" : {
"properties" : {
"actionNeeded" : {
"type" : "boolean"
},
"agencyFee" : {
"type" : "float"
},
"agencyFeeCurrency" : {
"properties" : {
"code" : {
"type" : "keyword",
"index" : false
},
"name" : {
"type" : "keyword",
"index" : false
}
}
},
"agencyFeeCurrencyCode" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"blStatus" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"cargo" : {
"properties" : {
"blStatus" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"cargoPurpose" : {
"type" : "long"
},
"commencedDate" : {
"type" : "date",
"format" : "date_time"
},
"confirmedOperation" : {
"type" : "boolean"
},
"loadUnloadedCargo" : {
"type" : "float"
},
"moloAmount" : {
"type" : "float"
},
"name" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"quantity" : {
"type" : "float"
},
"quantityType" : {
"type" : "keyword",
"index" : false
},
"route" : {
"properties" : {
"country" : {
"type" : "keyword"
},
"locode" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword"
}
}
},
"tillDate" : {
"type" : "date",
"format" : "date_time"
},
"unit" : {
"type" : "keyword",
"index" : false
}
}
},
"cargoQuantity" : {
"properties" : {
"loadedUnloaded" : {
"type" : "float"
},
"total" : {
"type" : "float"
},
"unit" : {
"type" : "keyword",
"index" : false
}
}
},
"clientReference" : {
"type" : "keyword"
},
"createdAt" : {
"type" : "date",
"format" : "date_time"
},
"daOwner" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"eta" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "date_time"
},
"isActual" : {
"type" : "boolean"
},
"remark" : {
"type" : "keyword",
"index" : false
}
}
},
"etb" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "date_time"
},
"isActual" : {
"type" : "boolean"
},
"remark" : {
"type" : "keyword",
"index" : false
}
}
},
"etc" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "date_time"
},
"isActual" : {
"type" : "boolean"
},
"remark" : {
"type" : "keyword",
"index" : false
}
}
},
"ets" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "date_time"
},
"isActual" : {
"type" : "boolean"
},
"remark" : {
"type" : "keyword",
"index" : false
}
}
},
"id" : {
"type" : "keyword"
},
"isNomination" : {
"type" : "boolean"
},
"messages" : {
"type" : "nested",
"properties" : {
"createdAt" : {
"type" : "date",
"format" : "date_time"
},
"portcallId" : {
"type" : "keyword"
},
"type" : {
"type" : "long"
},
"uniqueName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"vessel" : {
"type" : "keyword"
}
}
},
"nextPort" : {
"properties" : {
"country" : {
"properties" : {
"code" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword"
}
}
},
"locode" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
}
}
},
"notifications" : {
"type" : "nested",
"properties" : {
"activeFrom" : {
"type" : "date",
"format" : "date_time"
},
"activeTill" : {
"type" : "date",
"format" : "date_time"
},
"country" : {
"type" : "keyword"
},
"countryCode" : {
"type" : "keyword"
},
"createdAt" : {
"type" : "date",
"format" : "date_time"
},
"field" : {
"type" : "keyword"
},
"portOfCall" : {
"type" : "keyword"
},
"portcallId" : {
"type" : "keyword"
},
"reasonsList" : {
"type" : "long"
},
"status" : {
"type" : "long"
},
"uniqueName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"uniqueNumber" : {
"type" : "keyword"
},
"vessel" : {
"type" : "keyword"
}
}
},
"portOfCall" : {
"properties" : {
"country" : {
"properties" : {
"code" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword"
}
}
},
"locode" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
}
}
},
"portablePartyIds" : {
"type" : "keyword"
},
"portcallResponsibles" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"principal" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"purposeCall" : {
"properties" : {
"code" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
}
}
},
"purposeCallExtra" : {
"type" : "keyword"
},
"quantity" : {
"properties" : {
"loadedUnloaded" : {
"type" : "long"
},
"total" : {
"type" : "long"
}
}
},
"quantityUnit" : {
"type" : "keyword",
"index" : false
},
"query" : {
"properties" : {
"bool" : {
"properties" : {
"must" : {
"properties" : {
"bool" : {
"properties" : {
"should" : {
"properties" : {
"match" : {
"properties" : {
"status" : {
"properties" : {
"operator" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"query" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"status" : {
"type" : "keyword"
},
"subStatus" : {
"type" : "keyword"
},
"terminal" : {
"type" : "keyword",
"fields" : {
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
},
"uniqueNumber" : {
"type" : "keyword"
},
"updatedAt" : {
"type" : "date",
"format" : "date_time"
},
"userEmails" : {
"type" : "keyword"
},
"vessel" : {
"properties" : {
"imo" : {
"type" : "keyword"
},
"name" : {
"type" : "keyword",
"fields" : {
"autocomplete" : {
"type" : "text",
"analyzer" : "autocomplete",
"search_analyzer" : "autocomplete_search"
},
"sort" : {
"type" : "keyword",
"normalizer" : "lowercase_normalizer"
}
}
}
}
}
}
},
"settings" : {
"index" : {
"max_ngram_diff" : "15",
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "1",
"blocks" : {
"read_only_allow_delete" : "false"
},
"max_docvalue_fields_search" : "300",
"analysis" : {
"normalizer" : {
"lowercase_normalizer" : {
"filter" : [
"lowercase",
"asciifolding"
],
"type" : "custom",
"char_filter" : [ ]
}
},
"analyzer" : {
"autocomplete" : {
"filter" : [
"lowercase",
"asciifolding"
],
"tokenizer" : "autocomplete"
},
"autocomplete_search" : {
"tokenizer" : "lowercase"
}
},
"tokenizer" : {
"autocomplete" : {
"token_chars" : [
"letter",
"digit",
"whitespace",
"punctuation"
],
"min_gram" : "2",
"type" : "ngram",
"max_gram" : "15"
}
}
},
"number_of_replicas" : "1"
}
}
}
The query I do is something like (copy & paste messages.portcallId object a hundred of times):
GET /portcalls/_search
{
"sort": [
{
"messages.createdAt": {
"order": "desc"
}
}
],
"post_filter": {
"nested": {
"path": "messages",
"query": {
"bool": {
"should": [
{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
}
]
}
}
}
},
"query": {
"nested": {
"path": "messages",
"query": {
"bool": {
"should": [
{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
},{
"term": {
"messages.portcallId": "NI3GuQfz6wtxEv3GB99d"
}
}
]
}
}
}
}
}
and the error says:
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "failed to create query: maxClauseCount is set to 1024",
"index_uuid" : "CSZAkCocQv6ahIC-YlViIA",
"index" : "portcalls"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "portcalls",
"node" : "kRy3UV_pThqs9km7SUp3zw",
"reason" : {
"type" : "query_shard_exception",
"reason" : "failed to create query: maxClauseCount is set to 1024",
"index_uuid" : "CSZAkCocQv6ahIC-YlViIA",
"index" : "portcalls",
"caused_by" : {
"type" : "too_many_clauses",
"reason" : "maxClauseCount is set to 1024"
}
}
}
]
},
"status" : 400
}
I've checked what is the value for maxClauseCount, and it says 4096:
GET _cluster/settings/?include_defaults
I tried to modify that value editing the deployment and adding
indices.query.bool.max_clause_count: 8192
but the system does not allow me to Save the change. It says:
Your changes cannot be applied
Elasticsearch - 'indices.query.bool.max_clause_count': is not allowed
Anyone can help with the problem?
Regards.