2015-06-24 17:27:19 -04:00
|
|
|
[[java-query-dsl]]
|
|
|
|
== Query DSL
|
|
|
|
|
|
|
|
Elasticsearch provides a full Java query dsl in a similar manner to the
|
|
|
|
REST {ref}/query-dsl.html[Query DSL]. The factory for query
|
|
|
|
builders is `QueryBuilders`. Once your query is ready, you can use the
|
|
|
|
<<java-search,Search API>>.
|
|
|
|
|
|
|
|
To use `QueryBuilders` just import them in your class:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Note that you can easily print (aka debug) JSON generated queries using
|
|
|
|
`toString()` method on `QueryBuilder` object.
|
|
|
|
|
|
|
|
The `QueryBuilder` can then be used with any API that accepts a query,
|
|
|
|
such as `count` and `search`.
|
|
|
|
|
2017-05-02 13:00:56 -04:00
|
|
|
:query-dsl-test: {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java
|
|
|
|
|
2015-06-24 17:27:19 -04:00
|
|
|
include::query-dsl/match-all-query.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/full-text-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/term-level-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/compound-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/joining-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/geo-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/special-queries.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/span-queries.asciidoc[]
|
|
|
|
|
2017-05-02 13:00:56 -04:00
|
|
|
:query-dsl-test!:
|