java.asciidoc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. [[breaking_50_java_api_changes]]
  2. === Java API changes
  3. ==== Count api has been removed
  4. The deprecated count api has been removed from the Java api, use the search api instead and set size to 0.
  5. The following call
  6. [source,java]
  7. -----
  8. client.prepareCount(indices).setQuery(query).get();
  9. -----
  10. can be replaced with
  11. [source,java]
  12. -----
  13. client.prepareSearch(indices).setSource(new SearchSourceBuilder().size(0).query(query)).get();
  14. -----
  15. ==== Suggest api has been removed
  16. The suggest api has been removed from the Java api, use the suggest option in search api, it has been optimized
  17. for suggest-only request.
  18. The following call
  19. [source,java]
  20. -----
  21. client.prepareSuggest(indices).addSuggestion("foo", SuggestBuilders.completionSuggestion("field").text("s")).get();
  22. -----
  23. can be replaced with
  24. [source,java]
  25. -----
  26. client.prepareSearch(indices).suggest(new SuggestBuilder().addSuggestion("foo", SuggestBuilders.completionSuggestion("field").text("s"))).get();
  27. -----
  28. ==== Elasticsearch will no longer detect logging implementations
  29. Elasticsearch now logs only to log4j 1.2. Previously if log4j wasn't on the
  30. classpath it made some effort to degrade to slf4j or java.util.logging. Now it
  31. will fail to work without the log4j 1.2 api. The log4j-over-slf4j bridge ought
  32. to work when using the java client, as should log4j 2's log4j-1.2-api. The
  33. Elasticsearch server now only supports log4j as configured by `logging.yml`
  34. and will fail if log4j isn't present.
  35. ==== Groovy dependencies
  36. In previous versions of Elasticsearch, the Groovy scripting capabilities
  37. depended on the `org.codehaus.groovy:groovy-all` artifact. In addition
  38. to pulling in the Groovy language, this pulls in a very large set of
  39. functionality, none of which is needed for scripting within
  40. Elasticsearch. Aside from the inherent difficulties in managing such a
  41. large set of dependencies, this also increases the surface area for
  42. security issues. This dependency has been reduced to the core Groovy
  43. language `org.codehaus.groovy:groovy` artifact.
  44. ==== DocumentAlreadyExistsException removed
  45. `DocumentAlreadyExistsException` is removed and a `VersionConflictException` is thrown instead (with a better
  46. error description). This will influence code that use the `IndexRequest.opType()` or `IndexRequest.create()`
  47. to index a document only if it doesn't already exist.
  48. ==== Changes to Query Builders
  49. ===== BoostingQueryBuilder
  50. Removed setters for mandatory positive/negative query. Both arguments now have
  51. to be supplied at construction time already and have to be non-null.
  52. ===== SpanContainingQueryBuilder
  53. Removed setters for mandatory big/little inner span queries. Both arguments now have
  54. to be supplied at construction time already and have to be non-null. Updated
  55. static factory methods in QueryBuilders accordingly.
  56. ===== SpanOrQueryBuilder
  57. Making sure that query contains at least one clause by making initial clause mandatory
  58. in constructor.
  59. ===== SpanNearQueryBuilder
  60. Removed setter for mandatory slop parameter, needs to be set in constructor now. Also
  61. making sure that query contains at least one clause by making initial clause mandatory
  62. in constructor. Updated the static factory methods in QueryBuilders accordingly.
  63. ===== SpanNotQueryBuilder
  64. Removed setter for mandatory include/exclude span query clause, needs to be set in constructor now.
  65. Updated the static factory methods in QueryBuilders and tests accordingly.
  66. ===== SpanWithinQueryBuilder
  67. Removed setters for mandatory big/little inner span queries. Both arguments now have
  68. to be supplied at construction time already and have to be non-null. Updated
  69. static factory methods in QueryBuilders accordingly.
  70. ===== WrapperQueryBuilder
  71. Removed `wrapperQueryBuilder(byte[] source, int offset, int length)`. Instead simply
  72. use `wrapperQueryBuilder(byte[] source)`. Updated the static factory methods in
  73. QueryBuilders accordingly.
  74. ===== QueryStringQueryBuilder
  75. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  76. Use the `field(String, float)` method instead.
  77. ===== Operator
  78. Removed the enums called `Operator` from `MatchQueryBuilder`, `QueryStringQueryBuilder`,
  79. `SimpleQueryStringBuilder`, and `CommonTermsQueryBuilder` in favour of using the enum
  80. defined in `org.elasticsearch.index.query.Operator` in an effort to consolidate the
  81. codebase and avoid duplication.
  82. ===== queryName and boost support
  83. Support for `queryName` and `boost` has been streamlined to all of the queries. That is
  84. a breaking change till queries get sent over the network as serialized json rather
  85. than in `Streamable` format. In fact whenever additional fields are added to the json
  86. representation of the query, older nodes might throw error when they find unknown fields.
  87. ===== InnerHitsBuilder
  88. InnerHitsBuilder now has a dedicated addParentChildInnerHits and addNestedInnerHits methods
  89. to differentiate between inner hits for nested vs. parent / child documents. This change
  90. makes the type / path parameter mandatory.
  91. ===== MatchQueryBuilder
  92. Moving MatchQueryBuilder.Type and MatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.Type.
  93. Also reusing new Operator enum.
  94. ===== MoreLikeThisQueryBuilder
  95. Removed `MoreLikeThisQueryBuilder.Item#id(String id)`, `Item#doc(BytesReference doc)`,
  96. `Item#doc(XContentBuilder doc)`. Use provided constructors instead.
  97. Removed `MoreLikeThisQueryBuilder#addLike` in favor of texts and/or items being provided
  98. at construction time. Using arrays there instead of lists now.
  99. Removed `MoreLikeThisQueryBuilder#addUnlike` in favor to using the `unlike` methods
  100. which take arrays as arguments now rather than the lists used before.
  101. The deprecated `docs(Item... docs)`, `ignoreLike(Item... docs)`,
  102. `ignoreLike(String... likeText)`, `addItem(Item... likeItems)` have been removed.
  103. ===== GeoDistanceQueryBuilder
  104. Removing individual setters for lon() and lat() values, both values should be set together
  105. using point(lon, lat).
  106. ===== GeoDistanceRangeQueryBuilder
  107. Removing setters for to(Object ...) and from(Object ...) in favour of the only two allowed input
  108. arguments (String, Number). Removing setter for center point (point(), geohash()) because parameter
  109. is mandatory and should already be set in constructor.
  110. Also removing setters for lt(), lte(), gt(), gte() since they can all be replaced by equivalent
  111. calls to to/from() and inludeLower()/includeUpper().
  112. ===== GeoPolygonQueryBuilder
  113. Require shell of polygon already to be specified in constructor instead of adding it pointwise.
  114. This enables validation, but makes it necessary to remove the addPoint() methods.
  115. ===== MultiMatchQueryBuilder
  116. Moving MultiMatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.ZeroTermsQuery.
  117. Also reusing new Operator enum.
  118. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  119. Use the `field(String, float)` method instead.
  120. ===== MissingQueryBuilder
  121. The MissingQueryBuilder which was deprecated in 2.2.0 is removed. As a replacement use ExistsQueryBuilder
  122. inside a mustNot() clause. So instead of using `new ExistsQueryBuilder(name)` now use
  123. `new BoolQueryBuilder().mustNot(new ExistsQueryBuilder(name))`.
  124. ===== NotQueryBuilder
  125. The NotQueryBuilder which was deprecated in 2.1.0 is removed. As a replacement use BoolQueryBuilder
  126. with added mustNot() clause. So instead of using `new NotQueryBuilder(filter)` now use
  127. `new BoolQueryBuilder().mustNot(filter)`.
  128. ===== TermsQueryBuilder
  129. Remove the setter for `termsLookup()`, making it only possible to either use a TermsLookup object or
  130. individual values at construction time. Also moving individual settings for the TermsLookup (lookupIndex,
  131. lookupType, lookupId, lookupPath) to the separate TermsLookup class, using constructor only and moving
  132. checks for validation there. Removed `TermsLookupQueryBuilder` in favour of `TermsQueryBuilder`.
  133. ===== FunctionScoreQueryBuilder
  134. `add` methods have been removed, all filters and functions must be provided as constructor arguments by
  135. creating an array of `FunctionScoreQueryBuilder.FilterFunctionBuilder` objects, containing one element
  136. for each filter/function pair.
  137. `scoreMode` and `boostMode` can only be provided using corresponding enum members instead
  138. of string values: see `FilterFunctionScoreQuery.ScoreMode` and `CombineFunction`.
  139. `CombineFunction.MULT` has been renamed to `MULTIPLY`.
  140. ===== IdsQueryBuilder
  141. For simplicity, only one way of adding the ids to the existing list (empty by default) is left: `addIds(String...)`
  142. ===== ShapeBuilders
  143. `InternalLineStringBuilder` is removed in favour of `LineStringBuilder`, `InternalPolygonBuilder` in favour of PolygonBuilder` and `Ring` has been replaced with `LineStringBuilder`. Also the abstract base classes `BaseLineStringBuilder` and `BasePolygonBuilder` haven been merged with their corresponding implementations.
  144. ===== RescoreBuilder
  145. `RecoreBuilder.Rescorer` was merged with `RescoreBuilder`, which now is an abstract superclass. QueryRescoreBuilder currently is its only implementation.
  146. ===== PhraseSuggestionBuilder
  147. The inner DirectCandidateGenerator class has been moved out to its own class called DirectCandidateGeneratorBuilder.
  148. ===== SortBuilders
  149. The `sortMode` setter in `FieldSortBuilder`, `GeoDistanceSortBuilder` and `ScriptSortBuilder` now
  150. accept a `SortMode` enum instead of a String constant. Also the getter returns the same enum type.
  151. ===== SuggestBuilder
  152. The `setText` method has been changed to `setGlobalText` to make the intent more clear, and a `getGlobalText` method has been added.
  153. The `addSuggestion` method now required the user specified suggestion name, previously used in the ctor of each suggestion.
  154. ===== SuggestionBuilder
  155. The `field` setter has been deleted. Instead the field name needs to be specified as constructor argument.
  156. ==== SearchSourceBuilder
  157. All methods which take an `XContentBuilder`, `BytesReference` `Map<String, Object>` or `bytes[]` have been removed in favor of providing the
  158. relevant builder object for that feature (e.g. `HighlightBuilder`, `AggregationBuilder`, `SuggestBuilder`) . This means that all search requests
  159. can now be validated at call time which results in much clearer errors.
  160. The `defaultResourceWindowSize(int)` method has been removed. The window size should be set explicitly on all `RescoreBuilder` objects.
  161. ==== SearchRequestBuilder
  162. All methods which take an `XContentBuilder`, `BytesReference` `Map<String, Object>` or `bytes[]` have been removed in favor of providing the
  163. relevant builder object for that feature (e.g. `HighlightBuilder`, `AggregationBuilder`, `SuggestBuilder`) . This means that all search requests
  164. can now be validated at call time which results in much clearer errors.
  165. All highlighter methods have been removed in favor of a single `highlighter(HighlightBuilder)` method.
  166. The `setExtraSource(SearchSourceBuilder)` method has been removed.
  167. The `setTemplateSource(String)` and `setTemplateSource(BytesReference)` methods have been removed. Use `setTemplate(Template)` instead.
  168. `setRescorer(Rescorer)` and `setRescorer(Rescorer, int)` have been removed infavor of `setRescorer(RescoreBuilder)` and `setRescorer(RescoreBuilder, int)`
  169. ==== SearchRequest
  170. All `template` methods have been removed in favor of a single `template(Template)` method.
  171. All `source` methods have been removed in favor of a single `source(SearchSourceBuilder)` method. This means that all search requests can now be validated
  172. at call time which results in much clearer errors.
  173. All `extraSource` methods have been removed.
  174. ==== SearchResponse
  175. Sort values for `string` fields are now return as `java.lang.String` objects rather than `org.elasticsearch.common.text.Text`.
  176. ==== AggregationBuilder
  177. All methods which take an `XContentBuilder`, `BytesReference` `Map<String, Object>` or `bytes[]` have been removed in favor of providing the
  178. relevant builder object (i.e. `subAggregation(AggregationBuilder)` or `subAggregation(PipelineAggregationBuilder)`). This means that all
  179. requests can now be validated at call time which results in much clearer errors.
  180. ==== ValidateQueryRequest
  181. `source(QuerySourceBuilder)`, `source(Map)`, `source(XContentBuilder)`, `source(String)`, `source(byte[])`, `source(byte[], int, int)`,
  182. `source(BytesReference)` and `source()` have been removed in favor of using `query(QueryBuilder)` and `query()`
  183. ==== ValidateQueryRequestBuilder
  184. `setSource()` methods have been removed in favor of using `setQuery(QueryBuilder)`
  185. ==== ExplainRequest
  186. `source(QuerySourceBuilder)`, `source(Map)`, `source(BytesReference)` and `source()` have been removed in favor of using
  187. `query(QueryBuilder)` and `query()`
  188. ==== ExplainRequestBuilder
  189. The `setQuery(BytesReference)` method have been removed in favor of using `setQuery(QueryBuilder)`
  190. === ClusterStatsResponse
  191. Removed the `getMemoryAvailable` method from `OsStats`, which could be previously accessed calling
  192. `clusterStatsResponse.getNodesStats().getOs().getMemoryAvailable()`.