You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In `SearchOperations`, and so in `ElasticsearchOperations` as well, the `suggest` methods taking a `org.elasticsearch.search.suggest.SuggestBuilder` as argument and returning a `org.elasticsearch.action.search.SearchResponse` have been deprecated.
27
+
Use `SearchHits<T> search(Query query, Class<T> clazz)` instead, passing in a `NativeSearchQuery` which can contain a `SuggestBuilder` and read the suggest results from the returned `SearchHit<T>`.
28
+
29
+
In `ReactiveSearchOperations` the new `suggest` methods return a `Mono<org.springframework.data.elasticsearch.core.suggest.response.Suggest>` now.
@@ -59,3 +67,7 @@ Some properties of the `org.springframework.data.elasticsearch.core.query.BulkOp
59
67
=== IndicesOptions change
60
68
61
69
Spring Data Elasticsearch now uses `org.springframework.data.elasticsearch.core.query.IndicesOptions` instead of `org.elasticsearch.action.support.IndicesOptions`.
70
+
71
+
=== Completion classes
72
+
73
+
The classes from the package `org.springframework.data.elasticsearch.core.completion` have been moved to `org.springframework.data.elasticsearch.core.suggest`.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-operations.adoc
+16-11
Original file line number
Diff line number
Diff line change
@@ -20,11 +20,11 @@ The default implementations of the interfaces offer:
20
20
[NOTE]
21
21
====
22
22
.Index management and automatic creation of indices and mappings.
23
+
The `IndexOperations` interface and the provided implementation which can be obtained from an `ElasticsearchOperations` instance - for example with a call to `operations.indexOps(clazz)`- give the user the ability to create indices, put mappings or store template and alias information in the Elasticsearch cluster.
24
+
Details of the index that will be created can be set by using the `@Setting` annotation, refer to <<elasticsearc.misc.index.settings>> for further information.
23
25
24
-
The `IndexOperations` interface and the provided implementation which can be obtained from an `ElasticsearchOperations` instance - for example with a call to `operations.indexOps(clazz)`- give the user the ability to create indices, put mappings or store template and alias information in the Elasticsearch cluster. Details of the index that will be created
25
-
can be set by using the `@Setting` annotation, refer to <<elasticsearc.misc.index.settings>> for further information.
26
-
27
-
**None of these operations are done automatically** by the implementations of `IndexOperations` or `ElasticsearchOperations`. It is the user's responsibility to call the methods.
26
+
**None of these operations are done automatically** by the implementations of `IndexOperations` or `ElasticsearchOperations`.
27
+
It is the user's responsibility to call the methods.
28
28
29
29
There is support for automatic creation of indices and writing the mappings when using Spring Data Elasticsearch repositories, see <<elasticsearch.repositories.autocreation>>
30
30
@@ -58,6 +58,7 @@ public class TransportClientConfig extends ElasticsearchConfigurationSupport {
58
58
}
59
59
}
60
60
----
61
+
61
62
<1> Setting up the <<elasticsearch.clients.transport>>.
62
63
Deprecated as of version 4.0.
63
64
<2> Creating the `ElasticsearchTemplate` bean, offering both names, _elasticsearchOperations_ and _elasticsearchTemplate_.
@@ -82,6 +83,7 @@ public class RestClientConfig extends AbstractElasticsearchConfiguration {
82
83
// no special bean creation needed <2>
83
84
}
84
85
----
86
+
85
87
<1> Setting up the <<elasticsearch.clients.rest>>.
86
88
<2> The base class `AbstractElasticsearchConfiguration` already provides the `elasticsearchTemplate` bean.
87
89
====
@@ -127,6 +129,7 @@ public class TestController {
127
129
}
128
130
129
131
----
132
+
130
133
<1> Let Spring inject the provided `ElasticsearchOperations` bean in the constructor.
131
134
<2> Store some entity in the Elasticsearch cluster.
132
135
<3> Retrieve the entity with a query by id.
@@ -164,6 +167,7 @@ Contains the following information:
164
167
* Maximum score
165
168
* A list of `SearchHit<T>` objects
166
169
* Returned aggregations
170
+
* Returned suggest results
167
171
168
172
.SearchPage<T>
169
173
Defines a Spring Data `Page` that contains a `SearchHits<T>` element and can be used for paging access using repository methods.
@@ -182,12 +186,12 @@ Almost all of the methods defined in the `SearchOperations` and `ReactiveSearchO
182
186
[[elasticsearch.operations.criteriaquery]]
183
187
=== CriteriaQuery
184
188
185
-
`CriteriaQuery` based queries allow the creation of queries to search for data without knowing the syntax or basics of Elasticsearch queries. They allow the user to build queries by simply chaining and combining `Criteria` objects that specifiy the criteria the searched documents must fulfill.
189
+
`CriteriaQuery` based queries allow the creation of queries to search for data without knowing the syntax or basics of Elasticsearch queries.
190
+
They allow the user to build queries by simply chaining and combining `Criteria` objects that specifiy the criteria the searched documents must fulfill.
186
191
187
192
NOTE: when talking about AND or OR when combining criteria keep in mind, that in Elasticsearch AND are converted to a **must** condition and OR to a **should**
188
193
189
-
`Criteria` and their usage are best explained by example
190
-
(let's assume we have a `Book` entity with a `price` property):
194
+
`Criteria` and their usage are best explained by example (let's assume we have a `Book` entity with a `price` property):
191
195
192
196
.Get books with a given price
193
197
====
@@ -211,19 +215,21 @@ Query query = new CriteriaQuery(criteria);
211
215
212
216
When chaining `Criteria`, by default a AND logic is used:
213
217
214
-
.Get all persons with first name _James_ and last name _Miller_:
218
+
.Get all persons with first name _James_ and last name _Miller_:
215
219
====
216
220
[source,java]
217
221
----
218
222
Criteria criteria = new Criteria("lastname").is("Miller") <1>
219
223
.and("firstname").is("James") <2>
220
224
Query query = new CriteriaQuery(criteria);
221
225
----
226
+
222
227
<1> the first `Criteria`
223
228
<2> the and() creates a new `Criteria` and chaines it to the first one.
224
229
====
225
230
226
-
If you want to create nested queries, you need to use subqueries for this. Let's assume we want to find all persons with a last name of _Miller_ and a first name of either _Jack_ or _John_:
231
+
If you want to create nested queries, you need to use subqueries for this.
232
+
Let's assume we want to find all persons with a last name of _Miller_ and a first name of either _Jack_ or _John_:
227
233
228
234
.Nested subqueries
229
235
====
@@ -236,6 +242,7 @@ Criteria miller = new Criteria("lastName").is("Miller") <.>
236
242
);
237
243
Query query = new CriteriaQuery(criteria);
238
244
----
245
+
239
246
<.> create a first `Criteria` for the last name
240
247
<.> this is combined with AND to a subCriteria
241
248
<.> This sub Criteria is an OR combination for the first name _John_
@@ -281,5 +288,3 @@ Query query = new NativeSearchQueryBuilder()
0 commit comments