migrate_2_0.asciidoc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. ==== Source field limitations
  211. The `_source` field could previously be disabled dynamically. Since this field
  212. is a critical piece of many features like the Update API, it is no longer
  213. possible to disable.
  214. The options for `compress` and `compress_threshold` have also been removed.
  215. The source field is already compressed. To minimize the storage cost,
  216. set `index.codec: best_compression` in index settings.
  217. ==== Boolean fields
  218. Boolean fields used to have a string fielddata with `F` meaning `false` and `T`
  219. meaning `true`. They have been refactored to use numeric fielddata, with `0`
  220. for `false` and `1` for `true`. As a consequence, the format of the responses of
  221. the following APIs changed when applied to boolean fields: `0`/`1` is returned
  222. instead of `F`/`T`:
  223. - <<search-request-fielddata-fields,fielddata fields>>
  224. - <<search-request-sort,sort values>>
  225. - <<search-aggregations-bucket-terms-aggregation,terms aggregations>>
  226. In addition, terms aggregations use a custom formatter for boolean (like for
  227. dates and ip addresses, which are also backed by numbers) in order to return
  228. the user-friendly representation of boolean fields: `false`/`true`:
  229. [source,json]
  230. ---------------
  231. "buckets": [
  232. {
  233. "key": 0,
  234. "key_as_string": "false",
  235. "doc_count": 42
  236. },
  237. {
  238. "key": 1,
  239. "key_as_string": "true",
  240. "doc_count": 12
  241. }
  242. ]
  243. ---------------
  244. ==== Murmur3 Fields
  245. Fields of type `murmur3` can no longer change `doc_values` or `index` setting.
  246. They are always stored with doc values, and not indexed.
  247. ==== Source field configuration
  248. The `_source` field no longer supports `includes` and `excludes` parameters. When
  249. `_source` is enabled, the entire original source will be stored.
  250. ==== Config based mappings
  251. The ability to specify mappings in configuration files has been removed. To specify
  252. default mappings that apply to multiple indexes, use index templates.
  253. The following settings are no longer valid:
  254. * `index.mapper.default_mapping_location`
  255. * `index.mapper.default_percolator_mapping_location`
  256. === Codecs
  257. It is no longer possible to specify per-field postings and doc values formats
  258. in the mappings. This setting will be ignored on indices created before
  259. elasticsearch 2.0 and will cause mapping parsing to fail on indices created on
  260. or after 2.0. For old indices, this means that new segments will be written
  261. with the default postings and doc values formats of the current codec.
  262. It is still possible to change the whole codec by using the `index.codec`
  263. setting. Please however note that using a non-default codec is discouraged as
  264. it could prevent future versions of Elasticsearch from being able to read the
  265. index.
  266. === Scripting settings
  267. Removed support for `script.disable_dynamic` node setting, replaced by
  268. fine-grained script settings described in the <<enable-dynamic-scripting,scripting docs>>.
  269. The following setting previously used to enable dynamic scripts:
  270. [source,yaml]
  271. ---------------
  272. script.disable_dynamic: false
  273. ---------------
  274. can be replaced with the following two settings in `elasticsearch.yml` that
  275. achieve the same result:
  276. [source,yaml]
  277. ---------------
  278. script.inline: on
  279. script.indexed: on
  280. ---------------
  281. === Script parameters
  282. Deprecated script parameters `id`, `file`, and `scriptField` have been removed
  283. from all scriptable APIs. `script_id`, `script_file` and `script` should be used
  284. in their place.
  285. === Groovy scripts sandbox
  286. The groovy sandbox and related settings have been removed. Groovy is now a non
  287. sandboxed scripting language, without any option to turn the sandbox on.
  288. === Plugins making use of scripts
  289. Plugins that make use of scripts must register their own script context through
  290. `ScriptModule`. Script contexts can be used as part of fine-grained settings to
  291. enable/disable scripts selectively.
  292. === Thrift and memcached transport
  293. The thrift and memcached transport plugins are no longer supported. Instead, use
  294. either the HTTP transport (enabled by default) or the node or transport Java client.
  295. === `search_type=count` deprecation
  296. The `count` search type has been deprecated. All benefits from this search type can
  297. now be achieved by using the `query_then_fetch` search type (which is the
  298. default) and setting `size` to `0`.
  299. === JSONP support
  300. JSONP callback support has now been removed. CORS should be used to access Elasticsearch
  301. over AJAX instead:
  302. [source,yaml]
  303. ---------------
  304. http.cors.enabled: true
  305. http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/
  306. ---------------
  307. === Cluster state REST api
  308. The cluster state api doesn't return the `routing_nodes` section anymore when
  309. `routing_table` is requested. The newly introduced `routing_nodes` flag can
  310. be used separately to control whether `routing_nodes` should be returned.
  311. === Query DSL
  312. 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).
  313. 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.
  314. 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.
  315. The `fuzzy_like_this` and `fuzzy_like_this_field` queries have been removed.
  316. The `limit` filter is deprecated and becomes a no-op. You can achieve similar
  317. behaviour using the <<search-request-body,terminate_after>> parameter.
  318. `or` and `and` on the one hand and `bool` on the other hand used to have
  319. different performance characteristics depending on the wrapped filters. This is
  320. fixed now, as a consequence the `or` and `and` filters are now deprecated in
  321. favour or `bool`.
  322. The `execution` option of the `terms` filter is now deprecated and ignored if
  323. provided.
  324. The `_cache` and `_cache_key` parameters of filters are deprecated in the REST
  325. layer and removed in the Java API. In case they are specified they will be
  326. ignored. Instead filters are always used as their own cache key and elasticsearch
  327. makes decisions by itself about whether it should cache filters based on how
  328. often they are used.
  329. === Snapshot and Restore
  330. The obsolete parameters `expand_wildcards_open` and `expand_wildcards_close` are no longer
  331. supported by the snapshot and restore operations. These parameters have been replaced by
  332. a single `expand_wildcards` parameter. See <<multi-index,the multi-index docs>> for more.
  333. === `_shutdown` API
  334. The `_shutdown` API has been removed without a replacement. Nodes should be managed via operating
  335. systems and the provided start/stop scripts.
  336. === Analyze API
  337. The Analyze API return 0 as first Token's position instead of 1.
  338. === Multiple data.path striping
  339. Previously, if the `data.path` setting listed multiple data paths, then a
  340. shard would be ``striped'' across all paths by writing a whole file to each
  341. path in turn (in accordance with the `index.store.distributor` setting). The
  342. result was that the files from a single segment in a shard could be spread
  343. across multiple disks, and the failure of any one disk could corrupt multiple
  344. shards.
  345. This striping is no longer supported. Instead, different shards may be
  346. allocated to different paths, but all of the files in a single shard will be
  347. written to the same path.
  348. If striping is detected while starting Elasticsearch 2.0.0 or later, all of
  349. the files belonging to the same shard will be migrated to the same path. If
  350. there is not enough disk space to complete this migration, the upgrade will be
  351. cancelled and can only be resumed once enough disk space is made available.
  352. The `index.store.distributor` setting has also been removed.
  353. === Hunspell dictionary configuration
  354. The parameter `indices.analysis.hunspell.dictionary.location` has been removed,
  355. and `<path.conf>/hunspell` is always used.
  356. === Java API Transport API construction
  357. The `TransportClient` construction code has changed, it now uses the builder
  358. pattern. Instead of using:
  359. [source,java]
  360. --------------------------------------------------
  361. Settings settings = ImmutableSettings.settingsBuilder()
  362. .put("cluster.name", "myClusterName").build();
  363. Client client = new TransportClient(settings);
  364. --------------------------------------------------
  365. Use:
  366. [source,java]
  367. --------------------------------------------------
  368. Settings settings = ImmutableSettings.settingsBuilder()
  369. .put("cluster.name", "myClusterName").build();
  370. Client client = TransportClient.builder().settings(settings).build();
  371. --------------------------------------------------