[[java-query-dsl-span-within-query]]
==== Span Within Query

See {ref}/query-dsl-span-within-query.html[Span Within Query]

[source,java]
--------------------------------------------------
QueryBuilder qb = spanWithinQuery(
    spanNearQuery(spanTermQuery("field1", "bar"), 5) <1>
        .addClause(spanTermQuery("field1", "baz"))
        .inOrder(true),
    spanTermQuery("field1", "foo"));                 <2>
--------------------------------------------------
<1> `big` part
<2> `little` part