# Problem with span\_or

**URL:** <https://discuss.elastic.co/t/problem-with-span-or/4626>\
**Category:** Elasticsearch\
**Created:** [June 15, 2011, 9:21am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626 "2011-06-15T09:21:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![melix](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@melix](https://discuss.elastic.co/u/melix)\
**Post date:** [June 15, 2011, 9:21am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/1 "2011-06-15T09:21:24Z")

</div>

Hi,

I am using the Java query builder API to generate complex queries. One of my generated queries is a span\_or query which looks like this :

{  
"query" : {  
"span\_or" : {  
"clauses" : [  
{  
"span\_term" : {  
"title" : {  
"value" : "java",  
"boost" : 1.0  
}  
}  
},  
{  
"span\_term" : {  
"title" : {  
"value" : "javas",  
"boost" : 1.0  
}  
}  
}  
]  
}  
},  
"fields" : ["vid", "title"]  
}

However, when the query is executed, I receive this error :

QueryParsingException[[leastic] spanOr must include [clauses]]

I find it awkward as the JSON query is automatically generated and that it does include a "clauses" field. Am I missing something obvious ?

I'm using ES 0.16.2.

Thanks a lot,

---

<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 15, 2011, 9:35am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/2 "2011-06-15T09:35:07Z")

</div>

Can you gist a recreation?

On Wednesday, June 15, 2011 at 12:21 PM, melix wrote:

> Hi,
> 
> I am using the Java query builder API to generate complex queries. One of my  
> generated queries is a span\_or query which looks like this :
> 
> {  
> "query" : {  
> "span\_or" : {  
> "clauses" : [  
> {  
> "span\_term" : {  
> "title" : {  
> ""value" : "java",  
> "boost" : 1.0  
> }  
> }  
> }},  
> {  
> "span\_term" : {  
> "title" : {  
> ""value" : "javas",  
> "boost" : 1.0  
> }  
> }  
> }  
> ]  
> }  
> },  
> ""fields" : ["vid", "title"]  
> }
> 
> However, when the query is executed, I receive this error :
> 
> QueryParsingException[[leastic] spanOr must include [clauses]]
> 
> I find it awkward as the JSON query is automatically generated and that it  
> does include a "clauses" field. Am I missing something obvious ?
> 
> I'm using ES 0.16.2.
> 
> Thanks a lot,
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com) ([http://Nabble.com](http://Nabble.com)).

---

<div class="post-metadata">

**Author:** ![melix](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@melix](https://discuss.elastic.co/u/melix)\
**Post date:** [June 15, 2011, 9:47am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/3 "2011-06-15T09:47:08Z")

</div>

Here it is : [Throws a parse error when query gets executed · GitHub](https://gist.github.com/1026809)

Le 15/06/2011 11:35, Shay Banon a Ã©crit :

> Can you gist a recreation?
> 
> On Wednesday, June 15, 2011 at 12:21 PM, melix wrote:
> 
> > Hi,
> > 
> > I am using the Java query builder API to generate complex queries.  
> > One of my  
> > generated queries is a span\_or query which looks like this :
> > 
> > {  
> > "query" : {  
> > "span\_or" : {  
> > "clauses" : [  
> > {  
> > "span\_term" : {  
> > "title" : {  
> > ""value" : "java",  
> > "boost" : 1.0  
> > }  
> > }  
> > }}},  
> > {  
> > "span\_term" : {  
> > "title" : {  
> > """value" : "javas",  
> > ""boost" : 1.0  
> > }  
> > }}  
> > }  
> > ]  
> > }  
> > },  
> > ""fields" : ["vid", "title"]  
> > }
> > 
> > However, when the query is executed, I receive this error :
> > 
> > QueryParsingException[[leastic] spanOr must include [clauses]]
> > 
> > I find it awkward as the JSON query is automatically generated and  
> > that it  
> > does include a "clauses" field. Am I missing something obvious ?
> > 
> > I'm using ES 0.16.2.
> > 
> > Thanks a lot,
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com)  
> > [http://Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![melix](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@melix](https://discuss.elastic.co/u/melix)\
**Post date:** [June 15, 2011, 10:03am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/4 "2011-06-15T10:03:38Z")

</div>

I just noticed that removing "boost" solves the problem.

Le 15/06/2011 11:47, CÃ©dric Champeau a Ã©crit :

> Here it is : [Throws a parse error when query gets executed · GitHub](https://gist.github.com/1026809)
> 
> Le 15/06/2011 11:35, Shay Banon a Ã©crit :
> 
> > Can you gist a recreation?
> > 
> > On Wednesday, June 15, 2011 at 12:21 PM, melix wrote:
> > 
> > > Hi,
> > > 
> > > I am using the Java query builder API to generate complex queries.  
> > > One of my  
> > > generated queries is a span\_or query which looks like this :
> > > 
> > > {  
> > > "query" : {  
> > > "span\_or" : {  
> > > "clauses" : [  
> > > {  
> > > "span\_term" : {  
> > > "title" : {  
> > > ""value" : "java",  
> > > "boost" : 1.0  
> > > }  
> > > }  
> > > }}},  
> > > {  
> > > "span\_term" : {  
> > > "title" : {  
> > > """value" : "javas",  
> > > ""boost" : 1.0  
> > > }  
> > > }}  
> > > }  
> > > ]  
> > > }  
> > > },  
> > > ""fields" : ["vid", "title"]  
> > > }
> > > 
> > > However, when the query is executed, I receive this error :
> > > 
> > > QueryParsingException[[leastic] spanOr must include [clauses]]
> > > 
> > > I find it awkward as the JSON query is automatically generated and  
> > > that it  
> > > does include a "clauses" field. Am I missing something obvious ?
> > > 
> > > I'm using ES 0.16.2.
> > > 
> > > Thanks a lot,
> > > 
> > > --  
> > > View this message in context:  
> > > [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html)  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com)  
> > > [http://Nabble.com](http://Nabble.com).

---

<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 15, 2011, 10:13am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/5 "2011-06-15T10:13:10Z")

