[[java-query-dsl-span-near-query]]
==== Span Near Query
See {ref}/query-dsl-span-near-query.html[Span Near Query]
[source,java]
--------------------------------------------------
QueryBuilder qb = spanNearQuery(
spanTermQuery("field","value1"), <1>
12) <2>
.addClause(spanTermQuery("field","value2")) <1>
.addClause(spanTermQuery("field","value3")) <1>
.inOrder(false); <3>
<1> span term queries
<2> slop factor: the maximum number of intervening unmatched positions
<3> whether matches are required to be in-order