# Registering a Custom Query Builder

**URL:** <https://discuss.elastic.co/t/registering-a-custom-query-builder/3045>\
**Category:** Elasticsearch\
**Created:** [June 28, 2010, 1:54am UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045 "2010-06-28T01:54:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)\
**Post date:** [June 28, 2010, 1:54am UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/1 "2010-06-28T01:54:12Z")

</div>

I created a custom query builder but it looks like I somehow need to  
register it with ElasticSearch since I encounter a SearchParseException  
which says  
"No query parser registered for ... "

How do I go about doing this?

Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 28, 2010, 11:57am UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/2 "2010-06-28T11:57:37Z")

</div>

You can either write a plugin that automatically registers it under your  
special name, or configure elasticsearch to use it. You can have a look at  
the elasticsearch tests to see how its done, check  
out org.elasticsearch.index.query.xcontent.plugin  
and org.elasticsearch.index.query.xcontent.guice in the test area of the  
elasticsearch module.

-shay.banon

On Mon, Jun 28, 2010 at 4:54 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> I created a custom query builder but it looks like I somehow need to  
> register it with Elasticsearch since I encounter a SearchParseException  
> which says  
> "No query parser registered for ... "
> 
> How do I go about doing this?
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)\
**Post date:** [June 28, 2010, 1:26pm UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/3 "2010-06-28T13:26:41Z")

</div>

Great thanks!

On Mon, Jun 28, 2010 at 4:57 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> You can either write a plugin that automatically registers it under your  
> special name, or configure elasticsearch to use it. You can have a look at  
> the elasticsearch tests to see how its done, check  
> out org.elasticsearch.index.query.xcontent.plugin  
> and org.elasticsearch.index.query.xcontent.guice in the test area of the  
> elasticsearch module.
> 
> -shay.banon
> 
> On Mon, Jun 28, 2010 at 4:54 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> 
> > I created a custom query builder but it looks like I somehow need to  
> > register it with Elasticsearch since I encounter a SearchParseException  
> > which says  
> > "No query parser registered for ... "
> > 
> > How do I go about doing this?
> > 
> > Thanks.

---

<div class="post-metadata">

**Author:** ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)\
**Post date:** [June 30, 2010, 10:52am UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/4 "2010-06-30T10:52:07Z")

</div>

Hi,

I had a chance to look at this the other day and attempted to register my  
custom queryparser based on your test.  
The default settingsBuilder expects to have your parser within a package  
org.elasticsearch... or it will throw an exception saying so. Do I need to  
override the method that does this prefix check? I'm also now wondering  
about the settings themselves. I'm assuming if I'm a client I don't really  
need too much in the settings since most of this is configured via the  
elasticsearch.yml for each of the nodes and that the passed in settings can  
be empty for the most part?

So when I get to this point does the create injector call goes out and  
register the parser with all the discovered nodes? Is this something that  
needs to be done in another way or does just performing this operation from  
the client suffice?

Thanks

On Mon, Jun 28, 2010 at 6:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> Great thanks!
> 
> On Mon, Jun 28, 2010 at 4:57 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > You can either write a plugin that automatically registers it under your  
> > special name, or configure elasticsearch to use it. You can have a look at  
> > the elasticsearch tests to see how its done, check  
> > out org.elasticsearch.index.query.xcontent.plugin  
> > and org.elasticsearch.index.query.xcontent.guice in the test area of the  
> > elasticsearch module.
> > 
> > -shay.banon
> > 
> > On Mon, Jun 28, 2010 at 4:54 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > 
> > > I created a custom query builder but it looks like I somehow need to  
> > > register it with Elasticsearch since I encounter a SearchParseException  
> > > which says  
> > > "No query parser registered for ... "
> > > 
> > > How do I go about doing this?
> > > 
> > > Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 30, 2010, 4:56pm UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/5 "2010-06-30T16:56:03Z")

</div>

On Wed, Jun 30, 2010 at 1:52 PM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com) wrote:

> Hi,
> 
> I had a chance to look at this the other day and attempted to register my  
> custom queryparser based on your test.  
> The default settingsBuilder expects to have your parser within a package  
> org.elasticsearch... or it will throw an exception saying so. Do I need to  
> override the method that does this prefix check?

You simple call a different constructor, with the last parameter specifying  
the settings prefix you want to use (a different constructor in  
AbstractIndexComponent).

> I'm also now wondering about the settings themselves. I'm assuming if I'm a  
> client I don't really need too much in the settings since most of this is  
> configured via the elasticsearch.yml for each of the nodes and that the  
> passed in settings can be empty for the most part?