</div>

Yea, its a problem with span term query when providing boost. Fixed here: [Query DSL: Span Term Query wrongly parses when boost is provided, causing using it in span or to fail · Issue #1032 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1032).

On Wednesday, June 15, 2011 at 1:03 PM, Cédric Champeau wrote:

> I just noticed that removing "boost" solves the problem.
> 
> Le 15/06/2011 11:47, Cédric Champeau a écrit :
> 
> > Here it is : [Throws a parse error when query gets executed · GitHub](https://gist.github.com/1026809)
> > 
> > Le 15/06/2011 11:35, Shay Banon a écrit :
> > 
> > > Can you gist a recreation?
> > > 
> > > On Wednesday, June 15, 2011 at 12:21 PM, melix wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I am using the Java query builder API to generate complex queries. One of my  
> > > > generated queries is a span\_or query which looks like this :
> > > > 
> > > > {  
> > > > "query" : {  
> > > > "span\_or" : {  
> > > > "clauses" : [  
> > > > {  
> > > > "span\_term" : {  
> > > > "title" : {  
> > > > ""value" : "java",  
> > > > "boost" : 1.0  
> > > > }  
> > > > }  
> > > > }}},  
> > > > {  
> > > > "span\_term" : {  
> > > > "title" : {  
> > > > """value" : "javas",  
> > > > ""boost" : 1.0  
> > > > }  
> > > > }}  
> > > > }  
> > > > ]  
> > > > }  
> > > > },  
> > > > ""fields" : ["vid", "title"]  
> > > > }
> > > > 
> > > > However, when the query is executed, I receive this error :
> > > > 
> > > > QueryParsingException[[leastic] spanOr must include [clauses]]
> > > > 
> > > > I find it awkward as the JSON query is automatically generated and that it  
> > > > does include a "clauses" field. Am I missing something obvious ?
> > > > 
> > > > I'm using ES 0.16.2.
> > > > 
> > > > Thanks a lot,
> > > > 
> > > > --  
> > > > View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-span-or-tp3066599p3066599.html)  
> > > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com) ([http://Nabble.com](http://Nabble.com)).

---

<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:03am UTC](https://discuss.elastic.co/t/problem-with-span-or/4626/6 "2017-07-06T04:03:32Z")

</div>


