# Query DSL

**URL:** <https://discuss.elastic.co/t/query-dsl/3041>\
**Category:** Elasticsearch\
**Created:** [June 25, 2010, 2:41pm UTC](https://discuss.elastic.co/t/query-dsl/3041 "2010-06-25T14:41:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedric/32/3335_2.png) [@Cedric](https://discuss.elastic.co/u/Cedric)\
**Post date:** [June 25, 2010, 2:41pm UTC](https://discuss.elastic.co/t/query-dsl/3041/1 "2010-06-25T14:41:05Z")

</div>

Hi,

First of all, I'd like to say I'm really impressed with what you've  
done with ElasticSearch. Definitely looks like a Solr killer. Using it  
with Groovy is really neat. However, I have a question about the query  
DSL : is there any plan to integrate span queries (or is it just  
undocumented) ?

BTW, is there any developer documentation about writing plugins ?  
Specifically, I think I'll have to integrate custom analyzers. I will  
certainly take a look at the ICU plugin source but an overview would  
be great.

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 25, 2010, 6:40pm UTC](https://discuss.elastic.co/t/query-dsl/3041/2 "2010-06-25T18:40:04Z")

</div>

There is support for span queries already, I just haven't got around to  
document it... (its in 0.8). Can you open an issue so I will doc them (just  
so I won't forget about them again 😉 ).

Regarding writing plugins, there is no docs yet, though you don't have to  
write a plugin to provide custom analyzers, though you will need to write  
some custom code for that, which might as well be in the form of plugins.  
The ICU plugin is a good place to see how to write custom analyzers plugin,  
and I would love help in documenting it on the github wiki.

-shay.banon

On Fri, Jun 25, 2010 at 5:41 PM, Cédric [cedric.champeau@gmail.com](mailto:cedric.champeau@gmail.com) wrote:

> Hi,
> 
> First of all, I'd like to say I'm really impressed with what you've  
> done with Elasticsearch. Definitely looks like a Solr killer. Using it  
> with Groovy is really neat. However, I have a question about the query  
> DSL : is there any plan to integrate span queries (or is it just  
> undocumented) ?
> 
> BTW, is there any developer documentation about writing plugins ?  
> Specifically, I think I'll have to integrate custom analyzers. I will  
> certainly take a look at the ICU plugin source but an overview would  
> be great.
> 
> 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 25, 2010, 7:13pm UTC](https://discuss.elastic.co/t/query-dsl/3041/3 "2010-06-25T19:13:09Z")

</div>

No need for an issue regarding span queries, just documented them:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/).

On Fri, Jun 25, 2010 at 9:40 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> There is support for span queries already, I just haven't got around to  
> document it... (its in 0.8). Can you open an issue so I will doc them (just  
> so I won't forget about them again 😉 ).
> 
> Regarding writing plugins, there is no docs yet, though you don't have to  
> write a plugin to provide custom analyzers, though you will need to write  
> some custom code for that, which might as well be in the form of plugins.  
> The ICU plugin is a good place to see how to write custom analyzers plugin,  
> and I would love help in documenting it on the github wiki.
> 
> -shay.banon
> 
> On Fri, Jun 25, 2010 at 5:41 PM, Cédric [cedric.champeau@gmail.com](mailto:cedric.champeau@gmail.com) wrote:
> 
> > Hi,
> > 
> > First of all, I'd like to say I'm really impressed with what you've  
> > done with Elasticsearch. Definitely looks like a Solr killer. Using it  
> > with Groovy is really neat. However, I have a question about the query  
> > DSL : is there any plan to integrate span queries (or is it just  
> > undocumented) ?
> > 
> > BTW, is there any developer documentation about writing plugins ?  
> > Specifically, I think I'll have to integrate custom analyzers. I will  
> > certainly take a look at the ICU plugin source but an overview would  
> > be great.
> > 
> > Thanks,

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedric/32/3335_2.png) [@Cedric](https://discuss.elastic.co/u/Cedric)\
**Post date:** [June 28, 2010, 10:50am UTC](https://discuss.elastic.co/t/query-dsl/3041/4 "2010-06-28T10:50:49Z")

</div>

Nice, I'll take a look. Thanks.

On 25 juin, 20:40, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> There is support for span queries already, I just haven't got around to  
> document it... (its in 0.8). Can you open an issue so I will doc them (just  
> so I won't forget about them again 😉 ).
> 
> Regarding writing plugins, there is no docs yet, though you don't have to  
> write a plugin to provide custom analyzers, though you will need to write  
> some custom code for that, which might as well be in the form of plugins.  
> The ICU plugin is a good place to see how to write custom analyzers plugin,  
> and I would love help in documenting it on the github wiki.
> 
> -shay.banon
> 
> On Fri, Jun 25, 2010 at 5:41 PM, Cédric [cedric.champ...@gmail.com](mailto:cedric.champ...@gmail.com) wrote:
> 
> > Hi,
> 
> > First of all, I'd like to say I'm really impressed with what you've  
> > done with Elasticsearch. Definitely looks like a Solr killer. Using it  
> > with Groovy is really neat. However, I have a question about the query  
> > DSL : is there any plan to integrate span queries (or is it just  
> > undocumented) ?
> 
> > BTW, is there any developer documentation about writing plugins ?  
> > Specifically, I think I'll have to integrate custom analyzers. I will  
> > certainly take a look at the ICU plugin source but an overview would  
> > be great.
> 
> > Thanks,

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedric/32/3335_2.png) [@Cedric](https://discuss.elastic.co/u/Cedric)\
**Post date:** [June 29, 2010, 8:03am UTC](https://discuss.elastic.co/t/query-dsl/3041/5 "2010-06-29T08:03:37Z")

</div>

Hi again,

I'm having troubles with the Groovy API. There must be something I  
don't write correctly, because the span\_term items are null when I  
inspect the generated query (the clauses list contains two null  
elements). Have you got an idea of where I'm wrong ?

def search = searchService.client.search {  
indices "test"  
types "validation"  
source {  
size = 100  
query {  
span\_near {  
clauses = [  
span\_term(topic: "term1"),  
span\_term(topic: "term2")  
]  
slop = 2  
in\_order = true  
}  
}  
}  
}

Thanks !

On 25 juin, 20:40, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> There is support for span queries already, I just haven't got around to  
> document it... (its in 0.8). Can you open an issue so I will doc them (just  
> so I won't forget about them again 😉 ).
> 
> Regarding writing plugins, there is no docs yet, though you don't have to  
> write a plugin to provide custom analyzers, though you will need to write  
> some custom code for that, which might as well be in the form of plugins.  
> The ICU plugin is a good place to see how to write custom analyzers plugin,  
> and I would love help in documenting it on the github wiki.
> 
> -shay.banon
> 
> On Fri, Jun 25, 2010 at 5:41 PM, Cédric [cedric.champ...@gmail.com](mailto:cedric.champ...@gmail.com) wrote:
> 
> > Hi,
> 
> > First of all, I'd like to say I'm really impressed with what you've  
> > done with Elasticsearch. Definitely looks like a Solr killer. Using it  
> > with Groovy is really neat. However, I have a question about the query  
> > DSL : is there any plan to integrate span queries (or is it just  
> > undocumented) ?
> 
> > BTW, is there any developer documentation about writing plugins ?  
> > Specifically, I think I'll have to integrate custom analyzers. I will  
> > certainly take a look at the ICU plugin source but an overview would  
> > be great.
> 
> > 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, 11:01am UTC](https://discuss.elastic.co/t/query-dsl/3041/6 "2010-06-30T11:01:35Z")

</div>

Ok, finally found the problem for this. Basically, the way it works is that  
the top level closure is simply evaluated as a closure against the  
SearchRequest class. The `source` is special, and its built into json (in an  
optimized manner), which represents the search source.

Building this into json uses the same mechanism grails uses to build json  
(grails JSONBuilder), and its always tricky to understand what it does  
(especially since i am not groovy export ; ). But, I got what you wanted to  
generate a proper json. Below, you can find the way that I tested it, so it  
will be simpler to understand and debug what gets generated at the end (this  
is what the source gets injected with):

```
    def builder = new GXContentBuilder()

    def test = builder.buildAsString {
        size = 100
        query {
            span_near {
                clauses = [
                        { span_term(topic: "term1") },
                        { span_term(topic: "term2") }
                ]
                slop = 2
                in_order = true
            }
        }
    }

    println test

```

Note the above, the space\_term needs to be wrapped with { ... }.

-shay.banon

On Tue, Jun 29, 2010 at 11:03 AM, Cédric [cedric.champeau@gmail.com](mailto:cedric.champeau@gmail.com) wrote:

> Hi again,
> 
> I'm having troubles with the Groovy API. There must be something I  
> don't write correctly, because the span\_term items are null when I  
> inspect the generated query (the clauses list contains two null  
> elements). Have you got an idea of where I'm wrong ?
> 
> def search = searchService.client.search {  
> indices "test"  
> types "validation"  
> source {  
> size = 100  
> query {  
> span\_near {  
> clauses = [
> 
> span\_term(topic: "term1"),
> 
> span\_term(topic: "term2")  
> ]  
> slop = 2  
> in\_order = true  
> }  
> }  
> }  
> }
> 
> Thanks !
> 
> On 25 juin, 20:40, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > There is support for span queries already, I just haven't got around to  
> > document it... (its in 0.8). Can you open an issue so I will doc them  
> > (just  
> > so I won't forget about them again 😉 ).
> > 
> > Regarding writing plugins, there is no docs yet, though you don't have to  
> > write a plugin to provide custom analyzers, though you will need to write  
> > some custom code for that, which might as well be in the form of plugins.  
> > The ICU plugin is a good place to see how to write custom analyzers  
> > plugin,  
> > and I would love help in documenting it on the github wiki.
> > 
> > -shay.banon
> > 
> > On Fri, Jun 25, 2010 at 5:41 PM, Cédric [cedric.champ...@gmail.com](mailto:cedric.champ...@gmail.com)  
> > wrote:
> > 
> > > Hi,
> > 
> > > First of all, I'd like to say I'm really impressed with what you've  
> > > done with Elasticsearch. Definitely looks like a Solr killer. Using it  
> > > with Groovy is really neat. However, I have a question about the query  
> > > DSL : is there any plan to integrate span queries (or is it just  
> > > undocumented) ?
> > 
> > > BTW, is there any developer documentation about writing plugins ?  
> > > Specifically, I think I'll have to integrate custom analyzers. I will  
> > > certainly take a look at the ICU plugin source but an overview would  
> > > be great.
> > 
> > > 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/query-dsl/3041/7 "2017-07-06T04:22:51Z")

</div>


