Briefly, this error occurs when a Pinned Query in Elasticsearch is not properly configured. A Pinned Query is used to promote selected documents to rank higher in search results. It requires either ‘ids’ or ‘docs’ to specify which documents to promote. If neither is provided, this error is thrown. To resolve this, ensure that your Pinned Query includes either ‘ids’ or ‘docs’. If you’re using ‘ids’, provide the IDs of the documents to promote. If you’re using ‘docs’, provide the actual documents. Make sure the syntax is correct and the specified documents exist in your index.
This guide will help you check for common problems that cause the log ” Pinned Query rule actions must contain either ids or docs ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, query.
Log Context
Log “Pinned Query rule actions must contain either ids or docs” class name is QueryRule.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :
} private void validate() { if (type == QueryRuleType.PINNED) { if (actions.containsKey("ids") == false && actions.containsKey("docs") == false) { throw new ElasticsearchParseException("Pinned Query rule actions must contain either ids or docs"); } } else { throw new IllegalArgumentException("Unsupported QueryRuleType: " + type); } }