Custom Queries

Hi Shay,

Firstly, just like to say that I've been tinkering with ElasticSearch
for a few days and I'm really impressed, great work!

Secondly, apologies - it's silly newbie question time...

I've been looking at writing a custom query for a particular use case
that I have which ElasticSearch doesn't currently support (similar to
a has_parent query).

Looking at the source, it looks like I can add custom queries through
writing a QueryParsersProcessor, which registers the parser for the
query in the processXContentQueryParsers() method - but I'm currently
missing how I could get my QueryParsersProcessor picked up from the
ClassPath by ElasticSearch.

I was wondering whether you could possibly point me in the right
direction?

Many thanks,

Sean.

Heya,

What you should do is write a plugin. Have a look at the icu plugin for an example. In the plugin, you can override the processModule method, and if its the IndexQueryParserModule, then call addProcessor on it to add your own query.

Note, a plugin should come with an es-plugin.properties file. Check the icu analysis plugin for an example of one.

-shay.banon
On Friday, April 29, 2011 at 2:08 PM, seansi wrote:

Hi Shay,

Firstly, just like to say that I've been tinkering with Elasticsearch
for a few days and I'm really impressed, great work!

Secondly, apologies - it's silly newbie question time...

I've been looking at writing a custom query for a particular use case
that I have which Elasticsearch doesn't currently support (similar to
a has_parent query).

Looking at the source, it looks like I can add custom queries through
writing a QueryParsersProcessor, which registers the parser for the
query in the processXContentQueryParsers() method - but I'm currently
missing how I could get my QueryParsersProcessor picked up from the
ClassPath by Elasticsearch.

I was wondering whether you could possibly point me in the right
direction?

Many thanks,

Sean.

Many thanks for that Shay, I'll give it a go!

Sean.

Yep, that works a treat - cheers Shay!

Sean.