Span or clauses must be of type span query – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when the “span_or” query in Elasticsearch is not correctly formatted. The “span_or” query requires an array of “span” queries in the “clauses” field. If the “clauses” field contains anything other than “span” queries, this error will be thrown. To resolve this issue, ensure that the “clauses” field only contains valid “span” queries. Also, check the syntax and structure of your “span” queries to ensure they are correctly formatted.

This guide will help you check for common problems that cause the log ” span_or [clauses] must be of type span query ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: query, index.

Log Context

Log “span_or [clauses] must be of type span query” class name is SpanOrQueryBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 } else if (token == XContentParser.Token.START_ARRAY) {
 if (CLAUSES_FIELD.match(currentFieldName; parser.getDeprecationHandler())) {
 while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
 QueryBuilder query = parseInnerQueryBuilder(parser);
 if (query instanceof SpanQueryBuilder == false) {
 throw new ParsingException(parser.getTokenLocation(); "span_or [clauses] must be of type span query");
 }
 final SpanQueryBuilder clause = (SpanQueryBuilder) query;
 checkNoBoost(NAME; currentFieldName; parser; clause);
 clauses.add(clause);
 }

 

 [ratemypost]