Using span query for different fields - i.e., this field or that field for span query

I think I've figured out how to search for a particular user query using span, except I'd like to run an OR query for the stemmed and non-stemmed version of the field.
The query I'm trying to satisfy is: phraseWord1 phraseWord2 /50 (word1 OR word2).
So, I can search the non-stemmed (or stemmed) field doing this:
{
"span_near" : {
"clauses" : [
{
"span_near" : {
"clauses" : [
{ "span_term" : { "field" : "phraseWord1" } },
{ "span_term" : { "field" : "phraseWord2" } }
],
"slop" : 0,
"in_order" : true
}
},
{
"span_or" : {
"clauses" : [
{ "span_term" : { "field" : "word1" } },
{ "span_term" : { "field" : "word2" } }
]
}
}
],
"slop" : 50,
"in_order" : false
}
}

However, I can't figure out how to OR this with the exact same span query for "field.stemmed" instead of "field". I tried to use "span_or" for this, but apparently it wouldn't let me combine the two queries (one in "field" and the other in "field.stemmed") because I get an error saying that:
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Clauses must have same field."

Thanks for any direction, I'd appreciate it... Still learning...

I think I figured it out using field_masking_span. Let me know if that's not what I should use...

{
"span_or" : {
"clauses" : [
{
"span_near" : {
"clauses" : [
{
"span_near" : {
"clauses" : [
{ "span_term" : { "doc.body" : "ipse" } },
{ "span_term" : { "doc.body" : "dixit" } }
],
"slop" : 0,
"in_order" : true
}
},
{
"span_or" : {
"clauses" : [
{ "span_term" : { "doc.body" : "clear" } },
{ "span_term" : { "doc.body" : "clearly" } }
]
}
}
],
"slop" : 50,
"in_order" : false
}
},
{
"field_masking_span": {
"query":
{
"span_near" : {
"clauses" : [
{
"field_masking_span": {
"query":
{
"span_near" : {
"clauses" : [
{ "span_term" : { "doc.body.stemmed" : "ipse" } },
{ "span_term" : { "doc.body.stemmed" : "dixit" } }
],
"slop" : 0,
"in_order" : true
}
},
"field": "doc.body"
}
},
{
"field_masking_span": {
"query":
{
"span_or" : {
"clauses" : [
{ "span_term" : { "doc.body.stemmed" : "clear" } },
{ "span_term" : { "doc.body.stemmed" : "clearly" } }
]
}
},
"field": "doc.body"
}
}],
"slop" : 50,
"in_order" : false
}
},
"field": "doc.body"
}
}]
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.