1
0

java.asciidoc 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. ==== Elasticsearch will no longer detect logging implementations
  16. Elasticsearch now logs only to log4j 1.2. Previously if log4j wasn't on the
  17. classpath it made some effort to degrade to slf4j or java.util.logging. Now it
  18. will fail to work without the log4j 1.2 api. The log4j-over-slf4j bridge ought
  19. to work when using the java client, as should log4j 2's log4j-1.2-api. The
  20. Elasticsearch server now only supports log4j as configured by `logging.yml`
  21. and will fail if log4j isn't present.
  22. ==== Groovy dependencies
  23. In previous versions of Elasticsearch, the Groovy scripting capabilities
  24. depended on the `org.codehaus.groovy:groovy-all` artifact. In addition
  25. to pulling in the Groovy language, this pulls in a very large set of
  26. functionality, none of which is needed for scripting within
  27. Elasticsearch. Aside from the inherent difficulties in managing such a
  28. large set of dependencies, this also increases the surface area for
  29. security issues. This dependency has been reduced to the core Groovy
  30. language `org.codehaus.groovy:groovy` artifact.
  31. ==== DocumentAlreadyExistsException removed
  32. `DocumentAlreadyExistsException` is removed and a `VersionConflictException` is thrown instead (with a better
  33. error description). This will influence code that use the `IndexRequest.opType()` or `IndexRequest.create()`
  34. to index a document only if it doesn't already exist.
  35. ==== Changes to Query Builders
  36. ===== BoostingQueryBuilder
  37. Removed setters for mandatory positive/negative query. Both arguments now have
  38. to be supplied at construction time already and have to be non-null.
  39. ===== SpanContainingQueryBuilder
  40. Removed setters for mandatory big/little inner span queries. Both arguments now have
  41. to be supplied at construction time already and have to be non-null. Updated
  42. static factory methods in QueryBuilders accordingly.
  43. ===== SpanOrQueryBuilder
  44. Making sure that query contains at least one clause by making initial clause mandatory
  45. in constructor.
  46. ===== SpanNearQueryBuilder
  47. Removed setter for mandatory slop parameter, needs to be set in constructor now. Also
  48. making sure that query contains at least one clause by making initial clause mandatory
  49. in constructor. Updated the static factory methods in QueryBuilders accordingly.
  50. ===== SpanNotQueryBuilder
  51. Removed setter for mandatory include/exclude span query clause, needs to be set in constructor now.
  52. Updated the static factory methods in QueryBuilders and tests accordingly.
  53. ===== SpanWithinQueryBuilder
  54. Removed setters for mandatory big/little inner span queries. Both arguments now have
  55. to be supplied at construction time already and have to be non-null. Updated
  56. static factory methods in QueryBuilders accordingly.
  57. ===== QueryFilterBuilder
  58. Removed the setter `queryName(String queryName)` since this field is not supported
  59. in this type of query. Use `FQueryFilterBuilder.queryName(String queryName)` instead
  60. when in need to wrap a named query as a filter.
  61. ===== WrapperQueryBuilder
  62. Removed `wrapperQueryBuilder(byte[] source, int offset, int length)`. Instead simply
  63. use `wrapperQueryBuilder(byte[] source)`. Updated the static factory methods in
  64. QueryBuilders accordingly.
  65. ===== QueryStringQueryBuilder
  66. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  67. Use the `field(String, float)` method instead.
  68. ===== Operator
  69. Removed the enums called `Operator` from `MatchQueryBuilder`, `QueryStringQueryBuilder`,
  70. `SimpleQueryStringBuilder`, and `CommonTermsQueryBuilder` in favour of using the enum
  71. defined in `org.elasticsearch.index.query.Operator` in an effort to consolidate the
  72. codebase and avoid duplication.
  73. ===== queryName and boost support
  74. Support for `queryName` and `boost` has been streamlined to all of the queries. That is
  75. a breaking change till queries get sent over the network as serialized json rather
  76. than in `Streamable` format. In fact whenever additional fields are added to the json
  77. representation of the query, older nodes might throw error when they find unknown fields.
  78. ===== InnerHitsBuilder
  79. InnerHitsBuilder now has a dedicated addParentChildInnerHits and addNestedInnerHits methods
  80. to differentiate between inner hits for nested vs. parent / child documents. This change
  81. makes the type / path parameter mandatory.
  82. ===== MatchQueryBuilder
  83. Moving MatchQueryBuilder.Type and MatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.Type.
  84. Also reusing new Operator enum.
  85. ===== MoreLikeThisQueryBuilder
  86. Removed `MoreLikeThisQueryBuilder.Item#id(String id)`, `Item#doc(BytesReference doc)`,
  87. `Item#doc(XContentBuilder doc)`. Use provided constructors instead.
  88. Removed `MoreLikeThisQueryBuilder#addLike` in favor of texts and/or items being provided
  89. at construction time. Using arrays there instead of lists now.
  90. Removed `MoreLikeThisQueryBuilder#addUnlike` in favor to using the `unlike` methods
  91. which take arrays as arguments now rather than the lists used before.
  92. The deprecated `docs(Item... docs)`, `ignoreLike(Item... docs)`,
  93. `ignoreLike(String... likeText)`, `addItem(Item... likeItems)` have been removed.
  94. ===== GeoDistanceQueryBuilder
  95. Removing individual setters for lon() and lat() values, both values should be set together
  96. using point(lon, lat).
  97. ===== GeoDistanceRangeQueryBuilder
  98. Removing setters for to(Object ...) and from(Object ...) in favour of the only two allowed input
  99. arguments (String, Number). Removing setter for center point (point(), geohash()) because parameter
  100. is mandatory and should already be set in constructor.
  101. Also removing setters for lt(), lte(), gt(), gte() since they can all be replaced by equivalent
  102. calls to to/from() and inludeLower()/includeUpper().
  103. ===== GeoPolygonQueryBuilder
  104. Require shell of polygon already to be specified in constructor instead of adding it pointwise.
  105. This enables validation, but makes it necessary to remove the addPoint() methods.
  106. ===== MultiMatchQueryBuilder
  107. Moving MultiMatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.ZeroTermsQuery.
  108. Also reusing new Operator enum.
  109. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  110. Use the `field(String, float)` method instead.
  111. ===== MissingQueryBuilder
  112. The MissingQueryBuilder which was deprecated in 2.2.0 is removed. As a replacement use ExistsQueryBuilder
  113. inside a mustNot() clause. So instead of using `new ExistsQueryBuilder(name)` now use
  114. `new BoolQueryBuilder().mustNot(new ExistsQueryBuilder(name))`.
  115. ===== NotQueryBuilder
  116. The NotQueryBuilder which was deprecated in 2.1.0 is removed. As a replacement use BoolQueryBuilder
  117. with added mustNot() clause. So instead of using `new NotQueryBuilder(filter)` now use
  118. `new BoolQueryBuilder().mustNot(filter)`.
  119. ===== TermsQueryBuilder
  120. Remove the setter for `termsLookup()`, making it only possible to either use a TermsLookup object or
  121. individual values at construction time. Also moving individual settings for the TermsLookup (lookupIndex,
  122. lookupType, lookupId, lookupPath) to the separate TermsLookup class, using constructor only and moving
  123. checks for validation there. Removed `TermsLookupQueryBuilder` in favour of `TermsQueryBuilder`.
  124. ===== FunctionScoreQueryBuilder
  125. `add` methods have been removed, all filters and functions must be provided as constructor arguments by
  126. creating an array of `FunctionScoreQueryBuilder.FilterFunctionBuilder` objects, containing one element
  127. for each filter/function pair.
  128. `scoreMode` and `boostMode` can only be provided using corresponding enum members instead
  129. of string values: see `FilterFunctionScoreQuery.ScoreMode` and `CombineFunction`.
  130. `CombineFunction.MULT` has been renamed to `MULTIPLY`.
  131. ===== IdsQueryBuilder
  132. For simplicity, only one way of adding the ids to the existing list (empty by default) is left: `addIds(String...)`
  133. ===== ShapeBuilders
  134. `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.
  135. ===== RescoreBuilder
  136. `RecoreBuilder.Rescorer` was merged with `RescoreBuilder`, which now is an abstract superclass. QueryRescoreBuilder currently is its only implementation.
  137. ===== PhraseSuggestionBuilder
  138. The inner DirectCandidateGenerator class has been moved out to its own class called DirectCandidateGeneratorBuilder.
  139. ===== SortBuilders
  140. The `sortMode` setter in `FieldSortBuilder`, `GeoDistanceSortBuilder` and `ScriptSortBuilder` now
  141. accept a `SortMode` enum instead of a String constant. Also the getter returns the same enum type.