migrate_2_0.asciidoc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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
  19. The More Like This API and the More Like This Field query have been removed in
  20. favor of the <<query-dsl-mlt-query, More Like This Query>>.
  21. The parameter `percent_terms_to_match` has been removed in favor of
  22. `minimum_should_match`.
  23. === Routing
  24. The default hash function that is used for routing has been changed from djb2 to
  25. murmur3. This change should be transparent unless you relied on very specific
  26. properties of djb2. This will help ensure a better balance of the document counts
  27. between shards.
  28. In addition, the following node settings related to routing have been deprecated:
  29. [horizontal]
  30. `cluster.routing.operation.hash.type`::
  31. This was an undocumented setting that allowed to configure which hash function
  32. to use for routing. `murmur3` is now enforced on new indices.
  33. `cluster.routing.operation.use_type`::
  34. This was an undocumented setting that allowed to take the `_type` of the
  35. document into account when computing its shard (default: `false`). `false` is
  36. now enforced on new indices.
  37. === Async replication
  38. The `replication` parameter has been removed from all CRUD operations (index,
  39. update, delete, bulk, delete-by-query). These operations are now synchronous
  40. only, and a request will only return once the changes have been replicated to
  41. all active shards in the shard group.
  42. === Store
  43. The `memory` / `ram` store (`index.store.type`) option was removed in Elasticsearch 2.0.
  44. === Term Vectors API
  45. Usage of `/_termvector` is deprecated, and replaced in favor of `/_termvectors`.
  46. === Script fields
  47. Script fields in 1.x were only returned as a single value. So even if the return
  48. value of a script used to be list, it would be returned as an array containing
  49. a single value that is a list too, such as:
  50. [source,json]
  51. ---------------
  52. "fields": {
  53. "my_field": [
  54. [
  55. "v1",
  56. "v2"
  57. ]
  58. ]
  59. }
  60. ---------------
  61. In elasticsearch 2.x, scripts that return a list of values are considered as
  62. multivalued fields. So the same example would return the following response,
  63. with values in a single array.
  64. [source,json]
  65. ---------------
  66. "fields": {
  67. "my_field": [
  68. "v1",
  69. "v2"
  70. ]
  71. }
  72. ---------------
  73. === Main API
  74. Previously, calling `GET /` was giving back the http status code within the json response
  75. in addition to the actual HTTP status code. We removed `status` field in json response.
  76. === Java API
  77. `org.elasticsearch.index.queries.FilterBuilders` has been removed as part of the merge of
  78. queries and filters. These filters are now available in `QueryBuilders` with the same name.
  79. All methods that used to accept a `FilterBuilder` now accept a `QueryBuilder` instead.
  80. In addition some query builders have been removed or renamed:
  81. * `commonTerms(...)` renamed with `commonTermsQuery(...)`
  82. * `queryString(...)` renamed with `queryStringQuery(...)`
  83. * `simpleQueryString(...)` renamed with `simpleQueryStringQuery(...)`
  84. * `textPhrase(...)` removed
  85. * `textPhrasePrefix(...)` removed
  86. * `textPhrasePrefixQuery(...)` removed
  87. * `filtered(...)` removed. Use `filteredQuery(...)` instead.
  88. * `inQuery(...)` removed.
  89. === Aggregations
  90. The `date_histogram` aggregation now returns a `Histogram` object in the response, and the `DateHistogram` class has been removed. Similarly
  91. the `date_range`, `ipv4_range`, and `geo_distance` aggregations all return a `Range` object in the response, and the `IPV4Range`, `DateRange`,
  92. and `GeoDistance` classes have been removed. The motivation for this is to have a single response API for the Range and Histogram aggregations
  93. regardless of the type of data being queried. To support this some changes were made in the `MultiBucketAggregation` interface which applies
  94. to all bucket aggregations:
  95. * The `getKey()` method now returns `Object` instead of `String`. The actual object type returned depends on the type of aggregation requested
  96. (e.g. the `date_histogram` will return a `DateTime` object for this method whereas a `histogram` will return a `Number`).
  97. * A `getKeyAsString()` method has been added to return the String representation of the key.
  98. * All other `getKeyAsX()` methods have been removed.
  99. * The `getBucketAsKey(String)` methods have been removed on all aggregations except the `filters` and `terms` aggregations.
  100. The `histogram` and the `date_histogram` aggregation now support a simplified `offset` option that replaces the previous `pre_offset` and
  101. `post_offset` rounding options. Instead of having to specify two separate offset shifts of the underlying buckets, the `offset` option
  102. moves the bucket boundaries in positive or negative direction depending on its argument.
  103. The `date_histogram` options for `pre_zone` and `post_zone` are replaced by the `time_zone` option. The behavior of `time_zone` is
  104. equivalent to the former `pre_zone` option. Setting `time_zone` to a value like "+01:00" now will lead to the bucket calculations
  105. being applied in the specified time zone but In addition to this, also the `pre_zone_adjust_large_interval` is removed because we
  106. now always return dates and bucket keys in UTC.
  107. Both the `histogram` and `date_histogram` aggregations now have a default `min_doc_count` of `0` instead of `1` previously.
  108. `include`/`exclude` filtering on the `terms` aggregation now uses the same syntax as regexp queries instead of the Java syntax. While simple
  109. regexps should still work, more complex ones might need some rewriting. Also, the `flags` parameter is not supported anymore.
  110. === Terms filter lookup caching
  111. The terms filter lookup mechanism does not support the `cache` option anymore
  112. and relies on the filesystem cache instead. If the lookup index is not too
  113. large, it is recommended to make it replicated to all nodes by setting
  114. `index.auto_expand_replicas: 0-all` in order to remove the network overhead as
  115. well.
  116. === Delete by query
  117. The meaning of the `_shards` headers in the delete by query response has changed. Before version 2.0 the `total`,
  118. `successful` and `failed` fields in the header are based on the number of primary shards. The failures on replica
  119. shards aren't being kept track of. From version 2.0 the stats in the `_shards` header are based on all shards
  120. of an index. The http status code is left unchanged and is only based on failures that occurred while executing on
  121. primary shards.
  122. === Delete api with missing routing when required
  123. Delete api requires a routing value when deleting a document belonging to a type that has routing set to required in its
  124. mapping, whereas previous elasticsearch versions would trigger a broadcast delete on all shards belonging to the index.
  125. A `RoutingMissingException` is now thrown instead.
  126. === Mappings
  127. * The setting `index.mapping.allow_type_wrapper` has been removed. Documents should always be sent without the type as the root element.
  128. * The delete mappings API has been removed. Mapping types can no longer be deleted.
  129. * The `ignore_conflicts` option of the put mappings API has been removed. Conflicts can't be ignored anymore.
  130. ==== Removed type prefix on field names in queries
  131. Types can no longer be specified on fields within queries. Instead, specify type restrictions in the search request.
  132. The following is an example query in 1.x over types `t1` and `t2`:
  133. [source,json]
  134. ---------------
  135. curl -XGET 'localhost:9200/index/_search'
  136. {
  137. "query": {
  138. "bool": {
  139. "should": [
  140. {"match": { "t1.field_only_in_t1": "foo" }},
  141. {"match": { "t2.field_only_in_t2": "bar" }}
  142. ]
  143. }
  144. }
  145. }
  146. ---------------
  147. In 2.0, the query should look like the following:
  148. [source,json]
  149. ---------------
  150. curl -XGET 'localhost:9200/index/t1,t2/_search'
  151. {
  152. "query": {
  153. "bool": {
  154. "should": [
  155. {"match": { "field_only_in_t1": "foo" }},
  156. {"match": { "field_only_in_t2": "bar" }}
  157. ]
  158. }
  159. }
  160. }
  161. ---------------
  162. ==== Removed short name field access
  163. Field names in queries, aggregations, etc. must now use the complete name. Use of the short name
  164. caused ambiguities in field lookups when the same name existed within multiple object mappings.
  165. The following example illustrates the difference between 1.x and 2.0.
  166. Given these mappings:
  167. [source,json]
  168. ---------------
  169. curl -XPUT 'localhost:9200/index'
  170. {
  171. "mappings": {
  172. "type": {
  173. "properties": {
  174. "name": {
  175. "type": "object",
  176. "properties": {
  177. "first": {"type": "string"},
  178. "last": {"type": "string"}
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. ---------------
  186. The following query was possible in 1.x:
  187. [source,json]
  188. ---------------
  189. curl -XGET 'localhost:9200/index/type/_search'
  190. {
  191. "query": {
  192. "match": { "first": "foo" }
  193. }
  194. }
  195. ---------------
  196. In 2.0, the same query should now be:
  197. [source,json]
  198. ---------------
  199. curl -XGET 'localhost:9200/index/type/_search'
  200. {
  201. "query": {
  202. "match": { "name.first": "foo" }
  203. }
  204. }
  205. ---------------
  206. ==== Meta fields have limited configuration
  207. Meta fields (those beginning with underscore) are fields used by elasticsearch
  208. to provide special features. They now have limited configuration options.
  209. * `_id` configuration can no longer be changed. If you need to sort, use `_uid` instead.
  210. * `_type` configuration can no longer be changed.
  211. * `_index` configuration is limited to enabling the field.
  212. * `_routing` configuration is limited to requiring the field.
  213. * `_boost` has been removed.
  214. * `_field_names` configuration is limited to disabling the field.
  215. * `_size` configuration is limited to enabling the field.
  216. ==== Meta fields in documents
  217. Meta fields can no longer be specified within a document. They should be specified
  218. via the API. For example, instead of adding a field `_parent` within a document,
  219. use the `parent` url parameter when indexing that document.
  220. ==== Source field limitations
  221. The `_source` field could previously be disabled dynamically. Since this field
  222. is a critical piece of many features like the Update API, it is no longer
  223. possible to disable.
  224. The options for `compress` and `compress_threshold` have also been removed.
  225. The source field is already compressed. To minimize the storage cost,
  226. set `index.codec: best_compression` in index settings.
  227. ==== Boolean fields
  228. Boolean fields used to have a string fielddata with `F` meaning `false` and `T`
  229. meaning `true`. They have been refactored to use numeric fielddata, with `0`
  230. for `false` and `1` for `true`. As a consequence, the format of the responses of
  231. the following APIs changed when applied to boolean fields: `0`/`1` is returned
  232. instead of `F`/`T`:
  233. - <<search-request-fielddata-fields,fielddata fields>>
  234. - <<search-request-sort,sort values>>
  235. - <<search-aggregations-bucket-terms-aggregation,terms aggregations>>
  236. In addition, terms aggregations use a custom formatter for boolean (like for
  237. dates and ip addresses, which are also backed by numbers) in order to return
  238. the user-friendly representation of boolean fields: `false`/`true`:
  239. [source,json]
  240. ---------------
  241. "buckets": [
  242. {
  243. "key": 0,
  244. "key_as_string": "false",
  245. "doc_count": 42
  246. },
  247. {
  248. "key": 1,
  249. "key_as_string": "true",
  250. "doc_count": 12
  251. }
  252. ]
  253. ---------------
  254. ==== Murmur3 Fields
  255. Fields of type `murmur3` can no longer change `doc_values` or `index` setting.
  256. They are always stored with doc values, and not indexed.
  257. ==== Source field configuration
  258. The `_source` field no longer supports `includes` and `excludes` parameters. When
  259. `_source` is enabled, the entire original source will be stored.
  260. ==== Config based mappings
  261. The ability to specify mappings in configuration files has been removed. To specify
  262. default mappings that apply to multiple indexes, use index templates.
  263. The following settings are no longer valid:
  264. * `index.mapper.default_mapping_location`
  265. * `index.mapper.default_percolator_mapping_location`
  266. === Codecs
  267. It is no longer possible to specify per-field postings and doc values formats
  268. in the mappings. This setting will be ignored on indices created before
  269. elasticsearch 2.0 and will cause mapping parsing to fail on indices created on
  270. or after 2.0. For old indices, this means that new segments will be written
  271. with the default postings and doc values formats of the current codec.
  272. It is still possible to change the whole codec by using the `index.codec`
  273. setting. Please however note that using a non-default codec is discouraged as
  274. it could prevent future versions of Elasticsearch from being able to read the
  275. index.
  276. === Scripting settings
  277. Removed support for `script.disable_dynamic` node setting, replaced by
  278. fine-grained script settings described in the <<enable-dynamic-scripting,scripting docs>>.
  279. The following setting previously used to enable dynamic scripts:
  280. [source,yaml]
  281. ---------------
  282. script.disable_dynamic: false
  283. ---------------
  284. can be replaced with the following two settings in `elasticsearch.yml` that
  285. achieve the same result:
  286. [source,yaml]
  287. ---------------
  288. script.inline: on
  289. script.indexed: on
  290. ---------------
  291. === Script parameters
  292. Deprecated script parameters `id`, `file`, and `scriptField` have been removed
  293. from all scriptable APIs. `script_id`, `script_file` and `script` should be used
  294. in their place.
  295. === Groovy scripts sandbox
  296. The groovy sandbox and related settings have been removed. Groovy is now a non
  297. sandboxed scripting language, without any option to turn the sandbox on.
  298. === Plugins making use of scripts
  299. Plugins that make use of scripts must register their own script context through
  300. `ScriptModule`. Script contexts can be used as part of fine-grained settings to
  301. enable/disable scripts selectively.
  302. === Thrift and memcached transport
  303. The thrift and memcached transport plugins are no longer supported. Instead, use
  304. either the HTTP transport (enabled by default) or the node or transport Java client.
  305. === `search_type=count` deprecation
  306. The `count` search type has been deprecated. All benefits from this search type can
  307. now be achieved by using the `query_then_fetch` search type (which is the
  308. default) and setting `size` to `0`.
  309. === JSONP support
  310. JSONP callback support has now been removed. CORS should be used to access Elasticsearch
  311. over AJAX instead:
  312. [source,yaml]
  313. ---------------
  314. http.cors.enabled: true
  315. http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/
  316. ---------------
  317. === Cluster state REST api
  318. The cluster state api doesn't return the `routing_nodes` section anymore when
  319. `routing_table` is requested. The newly introduced `routing_nodes` flag can
  320. be used separately to control whether `routing_nodes` should be returned.
  321. === Query DSL
  322. 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).
  323. 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.
  324. 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.
  325. The `filtered` query is deprecated. Instead you should use a `bool` query with
  326. a `must` clause for the query and a `filter` clause for the filter. For instance
  327. the below query:
  328. [source,json]
  329. ---------------
  330. {
  331. "filtered": {
  332. "query": {
  333. // query
  334. },
  335. "filter": {
  336. // filter
  337. }
  338. }
  339. }
  340. ---------------
  341. can be replaced with
  342. [source,json]
  343. ---------------
  344. {
  345. "bool": {
  346. "must": {
  347. // query
  348. },
  349. "filter": {
  350. // filter
  351. }
  352. }
  353. }
  354. ---------------
  355. and will produce the same scores.
  356. The `fuzzy_like_this` and `fuzzy_like_this_field` queries have been removed.
  357. The `limit` filter is deprecated and becomes a no-op. You can achieve similar
  358. behaviour using the <<search-request-body,terminate_after>> parameter.
  359. `or` and `and` on the one hand and `bool` on the other hand used to have
  360. different performance characteristics depending on the wrapped filters. This is
  361. fixed now, as a consequence the `or` and `and` filters are now deprecated in
  362. favour or `bool`.
  363. The `execution` option of the `terms` filter is now deprecated and ignored if
  364. provided.
  365. The `_cache` and `_cache_key` parameters of filters are deprecated in the REST
  366. layer and removed in the Java API. In case they are specified they will be
  367. ignored. Instead filters are always used as their own cache key and elasticsearch
  368. makes decisions by itself about whether it should cache filters based on how
  369. often they are used.
  370. ==== Query/filter merge
  371. Elasticsearch no longer makes a difference between queries and filters in the
  372. DSL; it detects when scores are not needed and automatically optimizes the
  373. query to not compute scores and optionally caches the result.
  374. As a consequence the `query` filter serves no purpose anymore and is deprecated.
  375. === Snapshot and Restore
  376. Locations of file system repositories has to be now registered using `path.repo` setting. The `path.repo`
  377. setting can contain one or more repository locations:
  378. [source,yaml]
  379. ---------------
  380. path.repo: ["/mnt/daily", "/mnt/weekly"]
  381. ---------------
  382. If the file system repository location is specified as an absolute path it has to start with one of the locations
  383. specified in `path.repo`. If the location is specified as a relative path, it will be resolved against the first
  384. location specified in the `path.repo` setting.
  385. The obsolete parameters `expand_wildcards_open` and `expand_wildcards_close` are no longer
  386. supported by the snapshot and restore operations. These parameters have been replaced by
  387. a single `expand_wildcards` parameter. See <<multi-index,the multi-index docs>> for more.
  388. === `_shutdown` API
  389. The `_shutdown` API has been removed without a replacement. Nodes should be managed via operating
  390. systems and the provided start/stop scripts.
  391. === Analyze API
  392. * The Analyze API return 0 as first Token's position instead of 1.
  393. * The `text()` method on `AnalyzeRequest` now returns `String[]` instead of `String`.
  394. === Multiple data.path striping
  395. Previously, if the `data.path` setting listed multiple data paths, then a
  396. shard would be ``striped'' across all paths by writing a whole file to each
  397. path in turn (in accordance with the `index.store.distributor` setting). The
  398. result was that the files from a single segment in a shard could be spread
  399. across multiple disks, and the failure of any one disk could corrupt multiple
  400. shards.
  401. This striping is no longer supported. Instead, different shards may be
  402. allocated to different paths, but all of the files in a single shard will be
  403. written to the same path.
  404. If striping is detected while starting Elasticsearch 2.0.0 or later, all of
  405. the files belonging to the same shard will be migrated to the same path. If
  406. there is not enough disk space to complete this migration, the upgrade will be
  407. cancelled and can only be resumed once enough disk space is made available.
  408. The `index.store.distributor` setting has also been removed.
  409. === Hunspell dictionary configuration
  410. The parameter `indices.analysis.hunspell.dictionary.location` has been removed,
  411. and `<path.conf>/hunspell` is always used.
  412. === Java API Transport API construction
  413. The `TransportClient` construction code has changed, it now uses the builder
  414. pattern. Instead of using:
  415. [source,java]
  416. --------------------------------------------------
  417. Settings settings = ImmutableSettings.settingsBuilder()
  418. .put("cluster.name", "myClusterName").build();
  419. Client client = new TransportClient(settings);
  420. --------------------------------------------------
  421. Use:
  422. [source,java]
  423. --------------------------------------------------
  424. Settings settings = ImmutableSettings.settingsBuilder()
  425. .put("cluster.name", "myClusterName").build();
  426. Client client = TransportClient.builder().settings(settings).build();
  427. --------------------------------------------------
  428. === Logging
  429. Log messages are now truncated at 10,000 characters. This can be changed in the
  430. `logging.yml` configuration file.
  431. [float]
  432. === Removed `top_children` query
  433. The `top_children` query has been removed in favour of the `has_child` query. The `top_children` query wasn't always faster
  434. than the `has_child` query and the `top_children` query was often inaccurate. The total hits and any aggregations in the
  435. same search request will likely be off if `top_children` was used.
  436. === Removed file based index templates
  437. Index templates can no longer be configured on disk. Use the `_template` API instead.
  438. [float]
  439. === Removed `id_cache` from stats apis
  440. Removed `id_cache` metric from nodes stats, indices stats and cluster stats apis. This metric has also been removed
  441. from the shards cat, indices cat and nodes cat apis. Parent/child memory is now reported under fielddata, because it
  442. has internally be using fielddata for a while now.
  443. To just see how much parent/child related field data is taking, the `fielddata_fields` option can be used on the stats
  444. apis. Indices stats example:
  445. [source,js]
  446. --------------------------------------------------
  447. curl -XGET "http://localhost:9200/_stats/fielddata?pretty&human&fielddata_fields=_parent"
  448. --------------------------------------------------
  449. Parent/child is using field data for the `_parent` field since version `1.1.0`, but the memory stats for the `_parent`
  450. field were still shown under `id_cache` metric in the stats apis for backwards compatible reasons between 1.x versions.
  451. Before version `1.1.0` the parent/child had its own in-memory data structures for id values in the `_parent` field.
  452. [float]
  453. === Removed `id_cache` from clear cache api
  454. Removed `id_cache` option from the clear cache apis. The `fielddata` option should be used to clear `_parent` field
  455. from fielddata.
  456. [float]
  457. === Highlighting
  458. The default value for the `require_field_match` option is `true` rather than
  459. `false`, meaning that the highlighters will take the fields that were queried
  460. into account by default. That means for instance that highlighting any field
  461. when querying the `_all` field will produce no highlighted snippets by default,
  462. given that the match was on the `_all` field only. Querying the same fields
  463. that need to be highlighted is the cleaner solution to get highlighted snippets
  464. back. Otherwise `require_field_match` option can be set to `false` to ignore
  465. field names completely when highlighting.
  466. The postings highlighter doesn't support the `require_field_match` option
  467. anymore, it will only highlight fields that were queried.
  468. The `match` query with type set to `match_phrase_prefix` is not supported by the
  469. postings highlighter. No highlighted snippets will be returned.