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
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-clients.adoc
+1-1
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Spring Data Elasticsearch operates upon an Elasticsearch client that is connecte
8
8
[[elasticsearch.clients.transport]]
9
9
== Transport Client
10
10
11
-
WARNING: The well known `TransportClient` is deprecated as of Elasticsearch 7 and will be removed in Elasticsearch 8. (https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html[see the Elasticsearch documentation]). Spring Data Elasticsearch will support the `TransportClient` as long as it is available in the used
11
+
WARNING: The `TransportClient` is deprecated as of Elasticsearch 7 and will be removed in Elasticsearch 8. (https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html[see the Elasticsearch documentation]). Spring Data Elasticsearch will support the `TransportClient` as long as it is available in the used
12
12
Elasticsearch <<elasticsearch.versions,version>> but has deprecated the classes using it since version 4.0.
13
13
14
14
We strongly recommend to use the <<elasticsearch.clients.rest>> instead of the `TransportClient`.
The parameters of the `@Document` annotation that are relevant for the index settings (`useServerConfiguration`, `shards`. `replicas`, `refreshIntervall` and `indexStoretype`) have been moved to the `@Setting` annotation. Use in `@Document` is still possible but deprecated.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-misc.adoc
+51-1
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,48 @@
4
4
This chapter covers additional support for Elasticsearch operations that cannot be directly accessed via the repository interface.
5
5
It is recommended to add those operations as custom implementation as described in <<repositories.custom-implementations>> .
6
6
7
+
[[elasticsearc.misc.index.settings]]
8
+
== Index settings
9
+
10
+
When creating Elasticsearch indices with Spring Data Elasticsearch different index settings can be defined by using the `@Setting` annotation. The following arguments are available:
11
+
12
+
* `useServerConfiguration` does not send any settings parameters, so the Elasticsearch server configuration determines them.
13
+
* `settingPath` refers to a JSON file defining the settings that must be resolvable in the classpath
14
+
* `shards` the number of shards to use, defaults to _1_
15
+
* `replicas` the number of replicas, defaults to _1_
16
+
* `refreshIntervall`, defaults to _"1s"_
17
+
* `indexStoreType`, defaults to _"fs"_
18
+
19
+
20
+
It is as well possible to define https://www.elastic.co/guide/en/elasticsearch/reference/7.11/index-modules-index-sorting.html[index sorting] (check the linked Elasticsearch documentation for the possible field types and values):
@Field(name = "first_field", type = FieldType.Keyword)
37
+
private String firstField;
38
+
39
+
@Nullable @Field(name = "second_field", type = FieldType.Keyword)
40
+
private String secondField;
41
+
42
+
// getter and setter...
43
+
}
44
+
----
45
+
<.> when defining sort fields, use the name of the Java property (_firstField_), not the name that might be defined for Elasticsearch (_first_field_)
46
+
<.> `sortModes`, `sortOrders` and `sortMissingValues` are optional, but if they are set, the number of entries must match the number of `sortFields` elements
47
+
====
48
+
7
49
[[elasticsearch.misc.filter]]
8
50
== Filter Builder
9
51
@@ -20,7 +62,7 @@ SearchQuery searchQuery = new NativeSearchQueryBuilder()
Elasticsearch has a scroll API for getting big result set in chunks.
32
74
This is internally used by Spring Data Elasticsearch to provide the implementations of the `<T> SearchHitsIterator<T> SearchOperations.searchForStream(Query query, Class<T> clazz, IndexCoordinates index)` method.
33
75
76
+
====
34
77
[source,java]
35
78
----
36
79
IndexCoordinates index = IndexCoordinates.of("sample-index");
@@ -50,9 +93,11 @@ while (stream.hasNext()) {
50
93
51
94
stream.close();
52
95
----
96
+
====
53
97
54
98
There are no methods in the `SearchOperations` API to access the scroll id, if it should be necessary to access this, the following methods of the `ElasticsearchRestTemplate` can be used:
55
99
100
+
====
56
101
[source,java]
57
102
----
58
103
@@ -77,10 +122,12 @@ while (scroll.hasSearchHits()) {
77
122
}
78
123
template.searchScrollClear(scrollId);
79
124
----
125
+
====
80
126
81
127
To use the Scroll API with repository methods, the return type must defined as `Stream` in the Elasticsearch Repository.
82
128
The implementation of the method will then use the scroll methods from the ElasticsearchTemplate.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-object-mapping.adoc
+3-11
Original file line number
Diff line number
Diff line change
@@ -36,14 +36,6 @@ The most important attributes are:
36
36
This can contain a SpEL template expression like `"log-#{T(java.time.LocalDate).now().toString()}"`
37
37
** `type`: [line-through]#the mapping type.
38
38
If not set, the lowercased simple name of the class is used.# (deprecated since version 4.0)
39
-
** `shards`: the number of shards for the index.
40
-
** `replicas`: the number of replicas for the index.
41
-
** `refreshIntervall`: Refresh interval for the index.
42
-
Used for index creation.
43
-
Default value is _"1s"_.
44
-
** `indexStoreType`: Index storage type for the index.
45
-
Used for index creation.
46
-
Default value is _"fs"_.
47
39
** `createIndex`: flag whether to create an index on repository bootstrapping.
48
40
Default value is _true_.
49
41
See <<elasticsearch.repositories.autocreation>>
@@ -71,13 +63,13 @@ The mapping metadata infrastructure is defined in a separate spring-data-commons
71
63
==== Date format mapping
72
64
73
65
Properties that derive from `TemporalAccessor` or are of type `java.util.Date` must either have a `@Field` annotation
74
-
of type `FieldType.Date` or a custom converter must be registered for this type. This paragraph describes the use of
66
+
of type `FieldType.Date` or a custom converter must be registered for this type. This paragraph describes the use of
75
67
`FieldType.Date`.
76
68
77
-
There are two attributes of the `@Field` annotation that define which date format information is written to the
69
+
There are two attributes of the `@Field` annotation that define which date format information is written to the
78
70
mapping (also see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats[Elasticsearch Built In Formats] and https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#custom-date-formats[Elasticsearch Custom Date Formats])
79
71
80
-
The `format` attributes is used to define at least one of the predefined formats. If it is not defined, then a
72
+
The `format` attributes is used to define at least one of the predefined formats. If it is not defined, then a
81
73
default value of __date_optional_time_ and _epoch_millis_ is used.
82
74
83
75
The `pattern` attribute can be used to add additional custom format strings. If you want to use only custom date formats, you must set the `format` property to empty `{}`.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-operations.adoc
+2-1
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,8 @@ The default implementations of the interfaces offer:
21
21
====
22
22
.Index management and automatic creation of indices and mappings.
23
23
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.
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.
25
26
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.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-repositories.adoc
+2-2
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ class Book {
31
31
32
32
The `@Document` annotation has an argument `createIndex`. If this argument is set to true - which is the default value - Spring Data Elasticsearch will during bootstrapping the repository support on application startup check if the index defined by the `@Document` annotation exists.
33
33
34
-
If it does not exist, the index will be created and the mappings derived from the entity's annotations (see <<elasticsearch.mapping>>) will be written to the newly created index.
34
+
If it does not exist, the index will be created and the mappings derived from the entity's annotations (see <<elasticsearch.mapping>>) will be written to the newly created index. 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.
0 commit comments