Custom query plugin


(Daniel Pupo Ricardo) #1

I'm upgrading an Elasticsearch plugin from version 2.4.0 to 5.4.0. This plugin implements a custom query but with the new changes on Elasticsearch Java Api I'm a little confused in how to register the new query. I search in Elasticsearch site and I found that I must implement the SearchPlugin interfaces and override the method getQueries but I'm still confused and how I do that. Any help?


(Ryan Ernst) #2

The getQueries() method on SearchPlugin returns a list of QuerySpec. This is a trivial container of the things that elasticsearch needs in order to use the query. That consists of 3 things:

  1. A name for the query. This is what you would use within the rest api to specify the query.
  2. A Writable.Reader instance. This is a binary parser for the query. Since 5.0, queries need to be readable/writable by the transport api. This is so they can be parsed on the coordinating node, and sent to each shard without having to parse xcontent again.
  3. A QueryParser. This is probably what you already have and parses xcontent from a rest request.

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.