mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
732741dd8d
We've had `QueryDSLDocumentationTests` for a while but it had a very hopeful comment at the top about how we want to make sure that the example in the query-dsl docs match up with the test but we never had anything that made *sure* that they did. This changes that! Now the examples from the query-dsl docs are all built from the `QueryDSLDocumentationTests`. All except for the percolator example because that is hard to do as it stands now. To make this easier this change moves `QueryDSLDocumentationTests` from core and into the high level rest client. This is useful for two reasons: 1. We expect the high level rest client to be able to use the builders. 2. The code that builds that docs doesn't check out all of Elasticsearch. It only checks out certain directories. Since we're already including snippets from that directory we don't have to make any changes to that process. Closes #24320
41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
[[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`.
|
|
|
|
:query-dsl-test: {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java
|
|
|
|
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[]
|
|
|
|
:query-dsl-test!:
|