Span Within query
More info about Boosting query is in the official elasticsearch docs
Returns matches which are enclosed inside another span query.
{
"span_within" : {
"little" : {
"span_term" : { "field1" : "foo" }
},
"big" : {
"span_near" : {
"clauses" : [
{ "span_term" : { "field1" : "bar" } },
{ "span_term" : { "field1" : "baz" } }
],
"slop" : 5,
"in_order" : true
}
}
}
}
And now the query via DSL:
$spanTermQuery = new SpanTermQuery('field1', 'foo');
$spanNearQuery = new SpanNearQuery();
$spanNearQuery->setSlop(5);
$spanNearQuery->addParameter('in_order', true);
$spanNearQuery->addQuery(new SpanTermQuery('field1', 'bar'));
$spanNearQuery->addQuery(new SpanTermQuery('field1', 'baz'));
$spanWithinQuery = new SpanWithinQuery(
$spanTermQuery,
$spanNearQuery
);
$search = new Search();
$search->addQuery($spanWithinQuery);
$queryArray = $search->toArray();