1# Changes in Elastic 5.0 2 3## Enforce context.Context in PerformRequest and Do 4 5We enforce the usage of `context.Context` everywhere you execute a request. 6You need to change all your `Do()` calls to pass a context: `Do(ctx)`. 7This enables automatic request cancelation and many other patterns. 8 9If you don't need this, simply pass `context.TODO()` or `context.Background()`. 10 11## Warmers removed 12 13Warmers are no longer necessary and have been [removed in ES 5.0](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_index_apis.html#_warmers). 14 15## Optimize removed 16 17Optimize was deprecated in ES 2.0 and has been [removed in ES 5.0](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_rest_api_changes.html#_literal__optimize_literal_endpoint_removed). 18Use [Force Merge](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html) instead. 19 20## Missing Query removed 21 22The `missing` query has been [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/query-dsl-exists-query.html#_literal_missing_literal_query). 23Use `exists` query with `must_not` in `bool` query instead. 24 25## And Query removed 26 27The `and` query has been [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_search_changes.html#_deprecated_queries_removed). 28Use `must` clauses in a `bool` query instead. 29 30## Not Query removed 31 32TODO Is it removed? 33 34## Or Query removed 35 36The `or` query has been [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_search_changes.html#_deprecated_queries_removed). 37Use `should` clauses in a `bool` query instead. 38 39## Filtered Query removed 40 41The `filtered` query has been [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_search_changes.html#_deprecated_queries_removed). 42Use `bool` query instead, which supports `filter` clauses too. 43 44## Limit Query removed 45 46The `limit` query has been [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_search_changes.html#_deprecated_queries_removed). 47Use the `terminate_after` parameter instead. 48 49# Template Query removed 50 51The `template` query has been [deprecated](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl-template-query.html). You should use 52Search Templates instead. 53 54We remove it from Elastic 5.0 as the 5.0 update is already a good opportunity 55to get rid of old stuff. 56 57## `_timestamp` and `_ttl` removed 58 59Both of these fields were deprecated and are now [removed](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_mapping_changes.html#_literal__timestamp_literal_and_literal__ttl_literal). 60 61## Search template Put/Delete API returns `acknowledged` only 62 63The response type for Put/Delete search templates has changed. 64It only returns a single `acknowledged` flag now. 65 66## Fields has been renamed to Stored Fields 67 68The `fields` parameter has been renamed to `stored_fields`. 69See [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/breaking_50_search_changes.html#_literal_fields_literal_parameter). 70 71## Fielddatafields has been renamed to Docvaluefields 72 73The `fielddata_fields` parameter [has been renamed](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/breaking_50_search_changes.html#_literal_fielddata_fields_literal_parameter) 74to `docvalue_fields`. 75 76## Type exists endpoint changed 77 78The endpoint for checking whether a type exists has been changed from 79`HEAD {index}/{type}` to `HEAD {index}/_mapping/{type}`. 80See [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_rest_api_changes.html#_literal_head_index_type_literal_replaced_with_literal_head_index__mapping_type_literal). 81 82## Refresh parameter changed 83 84The `?refresh` parameter previously could be a boolean value. It indicated 85whether changes made by a request (e.g. by the Bulk API) should be immediately 86visible in search, or not. Using `refresh=true` had the positive effect of 87immediately seeing the changes when searching; the negative effect is that 88it is a rather big performance hit. 89 90With 5.0, you now have the choice between these 3 values. 91 92* `"true"` - Refresh immediately 93* `"false"` - Do not refresh (the default value) 94* `"wait_for"` - Wait until ES made the document visible in search 95 96See [?refresh](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-refresh.html) in the documentation. 97 98Notice that `true` and `false` (the boolean values) are no longer available 99now in Elastic. You must use a string instead, with one of the above values. 100 101## ReindexerService removed 102 103The `ReindexerService` was a custom solution that was started in the ES 1.x era 104to automate reindexing data, from one index to another or even between clusters. 105 106ES 2.3 introduced its own [Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) 107so we're going to remove our custom solution and ask you to use the native reindexer. 108 109The `ReindexService` is available via `client.Reindex()` (which used to point 110to the custom reindexer). 111 112## Delete By Query back in core 113 114The [Delete By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) 115was moved into a plugin in 2.0. Now its back in core with a complete rewrite based on the Bulk API. 116 117It has it's own endpoint at `/_delete_by_query`. 118 119Delete By Query, Reindex, and Update By Query are very similar under the hood. 120 121## Reindex, Delete By Query, and Update By Query response changed 122 123The response from the above APIs changed a bit. E.g. the `retries` value 124used to be an `int64` and returns separate values for `bulk` and `search` now: 125 126``` 127// Old 128{ 129 ... 130 "retries": 123, 131 ... 132} 133``` 134 135``` 136// New 137{ 138 ... 139 "retries": { 140 "bulk": 123, 141 "search": 0 142 }, 143 ... 144} 145``` 146 147## ScanService removed 148 149The `ScanService` is removed. Use the (new) `ScrollService` instead. 150 151## New ScrollService 152 153There was confusion around `ScanService` and `ScrollService` doing basically 154the same. One was returning slices and didn't support all query details, the 155other returned one document after another and wasn't safe for concurrent use. 156So we merged the two and merged it into a new `ScrollService` that 157removes all the problems with the older services. 158 159In other words: 160If you used `ScanService`, switch to `ScrollService`. 161If you used the old `ScrollService`, you might need to fix some things but 162overall it should just work. 163 164Changes: 165- We replaced `elastic.EOS` with `io.EOF` to indicate the "end of scroll". 166 167TODO Not implemented yet 168 169## Suggesters 170 171They have been [completely rewritten in ES 5.0](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_suggester.html). 172 173Some changes: 174- Suggesters no longer have an [output](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_suggester.html#_simpler_completion_indexing). 175 176TODO Fix all structural changes in suggesters 177 178## Percolator 179 180Percolator has [changed considerably](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/breaking_50_percolator.html). 181 182Elastic 5.0 adds the new 183[Percolator Query](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl-percolate-query.html) 184which can be used in combination with the new 185[Percolator type](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/percolator.html). 186 187The Percolate service is removed from Elastic 5.0. 188 189## Remove Consistency, add WaitForActiveShards 190 191The `consistency` parameter has been removed in a lot of places, e.g. the Bulk, 192Index, Delete, Delete-by-Query, Reindex, Update, and Update-by-Query API. 193 194It has been replaced by a somewhat similar `wait_for_active_shards` parameter. 195See https://github.com/elastic/elasticsearch/pull/19454. 196