migrate_3_0.asciidoc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. [[breaking-changes-3.0]]
  2. == Breaking changes in 3.0
  3. This section discusses the changes that you need to be aware of when migrating
  4. your application to Elasticsearch 3.0.
  5. === Search changes
  6. ==== `search_type=count` removed
  7. The `count` search type was deprecated since version 2.0.0 and is now removed.
  8. In order to get the same benefits, you just need to set the value of the `size`
  9. parameter to `0`.
  10. For instance, the following request:
  11. [source,sh]
  12. ---------------
  13. GET /my_index/_search?search_type=count
  14. {
  15. "aggs": {
  16. "my_terms": {
  17. "terms": {
  18. "field": "foo"
  19. }
  20. }
  21. }
  22. }
  23. ---------------
  24. can be replaced with:
  25. [source,sh]
  26. ---------------
  27. GET /my_index/_search
  28. {
  29. "size": 0,
  30. "aggs": {
  31. "my_terms": {
  32. "terms": {
  33. "field": "foo"
  34. }
  35. }
  36. }
  37. }
  38. ---------------
  39. ==== `search_type=scan` removed
  40. The `scan` search type was deprecated since version 2.1.0 and is now removed.
  41. All benefits from this search type can now be achieved by doing a scroll
  42. request that sorts documents in `_doc` order, for instance:
  43. [source,sh]
  44. ---------------
  45. GET /my_index/_search?scroll=2m
  46. {
  47. "sort": [
  48. "_doc"
  49. ]
  50. }
  51. ---------------
  52. Scroll requests sorted by `_doc` have been optimized to more efficiently resume
  53. from where the previous request stopped, so this will have the same performance
  54. characteristics as the former `scan` search type.
  55. === REST API changes
  56. ==== search exists api removed
  57. The search exists api has been removed in favour of using the search api with
  58. `size` set to `0` and `terminate_after` set to `1`.
  59. ==== `/_optimize` endpoint removed
  60. The deprecated `/_optimize` endpoint has been removed. The `/_forcemerge`
  61. endpoint should be used in lieu of optimize.
  62. ==== Deprecated queries removed
  63. The following deprecated queries have been removed:
  64. * `filtered`: use `bool` query instead, which supports `filter` clauses too
  65. * `and`: use `must` clauses in a `bool` query instead
  66. * `or`: use should clauses in a `bool` query instead
  67. * `limit`: use `terminate_after` parameter instead
  68. * `fquery`: obsolete after filters and queries have been merged
  69. * `query`: obsolete after filters and queries have been merged
  70. ==== Unified fuzziness parameter
  71. * Removed support for the deprecated `min_similarity` parameter in `fuzzy query`, in favour of `similarity`.
  72. * Removed support for the deprecated `fuzzy_min_sim` parameter in `query_string` query, in favour of `similarity`.
  73. * Removed support for the deprecated `edit_distance` parameter in completion suggester, in favour of `similarity`.
  74. ==== indices query
  75. Removed support for the deprecated `filter` and `no_match_filter` fields in `indices` query,
  76. in favour of `query` and `no_match_query`.
  77. ==== nested query
  78. Removed support for the deprecated `filter` fields in `nested` query, in favour of `query`.
  79. ==== terms query
  80. Removed support for the deprecated `minimum_should_match` and `disable_coord` in `terms` query, use `bool` query instead.
  81. Removed also support for the deprecated `execution` parameter.
  82. ==== function_score query
  83. Removed support for the top level `filter` element in `function_score` query, replaced by `query`.
  84. ==== highlighters
  85. Removed support for multiple highlighter names, the only supported ones are: `plain`, `fvh` and `postings`.
  86. ==== top level filter
  87. Removed support for the deprecated top level `filter` in the search api, replaced by `post_filter`.
  88. === Parent/Child changes
  89. The `children` aggregation, parent child inner hits and `has_child` and `has_parent` queries will not work on indices
  90. with `_parent` field mapping created before version `2.0.0`. The data of these indices need to be re-indexed into a new index.
  91. The format of the join between parent and child documents have changed with the `2.0.0` release. The old
  92. format can't read from version `3.0.0` and onwards. The new format allows for a much more efficient and
  93. scalable join between parent and child documents and the join data structures are stored on on disk
  94. data structures as opposed as before the join data structures were stored in the jvm heap space.
  95. ==== `score_type` has been removed
  96. The `score_type` option has been removed from the `has_child` and `has_parent` queries in favour of the `score_mode` option
  97. which does the exact same thing.
  98. ==== `sum` score mode removed
  99. The `sum` score mode has been removed in favour of the `total` mode which does the same and is already available in
  100. previous versions.
  101. ==== `max_children` option
  102. When `max_children` was set to `0` on the `has_child` query then there was no upper limit on how many children documents
  103. are allowed to match. This has changed and `0` now really means to zero child documents are allowed. If no upper limit
  104. is needed then the `max_children` option shouldn't be defined at all on the `has_child` query.
  105. === Settings changes ===
  106. ==== Analysis settings
  107. The `index.analysis.analyzer.default_index` analyzer is not supported anymore.
  108. If you wish to change the analyzer to use for indexing, change the
  109. `index.analysis.analyzer.default` analyzer instead.
  110. ==== Ping timeout settings
  111. Previously, there were three settings for the ping timeout: `discovery.zen.initial_ping_timeout`,
  112. `discovery.zen.ping.timeout` and `discovery.zen.ping_timeout`. The former two have been removed and
  113. the only setting key for the ping timeout is now `discovery.zen.ping_timeout`. The default value for
  114. ping timeouts remains at three seconds.
  115. === Plugins
  116. Plugins implementing custom queries need to implement the `fromXContent(QueryParseContext)` method in their
  117. `QueryParser` subclass rather than `parse`. This method will take care of parsing the query from `XContent` format
  118. into an intermediate query representation that can be streamed between the nodes in binary format, effectively the
  119. query object used in the java api. Also, the query parser needs to implement the `getBuilderPrototype` method that
  120. returns a prototype of the `NamedWriteable` query, which allows to deserialize an incoming query by calling
  121. `readFrom(StreamInput)` against it, which will create a new object, see usages of `Writeable`. The `QueryParser`
  122. also needs to declare the generic type of the query that it supports and it's able to parse.
  123. The query object can then transform itself into a lucene query through the new `toQuery(QueryShardContext)` method,
  124. which returns a lucene query to be executed on the data node.
  125. Similarly, plugins implementing custom score functions need to implement the `fromXContent(QueryParseContext)`
  126. method in their `ScoreFunctionParser` subclass rather than `parse`. This method will take care of parsing
  127. the function from `XContent` format into an intermediate function representation that can be streamed between
  128. the nodes in binary format, effectively the function object used in the java api. Also, the query parser needs
  129. to implement the `getBuilderPrototype` method that returns a prototype of the `NamedWriteable` function, which
  130. allows to deserialize an incoming function by calling `readFrom(StreamInput)` against it, which will create a
  131. new object, see usages of `Writeable`. The `ScoreFunctionParser` also needs to declare the generic type of the
  132. function that it supports and it's able to parse. The function object can then transform itself into a lucene
  133. function through the new `toFunction(QueryShardContext)` method, which returns a lucene function to be executed
  134. on the data node.
  135. ==== Cloud AWS plugin
  136. Cloud AWS plugin has been split in two plugins:
  137. * {plugins}/discovery-ec2.html[Discovery EC2 plugin]
  138. * {plugins}/repository-s3.html[Repository S3 plugin]
  139. ==== Cloud Azure plugin
  140. Cloud Azure plugin has been split in three plugins:
  141. * {plugins}/discovery-azure.html[Discovery Azure plugin]
  142. * {plugins}/repository-azure.html[Repository Azure plugin]
  143. * {plugins}/store-smb.html[Store SMB plugin]
  144. ==== Cloud GCE plugin
  145. Cloud GCE plugin has been renamed to {plugins}/discovery-gce.html[Discovery GCE plugin].
  146. === Java-API
  147. ==== Count api has been removed
  148. The deprecated count api has been removed from the Java api, use the search api instead and set size to 0.
  149. The following call
  150. ```
  151. client.prepareCount(indices).setQuery(query).get();
  152. ```
  153. can be replaced with
  154. ```
  155. client.prepareSearch(indices).setSource(new SearchSourceBuilder().size(0).query(query)).get();
  156. ```
  157. ==== BoostingQueryBuilder
  158. Removed setters for mandatory positive/negative query. Both arguments now have
  159. to be supplied at construction time already and have to be non-null.
  160. ==== SpanContainingQueryBuilder
  161. Removed setters for mandatory big/little inner span queries. Both arguments now have
  162. to be supplied at construction time already and have to be non-null. Updated
  163. static factory methods in QueryBuilders accordingly.
  164. ==== SpanOrQueryBuilder
  165. Making sure that query contains at least one clause by making initial clause mandatory
  166. in constructor.
  167. ==== SpanNearQueryBuilder
  168. Removed setter for mandatory slop parameter, needs to be set in constructor now. Also
  169. making sure that query contains at least one clause by making initial clause mandatory
  170. in constructor. Updated the static factory methods in QueryBuilders accordingly.
  171. ==== SpanNotQueryBuilder
  172. Removed setter for mandatory include/exclude span query clause, needs to be set in constructor now.
  173. Updated the static factory methods in QueryBuilders and tests accordingly.
  174. ==== SpanWithinQueryBuilder
  175. Removed setters for mandatory big/little inner span queries. Both arguments now have
  176. to be supplied at construction time already and have to be non-null. Updated
  177. static factory methods in QueryBuilders accordingly.
  178. ==== QueryFilterBuilder
  179. Removed the setter `queryName(String queryName)` since this field is not supported
  180. in this type of query. Use `FQueryFilterBuilder.queryName(String queryName)` instead
  181. when in need to wrap a named query as a filter.
  182. ==== WrapperQueryBuilder
  183. Removed `wrapperQueryBuilder(byte[] source, int offset, int length)`. Instead simply
  184. use `wrapperQueryBuilder(byte[] source)`. Updated the static factory methods in
  185. QueryBuilders accordingly.
  186. ==== QueryStringQueryBuilder
  187. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  188. Use the `field(String, float)` method instead.
  189. ==== Operator
  190. Removed the enums called `Operator` from `MatchQueryBuilder`, `QueryStringQueryBuilder`,
  191. `SimpleQueryStringBuilder`, and `CommonTermsQueryBuilder` in favour of using the enum
  192. defined in `org.elasticsearch.index.query.Operator` in an effort to consolidate the
  193. codebase and avoid duplication.
  194. ==== queryName and boost support
  195. Support for `queryName` and `boost` has been streamlined to all of the queries. That is
  196. a breaking change till queries get sent over the network as serialized json rather
  197. than in `Streamable` format. In fact whenever additional fields are added to the json
  198. representation of the query, older nodes might throw error when they find unknown fields.
  199. ==== InnerHitsBuilder
  200. InnerHitsBuilder now has a dedicated addParentChildInnerHits and addNestedInnerHits methods
  201. to differentiate between inner hits for nested vs. parent / child documents. This change
  202. makes the type / path parameter mandatory.
  203. ==== MatchQueryBuilder
  204. Moving MatchQueryBuilder.Type and MatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.Type.
  205. Also reusing new Operator enum.
  206. ==== MoreLikeThisQueryBuilder
  207. Removed `MoreLikeThisQueryBuilder.Item#id(String id)`, `Item#doc(BytesReference doc)`,
  208. `Item#doc(XContentBuilder doc)`. Use provided constructors instead.
  209. Removed `MoreLikeThisQueryBuilder#addLike` in favor of texts and/or items being provided
  210. at construction time. Using arrays there instead of lists now.
  211. Removed `MoreLikeThisQueryBuilder#addUnlike` in favor to using the `unlike` methods
  212. which take arrays as arguments now rather than the lists used before.
  213. The deprecated `docs(Item... docs)`, `ignoreLike(Item... docs)`,
  214. `ignoreLike(String... likeText)`, `addItem(Item... likeItems)` have been removed.
  215. ==== GeoDistanceQueryBuilder
  216. Removing individual setters for lon() and lat() values, both values should be set together
  217. using point(lon, lat).
  218. ==== GeoDistanceRangeQueryBuilder
  219. Removing setters for to(Object ...) and from(Object ...) in favour of the only two allowed input
  220. arguments (String, Number). Removing setter for center point (point(), geohash()) because parameter
  221. is mandatory and should already be set in constructor.
  222. Also removing setters for lt(), lte(), gt(), gte() since they can all be replaced by equivallent
  223. calls to to/from() and inludeLower()/includeUpper().
  224. ==== GeoPolygonQueryBuilder
  225. Require shell of polygon already to be specified in constructor instead of adding it pointwise.
  226. This enables validation, but makes it necessary to remove the addPoint() methods.
  227. ==== MultiMatchQueryBuilder
  228. Moving MultiMatchQueryBuilder.ZeroTermsQuery enum to MatchQuery.ZeroTermsQuery.
  229. Also reusing new Operator enum.
  230. Removed ability to pass in boost value using `field(String field)` method in form e.g. `field^2`.
  231. Use the `field(String, float)` method instead.
  232. ==== MissingQueryBuilder
  233. The two individual setters for existence() and nullValue() were removed in favour of
  234. optional constructor settings in order to better capture and validate their interdependent
  235. settings at construction time.
  236. ==== NotQueryBuilder
  237. The NotQueryBuilder which was deprecated in 2.1.0 is removed. As a replacement use BoolQueryBuilder
  238. with added mustNot() clause. So instead of using `new NotQueryBuilder(filter)` now use
  239. `new BoolQueryBuilder().mustNot(filter)`.
  240. ==== TermsQueryBuilder
  241. Remove the setter for `termsLookup()`, making it only possible to either use a TermsLookup object or
  242. individual values at construction time. Also moving individual settings for the TermsLookup (lookupIndex,
  243. lookupType, lookupId, lookupPath) to the separate TermsLookup class, using constructor only and moving
  244. checks for validation there. Removed `TermsLookupQueryBuilder` in favour of `TermsQueryBuilder`.
  245. ==== FunctionScoreQueryBuilder
  246. `add` methods have been removed, all filters and functions must be provided as constructor arguments by
  247. creating an array of `FunctionScoreQueryBuilder.FilterFunctionBuilder` objects, containing one element
  248. for each filter/function pair.
  249. `scoreMode` and `boostMode` can only be provided using corresponding enum members instead
  250. of string values: see `FilterFunctionScoreQuery.ScoreMode` and `CombineFunction`.
  251. `CombineFunction.MULT` has been renamed to `MULTIPLY`.
  252. ==== IdsQueryBuilder
  253. For simplicity, only one way of adding the ids to the existing list (empty by default) is left: `addIds(String...)`
  254. ==== DocumentAlreadyExistsException removed
  255. `DocumentAlreadyExistsException` is removed and a `VersionConflictException` is thrown instead (with a better
  256. error description). This will influence code that use the `IndexRequest.opType()` or `IndexRequest.create()`
  257. to index a document only if it doesn't already exist.
  258. === Cache concurrency level settings removed
  259. Two cache concurrency level settings `indices.requests.cache.concurrency_level` and
  260. `indices.fielddata.cache.concurrency_level` because they no longer apply to the cache implementation used for the
  261. request cache and the field data cache.
  262. === Remove bind option of `non_loopback`
  263. This setting would arbitrarily pick the first interface not marked as loopback. Instead, specify by address
  264. scope (e.g. `_local_,_site_` for all loopback and private network addresses) or by explicit interface names,
  265. hostnames, or addresses.