Search code examples
javaelasticsearch

no [query] registered for [query] error int ltr plugin of elasticsearch


I am using ltr plugin for elasticsearch and I am doing exactly what documentation said. here is my featureset:

{
   "validation": {
     "params": {
         "keywords": "rambo"
     },
     "index": "movies"
    },
    "featureset": {
        "name": "movie_features",
        "features": [
            {
                "name": "title_query",
                "params": [
                    "keywords"
                ],
                "template_language": "mustache",
                "template": {
                    "query": {
                        "match": {
                            "title": "{{keywords}}"
                        }
                    }
                }
            }
        ]
    }
}

when I submit this request, I get the following error:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Cannot store element, validation failed."
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Cannot store element, validation failed.",
        "caused_by": {
            "type": "search_phase_execution_exception",
            "reason": "all shards failed",
            "phase": "query",
            "grouped": true,
            "failed_shards": [
                {
                    "shard": 0,
                    "index": "movies",
                    "node": "OixZfLQjRzmcY8yDxTCt9w",
                    "reason": {
                        "type": "query_shard_exception",
                        "reason": "Cannot create query while parsing feature [title_query]",
                        "index_uuid": "9TSirwWkQNOuMAkHFMpGvw",
                        "index": "movies",
                        "caused_by": {
                            "type": "parsing_exception",
                            "reason": "no [query] registered for [query]",
                            "line": 1,
                            "col": 10
                        }
                    }
                }
            ]
        }
    },
    "status": 400
}

so what is wrong? it seems elasticsearch can not build the query, but I don't know what should I change in my query.


Solution

  • I found the answer. you should remove query keyword in template:

    "template": {
        "match": {
            "title": "{{keywords}}"
        }
    }