A couple of span query questions

I'm in the process of trying to understand span queries and am having
running into so problems that I can't find an answer for in the
documentation. I was hoping someone on the group could shed some light.

I have loaded up some documents that have analyzed textual fields and I
have a requirement to support proximity based queries in addition to normal
textual queries. These documents are presented to a user in a search form
with searchable fields that can map to multiple index fields. E.g search
form fieldA maps to field1 and field2 in the index. An example
proximity search might be fieldA(Pain PRE/6 Morphine). Since order is
important, that leads me down the road to a SPAN_NEAR query with "in_order"
set to true. Since term queries don't analyze the text, I need to do that
prior to sending the search down (e.g. Morphine would need to be morphin
with the analyzers we are using on those fields). Doing a single span_near
query on one of the two fields works, but when I try to combine them with a
span_or query as below I get a parse exception

{
"query": {
"span_or": {
"clauses": [
{
"span_near": {
"clauses": [
{
"span_term": {
"field1": "pain"
}
},
{
"span_term": {
"field1": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
},
{
"span_near": {
"clauses": [
{
"span_term": {
"field2": "pain"
}
},
{
"span_term": {
"field2": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
}
]
}
}
}

Gives
{

  • error: SearchPhaseExecutionException[Failed to execute phase [query],
    total failure; shardFailures {[XrFytwobQPOTn2QOInx8jg][hothouse][3]:
    SearchParseException[[hothouse][3]: from[-1],size[-1]: Parse Failure
    [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.];
    }{[XrFytwobQPOTn2QOInx8jg][hothouse][1]:
    SearchParseException[[hothouse][1]: from[-1],size[-1]: Parse Failure
    [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.]; }]
  • status: 500

}

The documentation states the the clauses to a span_or (or any of the span
queries ) must be span_type queries. I assume there is more to it than
this based on the above error?

I also have a follow up question to the above... If I swap out the span_or
w/ clauses for a boolean/should structure, the request above runs (although
I will have issues as I start having to support more complex proximity
queries taking this approach) but I don't get any highlighting back for
the request.. However, if I run the the request using match query of type
phrase with the slop of 6 I do get highlight results. The highlight clause
of the query structure is the same between the two approaches. Is anyone
aware of highlighting issues with span queries?

Thanks for any insights...

Curt

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,
the error that you get back is because all clauses must be related to the
same field, beyond being span_term queries. In your case you are referring
to both field1 and field2. Span queries can be complex but always need to
stay on the same field.

There might be issues while highlighting when using span queries in lucene,
depending on the highlighter type you're using. Plain highlighter of fast
vector highlighter?

On Monday, September 9, 2013 6:34:15 PM UTC+2, Curt Kohler wrote:

I'm in the process of trying to understand span queries and am having
running into so problems that I can't find an answer for in the
documentation. I was hoping someone on the group could shed some light.

I have loaded up some documents that have analyzed textual fields and I
have a requirement to support proximity based queries in addition to normal
textual queries. These documents are presented to a user in a search form
with searchable fields that can map to multiple index fields. E.g search
form fieldA maps to field1 and field2 in the index. An example
proximity search might be fieldA(Pain PRE/6 Morphine). Since order is
important, that leads me down the road to a SPAN_NEAR query with "in_order"
set to true. Since term queries don't analyze the text, I need to do that
prior to sending the search down (e.g. Morphine would need to be morphin
with the analyzers we are using on those fields). Doing a single span_near
query on one of the two fields works, but when I try to combine them with a
span_or query as below I get a parse exception

{
"query": {
"span_or": {
"clauses": [
{
"span_near": {
"clauses": [
{
"span_term": {
"field1": "pain"
}
},
{
"span_term": {
"field1": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
},
{
"span_near": {
"clauses": [
{
"span_term": {
"field2": "pain"
}
},
{
"span_term": {
"field2": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
}
]
}
}
}

Gives
{

  • error: SearchPhaseExecutionException[Failed to execute phase
    [query], total failure; shardFailures
    {[XrFytwobQPOTn2QOInx8jg][hothouse][3]: SearchParseException[[hothouse][3]:
    from[-1],size[-1]: Parse Failure [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.];
    }{[XrFytwobQPOTn2QOInx8jg][hothouse][1]:
    SearchParseException[[hothouse][1]: from[-1],size[-1]: Parse Failure
    [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.]; }]
  • status: 500

}

The documentation states the the clauses to a span_or (or any of the span
queries ) must be span_type queries. I assume there is more to it than
this based on the above error?

I also have a follow up question to the above... If I swap out the
span_or w/ clauses for a boolean/should structure, the request above runs
(although I will have issues as I start having to support more complex
proximity queries taking this approach) but I don't get any highlighting
back for the request.. However, if I run the the request using match query
of type phrase with the slop of 6 I do get highlight results. The highlight
clause of the query structure is the same between the two approaches. Is
anyone aware of highlighting issues with span queries?

Thanks for any insights...

Curt

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for the quick reply Luca,

As to your follow up question regarding highlighting, I'm using the fast
vector highlighter in both cases..

Curt

On Monday, September 9, 2013 12:47:45 PM UTC-4, Luca Cavanna wrote:

Hi,
the error that you get back is because all clauses must be related to the
same field, beyond being span_term queries. In your case you are referring
to both field1 and field2. Span queries can be complex but always need to
stay on the same field.

There might be issues while highlighting when using span queries in
lucene, depending on the highlighter type you're using. Plain highlighter
of fast vector highlighter?

On Monday, September 9, 2013 6:34:15 PM UTC+2, Curt Kohler wrote:

I'm in the process of trying to understand span queries and am having
running into so problems that I can't find an answer for in the
documentation. I was hoping someone on the group could shed some light.

I have loaded up some documents that have analyzed textual fields and I
have a requirement to support proximity based queries in addition to normal
textual queries. These documents are presented to a user in a search form
with searchable fields that can map to multiple index fields. E.g search
form fieldA maps to field1 and field2 in the index. An example
proximity search might be fieldA(Pain PRE/6 Morphine). Since order is
important, that leads me down the road to a SPAN_NEAR query with "in_order"
set to true. Since term queries don't analyze the text, I need to do that
prior to sending the search down (e.g. Morphine would need to be morphin
with the analyzers we are using on those fields). Doing a single span_near
query on one of the two fields works, but when I try to combine them with a
span_or query as below I get a parse exception

{
"query": {
"span_or": {
"clauses": [
{
"span_near": {
"clauses": [
{
"span_term": {
"field1": "pain"
}
},
{
"span_term": {
"field1": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
},
{
"span_near": {
"clauses": [
{
"span_term": {
"field2": "pain"
}
},
{
"span_term": {
"field2": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
}
]
}
}
}

Gives
{

  • error: SearchPhaseExecutionException[Failed to execute phase
    [query], total failure; shardFailures
    {[XrFytwobQPOTn2QOInx8jg][hothouse][3]: SearchParseException[[hothouse][3]:
    from[-1],size[-1]: Parse Failure [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.];
    }{[XrFytwobQPOTn2QOInx8jg][hothouse][1]:
    SearchParseException[[hothouse][1]: from[-1],size[-1]: Parse Failure
    [Failed to parse source
    [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]];
    nested: IllegalArgumentException[Clauses must have same field.]; }]
  • status: 500

}

The documentation states the the clauses to a span_or (or any of the span
queries ) must be span_type queries. I assume there is more to it than
this based on the above error?

I also have a follow up question to the above... If I swap out the
span_or w/ clauses for a boolean/should structure, the request above runs
(although I will have issues as I start having to support more complex
proximity queries taking this approach) but I don't get any highlighting
back for the request.. However, if I run the the request using match query
of type phrase with the slop of 6 I do get highlight results. The highlight
clause of the query structure is the same between the two approaches. Is
anyone aware of highlighting issues with span queries?

Thanks for any insights...

Curt

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Curt,
do you mid giving a try to the plain highlighter with the same queries and see what happens?

You can force the use of the plain one even though you stored term vectors by using "type":"plain" in your highlight json object.

On 9 Sep 2013, at 19:11, Curt Kohler c.kohler@elsevier.com wrote:

Thanks for the quick reply Luca,

As to your follow up question regarding highlighting, I'm using the fast vector highlighter in both cases..

Curt

On Monday, September 9, 2013 12:47:45 PM UTC-4, Luca Cavanna wrote:

Hi,
the error that you get back is because all clauses must be related to the same field, beyond being span_term queries. In your case you are referring to both field1 and field2. Span queries can be complex but always need to stay on the same field.

There might be issues while highlighting when using span queries in lucene, depending on the highlighter type you're using. Plain highlighter of fast vector highlighter?

On Monday, September 9, 2013 6:34:15 PM UTC+2, Curt Kohler wrote:

I'm in the process of trying to understand span queries and am having running into so problems that I can't find an answer for in the documentation. I was hoping someone on the group could shed some light.

I have loaded up some documents that have analyzed textual fields and I have a requirement to support proximity based queries in addition to normal textual queries. These documents are presented to a user in a search form with searchable fields that can map to multiple index fields. E.g search form fieldA maps to field1 and field2 in the index. An example proximity search might be fieldA(Pain PRE/6 Morphine). Since order is important, that leads me down the road to a SPAN_NEAR query with "in_order" set to true. Since term queries don't analyze the text, I need to do that prior to sending the search down (e.g. Morphine would need to be morphin with the analyzers we are using on those fields). Doing a single span_near query on one of the two fields works, but when I try to combine them with a span_or query as below I get a parse exception

{
"query": {
"span_or": {
"clauses": [
{
"span_near": {
"clauses": [
{
"span_term": {
"field1": "pain"
}
},
{
"span_term": {
"field1": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
},
{
"span_near": {
"clauses": [
{
"span_term": {
"field2": "pain"
}
},
{
"span_term": {
"field2": "morphin"
}
}
],
"slop": 6,
"in_order": true
}
}
]
}
}
}

Gives
{
error: SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[XrFytwobQPOTn2QOInx8jg][hothouse][3]: SearchParseException[[hothouse][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]]; nested: IllegalArgumentException[Clauses must have same field.]; }{[XrFytwobQPOTn2QOInx8jg][hothouse][1]: SearchParseException[[hothouse][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"span_or":{"clauses":[{"span_near":{"clauses":[{"span_term":{"field1":"pain"}},{"span_term":{"field1":"morphin"}}],"slop":6,"in_order":true}},{"span_near":{"clauses":[{"span_term":{"field2":"pain"}},{"span_term":{"field2":"morphin"}}],"slop":6,"in_order":true}}]}}}]]]; nested: IllegalArgumentException[Clauses must have same field.]; }]
status: 500
}

The documentation states the the clauses to a span_or (or any of the span queries ) must be span_type queries. I assume there is more to it than this based on the above error?

I also have a follow up question to the above... If I swap out the span_or w/ clauses for a boolean/should structure, the request above runs (although I will have issues as I start having to support more complex proximity queries taking this approach) but I don't get any highlighting back for the request.. However, if I run the the request using match query of type phrase with the slop of 6 I do get highlight results. The highlight clause of the query structure is the same between the two approaches. Is anyone aware of highlighting issues with span queries?

Thanks for any insights...

Curt

--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/daTQwlBMDIE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.