简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM