migrate_2_0.asciidoc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. [[breaking-changes-2.0]]
  2. == Breaking changes in 2.0
  3. This section discusses the changes that you need to be aware of when migrating
  4. your application to Elasticsearch 2.0.
  5. === Indices API
  6. The <<alias-retrieving, get alias api>> will, by default produce an error response
  7. if a requested index does not exist. This change brings the defaults for this API in
  8. line with the other Indices APIs. The <<multi-index>> options can be used on a request
  9. to change this behavior
  10. `GetIndexRequest.features()` now returns an array of Feature Enums instead of an array of String values.
  11. The following deprecated methods have been removed:
  12. * `GetIndexRequest.addFeatures(String[])` - Please use `GetIndexRequest.addFeatures(Feature[])` instead
  13. * `GetIndexRequest.features(String[])` - Please use `GetIndexRequest.features(Feature[])` instead
  14. * `GetIndexRequestBuilder.addFeatures(String[])` - Please use `GetIndexRequestBuilder.addFeatures(Feature[])` instead
  15. * `GetIndexRequestBuilder.setFeatures(String[])` - Please use `GetIndexRequestBuilder.setFeatures(Feature[])` instead
  16. === Partial fields
  17. Partial fields were deprecated since 1.0.0beta1 in favor of <<search-request-source-filtering,source filtering>>.
  18. === More Like This Field
  19. The More Like This Field query has been removed in favor of the <<query-dsl-mlt-query, More Like This Query>>
  20. restrained set to a specific `field`.
  21. === Routing
  22. The default hash function that is used for routing has been changed from djb2 to
  23. murmur3. This change should be transparent unless you relied on very specific
  24. properties of djb2. This will help ensure a better balance of the document counts
  25. between shards.
  26. In addition, the following node settings related to routing have been deprecated:
  27. [horizontal]
  28. `cluster.routing.operation.hash.type`::
  29. This was an undocumented setting that allowed to configure which hash function
  30. to use for routing. `murmur3` is now enforced on new indices.
  31. `cluster.routing.operation.use_type`::
  32. This was an undocumented setting that allowed to take the `_type` of the
  33. document into account when computing its shard (default: `false`). `false` is
  34. now enforced on new indices.
  35. === Async replication
  36. The `replication` parameter has been removed from all CRUD operations (index,
  37. update, delete, bulk, delete-by-query). These operations are now synchronous
  38. only, and a request will only return once the changes have been replicated to
  39. all active shards in the shard group.
  40. === Store
  41. The `memory` / `ram` store (`index.store.type`) option was removed in Elasticsearch 2.0.
  42. === Term Vectors API
  43. Usage of `/_termvector` is deprecated, and replaced in favor of `/_termvectors`.
  44. === Script fields
  45. Script fields in 1.x were only returned as a single value. So even if the return
  46. value of a script used to be list, it would be returned as an array containing
  47. a single value that is a list too, such as:
  48. [source,json]
  49. ---------------
  50. "fields": {
  51. "my_field": [
  52. [
  53. "v1",
  54. "v2"
  55. ]
  56. ]
  57. }
  58. ---------------
  59. In elasticsearch 2.x, scripts that return a list of values are considered as
  60. multivalued fields. So the same example would return the following response,
  61. with values in a single array.
  62. [source,json]
  63. ---------------
  64. "fields": {
  65. "my_field": [
  66. "v1",
  67. "v2"
  68. ]
  69. }
  70. ---------------
  71. === Main API
  72. Previously, calling `GET /` was giving back the http status code within the json response
  73. in addition to the actual HTTP status code. We removed `status` field in json response.
  74. === Java API
  75. Some query builders have been removed or renamed:
  76. * `commonTerms(...)` renamed with `commonTermsQuery(...)`
  77. * `queryString(...)` renamed with `queryStringQuery(...)`
  78. * `simpleQueryString(...)` renamed with `simpleQueryStringQuery(...)`
  79. * `textPhrase(...)` removed
  80. * `textPhrasePrefix(...)` removed
  81. * `textPhrasePrefixQuery(...)` removed
  82. * `filtered(...)` removed. Use `filteredQuery(...)` instead.
  83. * `inQuery(...)` removed.
  84. === Aggregations
  85. The `date_histogram` aggregation now returns a `Histogram` object in the response, and the `DateHistogram` class has been removed. Similarly
  86. the `date_range`, `ipv4_range`, and `geo_distance` aggregations all return a `Range` object in the response, and the `IPV4Range`, `DateRange`,
  87. and `GeoDistance` classes have been removed. The motivation for this is to have a single response API for the Range and Histogram aggregations
  88. regardless of the type of data being queried. To support this some changes were made in the `MultiBucketAggregation` interface which applies
  89. to all bucket aggregations:
  90. * The `getKey()` method now returns `Object` instead of `String`. The actual object type returned depends on the type of aggregation requested
  91. (e.g. the `date_histogram` will return a `DateTime` object for this method whereas a `histogram` will return a `Number`).
  92. * A `getKeyAsString()` method has been added to return the String representation of the key.
  93. * All other `getKeyAsX()` methods have been removed.
  94. * The `getBucketAsKey(String)` methods have been removed on all aggregations except the `filters` and `terms` aggregations.
  95. The `histogram` and the `date_histogram` aggregation now support a simplified `offset` option that replaces the previous `pre_offset` and
  96. `post_offset` rounding options. Instead of having to specify two separate offset shifts of the underlying buckets, the `offset` option
  97. moves the bucket boundaries in positive or negative direction depending on its argument.
  98. The `date_histogram` options for `pre_zone` and `post_zone` are replaced by the `time_zone` option. The behavior of `time_zone` is
  99. equivalent to the former `pre_zone` option. Setting `time_zone` to a value like "+01:00" now will lead to the bucket calculations
  100. being applied in the specified time zone but In addition to this, also the `pre_zone_adjust_large_interval` is removed because we
  101. now always return dates and bucket keys in UTC.
  102. Both the `histogram` and `date_histogram` aggregations now have a default `min_doc_count` of `0` instead of `1` previously.
  103. `include`/`exclude` filtering on the `terms` aggregation now uses the same syntax as regexp queries instead of the Java syntax. While simple
  104. regexps should still work, more complex ones might need some rewriting. Also, the `flags` parameter is not supported anymore.
  105. === Terms filter lookup caching
  106. The terms filter lookup mechanism does not support the `cache` option anymore
  107. and relies on the filesystem cache instead. If the lookup index is not too
  108. large, it is recommended to make it replicated to all nodes by setting
  109. `index.auto_expand_replicas: 0-all` in order to remove the network overhead as
  110. well.
  111. === Delete by query
  112. The meaning of the `_shards` headers in the delete by query response has changed. Before version 2.0 the `total`,
  113. `successful` and `failed` fields in the header are based on the number of primary shards. The failures on replica
  114. shards aren't being kept track of. From version 2.0 the stats in the `_shards` header are based on all shards
  115. of an index. The http status code is left unchanged and is only based on failures that occurred while executing on
  116. primary shards.
  117. === Delete api with missing routing when required
  118. Delete api requires a routing value when deleting a document belonging to a type that has routing set to required in its
  119. mapping, whereas previous elasticsearch versions would trigger a broadcast delete on all shards belonging to the index.
  120. A `RoutingMissingException` is now thrown instead.
  121. === Mappings
  122. * The setting `index.mapping.allow_type_wrapper` has been removed. Documents should always be sent without the type as the root element.
  123. * The delete mappings API has been removed. Mapping types can no longer be deleted.
  124. ==== Removed type prefix on field names in queries
  125. Types can no longer be specified on fields within queries. Instead, specify type restrictions in the search request.
  126. The following is an example query in 1.x over types `t1` and `t2`:
  127. [source,json]
  128. ---------------
  129. curl -XGET 'localhost:9200/index/_search'
  130. {
  131. "query": {
  132. "bool": {
  133. "should": [
  134. {"match": { "t1.field_only_in_t1": "foo" }},
  135. {"match": { "t2.field_only_in_t2": "bar" }}
  136. ]
  137. }
  138. }
  139. }
  140. ---------------
  141. In 2.0, the query should look like the following:
  142. [source,json]
  143. ---------------
  144. curl -XGET 'localhost:9200/index/t1,t2/_search'
  145. {
  146. "query": {
  147. "bool": {
  148. "should": [
  149. {"match": { "field_only_in_t1": "foo" }},
  150. {"match": { "field_only_in_t2": "bar" }}
  151. ]
  152. }
  153. }
  154. }
  155. ---------------
  156. ==== Removed short name field access
  157. Field names in queries, aggregations, etc. must now use the complete name. Use of the short name
  158. caused ambiguities in field lookups when the same name existed within multiple object mappings.
  159. The following example illustrates the difference between 1.x and 2.0.
  160. Given these mappings:
  161. [source,json]
  162. ---------------
  163. curl -XPUT 'localhost:9200/index'
  164. {
  165. "mappings": {
  166. "type": {
  167. "properties": {
  168. "name": {
  169. "type": "object",
  170. "properties": {
  171. "first": {"type": "string"},
  172. "last": {"type": "string"}
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. ---------------
  180. The following query was possible in 1.x:
  181. [source,json]
  182. ---------------
  183. curl -XGET 'localhost:9200/index/type/_search'
  184. {
  185. "query": {
  186. "match": { "first": "foo" }
  187. }
  188. }
  189. ---------------
  190. In 2.0, the same query should now be:
  191. [source,json]
  192. ---------------
  193. curl -XGET 'localhost:9200/index/type/_search'
  194. {
  195. "query": {
  196. "match": { "name.first": "foo" }
  197. }
  198. }
  199. ---------------
  200. ==== Meta fields have limited configuration
  201. Meta fields (those beginning with underscore) are fields used by elasticsearch
  202. to provide special features. They now have limited configuration options.
  203. * `_id` configuration can no longer be changed. If you need to sort, use `_uid` instead.
  204. * `_type` configuration can no longer be changed.
  205. * `_index` configuration is limited to enabling the field.
  206. * `_routing` configuration is limited to requiring the field.
  207. * `_boost` has been removed.
  208. * `_field_names` configuration is limited to disabling the field.
  209. * `_size` configuration is limited to enabling the field.
  210. ==== Boolean fields
  211. Boolean fields used to have a string fielddata with `F` meaning `false` and `T`
  212. meaning `true`. They have been refactored to use numeric fielddata, with `0`
  213. for `false` and `1` for `true`. As a consequence, the format of the responses of
  214. the following APIs changed when applied to boolean fields: `0`/`1` is returned
  215. instead of `F`/`T`:
  216. - <<search-request-fielddata-fields,fielddata fields>>
  217. - <<search-request-sort,sort values>>
  218. - <<search-aggregations-bucket-terms-aggregation,terms aggregations>>
  219. In addition, terms aggregations use a custom formatter for boolean (like for
  220. dates and ip addresses, which are also backed by numbers) in order to return
  221. the user-friendly representation of boolean fields: `false`/`true`:
  222. [source,json]
  223. ---------------
  224. "buckets": [
  225. {
  226. "key": 0,
  227. "key_as_string": "false",
  228. "doc_count": 42
  229. },
  230. {
  231. "key": 1,
  232. "key_as_string": "true",
  233. "doc_count": 12
  234. }
  235. ]
  236. ---------------
  237. ==== Murmur3 Fields
  238. Fields of type `murmur3` can no longer change `doc_values` or `index` setting.
  239. They are always stored with doc values, and not indexed.
  240. ==== Source field configuration
  241. The `_source` field no longer supports `includes` and `excludes` paramters. When
  242. `_source` is enabled, the entire original source will be stored.
  243. ==== Config based mappings
  244. The ability to specify mappings in configuration files has been removed. To specify
  245. default mappings that apply to multiple indexes, use index templates.
  246. The following settings are no longer valid:
  247. * `index.mapper.default_mapping_location`
  248. * `index.mapper.default_percolator_mapping_location`
  249. === Codecs
  250. It is no longer possible to specify per-field postings and doc values formats
  251. in the mappings. This setting will be ignored on indices created before
  252. elasticsearch 2.0 and will cause mapping parsing to fail on indices created on
  253. or after 2.0. For old indices, this means that new segments will be written
  254. with the default postings and doc values formats of the current codec.
  255. It is still possible to change the whole codec by using the `index.codec`
  256. setting. Please however note that using a non-default codec is discouraged as
  257. it could prevent future versions of Elasticsearch from being able to read the
  258. index.
  259. === Scripting settings
  260. Removed support for `script.disable_dynamic` node setting, replaced by
  261. fine-grained script settings described in the <<enable-dynamic-scripting,scripting docs>>.
  262. The following setting previously used to enable dynamic scripts:
  263. [source,yaml]
  264. ---------------
  265. script.disable_dynamic: false
  266. ---------------
  267. can be replaced with the following two settings in `elasticsearch.yml` that
  268. achieve the same result:
  269. [source,yaml]
  270. ---------------
  271. script.inline: on
  272. script.indexed: on
  273. ---------------
  274. === Script parameters
  275. Deprecated script parameters `id`, `file`, and `scriptField` have been removed
  276. from all scriptable APIs. `script_id`, `script_file` and `script` should be used
  277. in their place.
  278. === Groovy scripts sandbox
  279. The groovy sandbox and related settings have been removed. Groovy is now a non
  280. sandboxed scripting language, without any option to turn the sandbox on.
  281. === Plugins making use of scripts
  282. Plugins that make use of scripts must register their own script context through
  283. `ScriptModule`. Script contexts can be used as part of fine-grained settings to
  284. enable/disable scripts selectively.
  285. === Thrift and memcached transport
  286. The thrift and memcached transport plugins are no longer supported. Instead, use
  287. either the HTTP transport (enabled by default) or the node or transport Java client.
  288. === `search_type=count` deprecation
  289. The `count` search type has been deprecated. All benefits from this search type can
  290. now be achieved by using the `query_then_fetch` search type (which is the
  291. default) and setting `size` to `0`.
  292. === JSONP support
  293. JSONP callback support has now been removed. CORS should be used to access Elasticsearch
  294. over AJAX instead:
  295. [source,yaml]
  296. ---------------
  297. http.cors.enabled: true
  298. http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/
  299. ---------------
  300. === Cluster state REST api
  301. The cluster state api doesn't return the `routing_nodes` section anymore when
  302. `routing_table` is requested. The newly introduced `routing_nodes` flag can
  303. be used separately to control whether `routing_nodes` should be returned.
  304. === Query DSL
  305. Change to ranking behaviour: single-term queries on numeric fields now score in the same way as string fields (use of IDF, norms if enabled).
  306. Previously, term queries on numeric fields were deliberately prevented from using the usual Lucene scoring logic and this behaviour was undocumented and, to some, unexpected.
  307. If the introduction of scoring to numeric fields is undesirable for your query clauses the fix is simple: wrap them in a `constant_score` or use a `filter` expression instead.
  308. The `fuzzy_like_this` and `fuzzy_like_this_field` queries have been removed.
  309. The `limit` filter is deprecated and becomes a no-op. You can achieve similar
  310. behaviour using the <<search-request-body,terminate_after>> parameter.
  311. `or` and `and` on the one hand and `bool` on the other hand used to have
  312. different performance characteristics depending on the wrapped filters. This is
  313. fixed now, as a consequence the `or` and `and` filters are now deprecated in
  314. favour or `bool`.
  315. The `execution` option of the `terms` filter is now deprecated and ignored if
  316. provided.
  317. The `_cache` and `_cache_key` parameters of filters are deprecated in the REST
  318. layer and removed in the Java API. In case they are specified they will be
  319. ignored. Instead filters are always used as their own cache key and elasticsearch
  320. makes decisions by itself about whether it should cache filters based on how
  321. often they are used.
  322. === Snapshot and Restore
  323. The obsolete parameters `expand_wildcards_open` and `expand_wildcards_close` are no longer
  324. supported by the snapshot and restore operations. These parameters have been replaced by
  325. a single `expand_wildcards` parameter. See <<multi-index,the multi-index docs>> for more.
  326. === `_shutdown` API
  327. The `_shutdown` API has been removed without a replacement. Nodes should be managed via operating
  328. systems and the provided start/stop scripts.
  329. === Analyze API
  330. The Analyze API return 0 as first Token's position instead of 1.
  331. === Multiple data.path striping
  332. Previously, if the `data.path` setting listed multiple data paths, then a
  333. shard would be ``striped'' across all paths by writing a whole file to each
  334. path in turn (in accordance with the `index.store.distributor` setting). The
  335. result was that the files from a single segment in a shard could be spread
  336. across multiple disks, and the failure of any one disk could corrupt multiple
  337. shards.
  338. This striping is no longer supported. Instead, different shards may be
  339. allocated to different paths, but all of the files in a single shard will be
  340. written to the same path.
  341. If striping is detected while starting Elasticsearch 2.0.0 or later, all of
  342. the files belonging to the same shard will be migrated to the same path. If
  343. there is not enough disk space to complete this migration, the upgrade will be
  344. cancelled and can only be resumed once enough disk space is made available.
  345. The `index.store.distributor` setting has also been removed.