[[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() .clause(spanTermQuery("field","value1")) <1> .clause(spanTermQuery("field","value2")) <1> .clause(spanTermQuery("field","value3")) <1> .slop(12) <2> .inOrder(false) <3> .collectPayloads(false); <4> -------------------------------------------------- <1> span term queries <2> slop factor: the maximum number of intervening unmatched positions <3> whether matches are required to be in-order <4> collect payloads or not