Not sure I understand. The settings will come from the yaml file, but most  
times, with query parsers, most parameters would come within the json the  
user provides in the Query DSL (you can see that all query parsers in  
elasticsearch do not use anything from the settings).

> So when I get to this point does the create injector call goes out and  
> register the parser with all the discovered nodes? Is this something that  
> needs to be done in another way or does just performing this operation from  
> the client suffice?

Not really sure what you decided to go with, which integration? The one  
using a plugin, or through the configuration?

> Thanks
> 
> On Mon, Jun 28, 2010 at 6:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> 
> > Great thanks!
> > 
> > On Mon, Jun 28, 2010 at 4:57 AM, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > wrote:
> > 
> > > You can either write a plugin that automatically registers it under your  
> > > special name, or configure elasticsearch to use it. You can have a look at  
> > > the elasticsearch tests to see how its done, check  
> > > out org.elasticsearch.index.query.xcontent.plugin  
> > > and org.elasticsearch.index.query.xcontent.guice in the test area of the  
> > > elasticsearch module.
> > > 
> > > -shay.banon
> > > 
> > > On Mon, Jun 28, 2010 at 4:54 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > > 
> > > > I created a custom query builder but it looks like I somehow need to  
> > > > register it with Elasticsearch since I encounter a SearchParseException  
> > > > which says  
> > > > "No query parser registered for ... "
> > > > 
> > > > How do I go about doing this?
> > > > 
> > > > Thanks.

---

<div class="post-metadata">

**Author:** ![Samuel\_Doyle](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Samuel\_Doyle](https://discuss.elastic.co/u/Samuel_Doyle)\
**Post date:** [June 30, 2010, 7:07pm UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/6 "2010-06-30T19:07:16Z")

</div>

Thanks, I'm trying to use the plugin and ideally it should only apply to the  
client so hopefully it doesn't do any updates to the running nodes.

Thanks

On Wed, Jun 30, 2010 at 9:56 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> On Wed, Jun 30, 2010 at 1:52 PM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> 
> > Hi,
> > 
> > I had a chance to look at this the other day and attempted to register my  
> > custom queryparser based on your test.  
> > The default settingsBuilder expects to have your parser within a package  
> > org.elasticsearch... or it will throw an exception saying so. Do I need to  
> > override the method that does this prefix check?
> 
> You simple call a different constructor, with the last parameter specifying  
> the settings prefix you want to use (a different constructor in  
> AbstractIndexComponent).
> 
> > I'm also now wondering about the settings themselves. I'm assuming if I'm  
> > a client I don't really need too much in the settings since most of this is  
> > configured via the elasticsearch.yml for each of the nodes and that the  
> > passed in settings can be empty for the most part?
> 
> Not sure I understand. The settings will come from the yaml file, but most  
> times, with query parsers, most parameters would come within the json the  
> user provides in the Query DSL (you can see that all query parsers in  
> elasticsearch do not use anything from the settings).
> 
> > So when I get to this point does the create injector call goes out and  
> > register the parser with all the discovered nodes? Is this something that  
> > needs to be done in another way or does just performing this operation from  
> > the client suffice?
> 
> Not really sure what you decided to go with, which integration? The one  
> using a plugin, or through the configuration?
> 
> > Thanks
> > 
> > On Mon, Jun 28, 2010 at 6:26 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > 
> > > Great thanks!
> > > 
> > > On Mon, Jun 28, 2010 at 4:57 AM, Shay Banon \<  
> > > [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)\> wrote:
> > > 
> > > > You can either write a plugin that automatically registers it under your  
> > > > special name, or configure elasticsearch to use it. You can have a look at  
> > > > the elasticsearch tests to see how its done, check  
> > > > out org.elasticsearch.index.query.xcontent.plugin  
> > > > and org.elasticsearch.index.query.xcontent.guice in the test area of the  
> > > > elasticsearch module.
> > > > 
> > > > -shay.banon
> > > > 
> > > > On Mon, Jun 28, 2010 at 4:54 AM, Samuel Doyle [samueldoyle@gmail.com](mailto:samueldoyle@gmail.com)wrote:
> > > > 
> > > > > I created a custom query builder but it looks like I somehow need to  
> > > > > register it with Elasticsearch since I encounter a SearchParseException  
> > > > > which says  
> > > > > "No query parser registered for ... "
> > > > > 
> > > > > How do I go about doing this?
> > > > > 
> > > > > Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:22am UTC](https://discuss.elastic.co/t/registering-a-custom-query-builder/3045/7 "2017-07-06T04:22:49Z")

</div>


