summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-01-29 14:17:40 -0800
committerGitHub <noreply@github.com>2018-01-29 14:17:40 -0800
commit961c04cae992eadb42d286d2f85f8a675bdc68c8 (patch)
tree3408f2d06f847e966c53485e2d54c692cdd037c1 /vendor/gopkg.in
parent8d66523ba7d9a77129844be476732ebfd5272d64 (diff)
downloadchat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.gz
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.bz2
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.zip
Upgrading server dependancies (#8154)
Diffstat (limited to 'vendor/gopkg.in')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/.gitignore1
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/.travis.yml3
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/CHANGELOG-6.0.md18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ISSUE_TEMPLATE.md1
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/README.md59
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/acknowledged_response.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk.go33
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request.go81
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_easyjson.go230
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go25
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_index_request.go102
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_easyjson.go262
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_test.go41
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go104
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_processor_test.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_test.go188
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_update_request.go172
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_easyjson.go461
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_test.go60
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/clear_scroll.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/clear_scroll_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/client.go123
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/client_test.go64
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/cluster-test/cluster-test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/cluster_health.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/cluster_state.go20
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/count.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/count_test.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/decoder_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete.go30
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete_by_query.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete_by_query_test.go8
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete_template.go109
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete_template_test.go23
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete_test.go25
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/docker-compose.yml23
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/example_test.go69
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/exists.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/exists_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/explain.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/explain_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/fetch_source_context.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/field_caps.go202
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/field_caps_test.go146
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/field_stats.go259
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/field_stats_test.go282
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/get.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/get_template.go113
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/get_template_test.go52
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/get_test.go22
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/highlight.go20
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/highlight_test.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/index.go31
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/index_test.go30
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_analyze.go15
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_close.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_create.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_delete.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_delete_template.go16
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_exists.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_exists_template.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_exists_template_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_exists_type.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_exists_type_test.go8
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_flush.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_forcemerge.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases_test.go15
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_field_mapping.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_mapping.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_settings.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_get_template.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_open.go16
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_alias.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_alias_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping_test.go30
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_settings.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_put_template.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_refresh.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_refresh_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_rollover.go15
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_rollover_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_segments.go237
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_segments_test.go86
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_shrink.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/indices_stats.go39
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ingest_delete_pipeline.go16
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ingest_put_pipeline.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ingest_simulate_pipeline.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/mget.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/mget_test.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/msearch.go7
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/msearch_test.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/mtermvectors.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/mtermvectors_test.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/nodes_info.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go45
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/percolate_test.go27
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ping.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/put_template.go145
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/put_template_test.go53
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/recipes/bulk_insert/bulk_insert.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/recipes/connect/connect.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/recipes/sliced_scroll/sliced_scroll.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/reindex.go22
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/reindex_test.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/request.go53
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/request_test.go55
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/retrier_test.go55
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.0.0.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.0.1.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.1.1.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.1.2.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.2.0.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.2.1.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.2.2.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.3.0.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.4.0.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.5.0.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.5.1.sh1
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.6.3.sh2
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es.sh3
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/script.go26
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/script_test.go25
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/scroll.go44
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/scroll_test.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search.go39
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs.go90
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_children.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_count_thresholds.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_histogram.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_range.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filter.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filters.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_geo_distance.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_global.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_histogram.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range.go195
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range_test.go90
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_missing.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_nested.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_range.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_reverse_nested.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_sampler.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms.go18
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text.go245
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text_test.go66
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_matrix_stats.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_avg.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_cardinality.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_extended_stats.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_geo_bounds.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_max.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_min.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentile_ranks.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentiles.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_stats.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_sum.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_top_hits.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_value_count.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_avg_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_cumulative_sum.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_derivative.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_max_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_min_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_mov_avg.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_serial_diff.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_stats_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_sum_bucket.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_test.go143
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_collapse_builder.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_bool.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_bool_test.go3
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_boosting.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_constant_score.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_dis_max.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_exists.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_score_funcs.go28
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_fuzzy.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_bounding_box.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance_test.go3
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_polygon.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_has_child.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_has_parent.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_ids.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_indices.go89
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_indices_test.go46
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_match.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_match_all.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_match_none.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase_prefix.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this.go24
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_multi_match.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_nested.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_parent_id.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator_test.go7
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix_example_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_query_string.go97
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_range.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_regexp.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_script.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_script_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string_test.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_slice.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_term.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_terms.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_type.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_request.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_source.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_source_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_suggester_test.go31
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_terms_lookup.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_test.go381
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/setup_test.go235
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go13
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_create_repository.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_delete_repository.go16
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_get_repository.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_verify_repository.go12
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/sort.go177
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/sort_test.go52
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggest.go158
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggest_field.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggest_field_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggest_test.go162
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go226
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy.go179
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy_test.go50
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go58
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context_geo.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_phrase.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_phrase_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_term.go6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/tasks_cancel.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/tasks_get_task.go8
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/tasks_list.go56
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/tasks_list_test.go8
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/termvectors.go17
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/termvectors_test.go16
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update.go26
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update_by_query.go11
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update_by_query_test.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update_integration_test.go58
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update_test.go71
273 files changed, 5106 insertions, 3625 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/.gitignore b/vendor/gopkg.in/olivere/elastic.v5/.gitignore
index 47140b99b..306ffbd83 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/.gitignore
+++ b/vendor/gopkg.in/olivere/elastic.v5/.gitignore
@@ -22,6 +22,7 @@ _testmain.go
*.exe
/.vscode/
+/debug.test
/generator
/cluster-test/cluster-test
/cluster-test/*.log
diff --git a/vendor/gopkg.in/olivere/elastic.v5/.travis.yml b/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
index 6f718f66a..b4322c13c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
+++ b/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
@@ -12,5 +12,4 @@ services:
- docker
before_install:
- sudo sysctl -w vm.max_map_count=262144
- - docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:5.6.3 elasticsearch -Expack.security.enabled=false -Escript.inline=true -Escript.stored=true -Escript.file=true -Enetwork.host=_local_,_site_ -Enetwork.publish_host=_local_ >& /dev/null &
- - sleep 30
+ - docker run -d --rm -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:6.1.2 elasticsearch -Expack.security.enabled=false -Enetwork.host=_local_,_site_ -Enetwork.publish_host=_local_
diff --git a/vendor/gopkg.in/olivere/elastic.v5/CHANGELOG-6.0.md b/vendor/gopkg.in/olivere/elastic.v5/CHANGELOG-6.0.md
new file mode 100644
index 000000000..277925929
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/CHANGELOG-6.0.md
@@ -0,0 +1,18 @@
+# Changes from 5.0 to 6.0
+
+See [breaking changes](https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-6.0.html).
+
+## _all removed
+
+6.0 has removed support for the `_all` field.
+
+## Boolean values coerced
+
+Only use `true` or `false` for boolean values, not `0` or `1` or `on` or `off`.
+
+## Single Type Indices
+
+Notice that 6.0 and future versions will default to single type indices, i.e. you may not use multiple types when e.g. adding an index with a mapping.
+
+See [here for details](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#_what_are_mapping_types).
+
diff --git a/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS b/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
index e3ded87cd..d7f7f780f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
+++ b/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
@@ -12,6 +12,7 @@ Adam Weiner [@adamweiner](https://github.com/adamweiner)
Adrian Lungu [@AdrianLungu](https://github.com/AdrianLungu)
alehano [@alehano](https://github.com/alehano)
Alex [@akotlar](https://github.com/akotlar)
+Alexander Sack [@asac](https://github.com/asac)
Alexandre Olivier [@aliphen](https://github.com/aliphen)
Alexey Sharov [@nizsheanez](https://github.com/nizsheanez)
AndreKR [@AndreKR](https://github.com/AndreKR)
@@ -62,6 +63,7 @@ Jack Lindamood [@cep21](https://github.com/cep21)
Jacob [@jdelgad](https://github.com/jdelgad)
Jayme Rotsaert [@jrots](https://github.com/jrots)
Jeremy Canady [@jrmycanady](https://github.com/jrmycanady)
+Jim Berlage [@jimberlage](https://github.com/jimberlage)
Joe Buck [@four2five](https://github.com/four2five)
John Barker [@j16r](https://github.com/j16r)
John Goodall [@jgoodall](https://github.com/jgoodall)
@@ -82,6 +84,7 @@ Marcy Buccellato [@marcybuccellato](https://github.com/marcybuccellato)
Mark Costello [@mcos](https://github.com/mcos)
Martin Häger [@protomouse](https://github.com/protomouse)
Medhi Bechina [@mdzor](https://github.com/mdzor)
+mnpritula [@mnpritula](https://github.com/mnpritula)
mosa [@mosasiru](https://github.com/mosasiru)
naimulhaider [@naimulhaider](https://github.com/naimulhaider)
Naoya Yoshizawa [@azihsoyn](https://github.com/azihsoyn)
@@ -108,6 +111,7 @@ Take [ww24](https://github.com/ww24)
Tetsuya Morimoto [@t2y](https://github.com/t2y)
TimeEmit [@TimeEmit](https://github.com/timeemit)
TusharM [@tusharm](https://github.com/tusharm)
+zhangxin [@visaxin](https://github.com/visaxin)
wangtuo [@wangtuo](https://github.com/wangtuo)
Wédney Yuri [@wedneyyuri](https://github.com/wedneyyuri)
wolfkdy [@wolfkdy](https://github.com/wolfkdy)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ISSUE_TEMPLATE.md b/vendor/gopkg.in/olivere/elastic.v5/ISSUE_TEMPLATE.md
index c5eb690a7..88d66cc83 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ISSUE_TEMPLATE.md
+++ b/vendor/gopkg.in/olivere/elastic.v5/ISSUE_TEMPLATE.md
@@ -6,6 +6,7 @@ your issue/question without further inquiry. Thank you.
[ ] elastic.v2 (for Elasticsearch 1.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
+[ ] elastic.v6 (for Elasticsearch 6.x)
### Please describe the expected behavior
diff --git a/vendor/gopkg.in/olivere/elastic.v5/README.md b/vendor/gopkg.in/olivere/elastic.v5/README.md
index 45b84dab8..f452b664d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/README.md
+++ b/vendor/gopkg.in/olivere/elastic.v5/README.md
@@ -1,10 +1,12 @@
# Elastic
+**This is a development branch that is actively being worked on. DO NOT USE IN PRODUCTION!**
+
Elastic is an [Elasticsearch](http://www.elasticsearch.org/) client for the
[Go](http://www.golang.org/) programming language.
-[![Build Status](https://travis-ci.org/olivere/elastic.svg?branch=release-branch.v5)](https://travis-ci.org/olivere/elastic)
-[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](http://godoc.org/gopkg.in/olivere/elastic.v5)
+[![Build Status](https://travis-ci.org/olivere/elastic.svg?branch=release-branch.v6)](https://travis-ci.org/olivere/elastic)
+[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](http://godoc.org/github.com/olivere/elastic)
[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/olivere/elastic/master/LICENSE)
See the [wiki](https://github.com/olivere/elastic/wiki) for additional information about Elastic.
@@ -12,35 +14,46 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for additional informati
## Releases
-**The release branches (e.g. [`release-branch.v5`](https://github.com/olivere/elastic/tree/release-branch.v5))
+**The release branches (e.g. [`release-branch.v6`](https://github.com/olivere/elastic/tree/release-branch.v6))
are actively being worked on and can break at any time.
-If you want to use stable versions of Elastic, please use the packages released via [gopkg.in](https://gopkg.in).**
+If you want to use stable versions of Elastic, please use a dependency manager like [dep](https://github.com/golang/dep).**
Here's the version matrix:
-Elasticsearch version | Elastic version -| Package URL
-----------------------|------------------|------------
-5.x | 5.0 | [`gopkg.in/olivere/elastic.v5`](https://gopkg.in/olivere/elastic.v5) ([source](https://github.com/olivere/elastic/tree/release-branch.v5) [doc](http://godoc.org/gopkg.in/olivere/elastic.v5))
-2.x | 3.0 | [`gopkg.in/olivere/elastic.v3`](https://gopkg.in/olivere/elastic.v3) ([source](https://github.com/olivere/elastic/tree/release-branch.v3) [doc](http://godoc.org/gopkg.in/olivere/elastic.v3))
-1.x | 2.0 | [`gopkg.in/olivere/elastic.v2`](https://gopkg.in/olivere/elastic.v2) ([source](https://github.com/olivere/elastic/tree/release-branch.v2) [doc](http://godoc.org/gopkg.in/olivere/elastic.v2))
-0.9-1.3 | 1.0 | [`gopkg.in/olivere/elastic.v1`](https://gopkg.in/olivere/elastic.v1) ([source](https://github.com/olivere/elastic/tree/release-branch.v1) [doc](http://godoc.org/gopkg.in/olivere/elastic.v1))
+Elasticsearch version | Elastic version | Package URL | Remarks |
+----------------------|------------------|-------------|---------|
+6.x                   | 6.0             | [`github.com/olivere/elastic`](https://github.com/olivere/elastic) ([source](https://github.com/olivere/elastic/tree/release-branch.v6) [doc](http://godoc.org/github.com/olivere/elastic)) | Use a dependency manager (see below).
+5.x | 5.0 | [`gopkg.in/olivere/elastic.v5`](https://gopkg.in/olivere/elastic.v5) ([source](https://github.com/olivere/elastic/tree/release-branch.v5) [doc](http://godoc.org/gopkg.in/olivere/elastic.v5)) | Actively maintained.
+2.x | 3.0 | [`gopkg.in/olivere/elastic.v3`](https://gopkg.in/olivere/elastic.v3) ([source](https://github.com/olivere/elastic/tree/release-branch.v3) [doc](http://godoc.org/gopkg.in/olivere/elastic.v3)) | Deprecated. Please update.
+1.x | 2.0 | [`gopkg.in/olivere/elastic.v2`](https://gopkg.in/olivere/elastic.v2) ([source](https://github.com/olivere/elastic/tree/release-branch.v2) [doc](http://godoc.org/gopkg.in/olivere/elastic.v2)) | Deprecated. Please update.
+0.9-1.3 | 1.0 | [`gopkg.in/olivere/elastic.v1`](https://gopkg.in/olivere/elastic.v1) ([source](https://github.com/olivere/elastic/tree/release-branch.v1) [doc](http://godoc.org/gopkg.in/olivere/elastic.v1)) | Deprecated. Please update.
**Example:**
-You have installed Elasticsearch 5.0.0 and want to use Elastic.
-As listed above, you should use Elastic 5.0.
-So you first install the stable release of Elastic 5.0 from gopkg.in.
+You have installed Elasticsearch 6.0.0 and want to use Elastic.
+As listed above, you should use Elastic 6.0.
-```sh
-$ go get gopkg.in/olivere/elastic.v5
-```
+To use the required version of Elastic in your application, it is strongly
+advised to use a tool like
+[dep](https://github.com/golang/dep)
+or
+[Glide](https://glide.sh/)
+to manage that dependency. Make sure to use a version such as `^6.0.0`.
-You then import it with this import path:
+To use Elastic, simply import:
```go
-import elastic "gopkg.in/olivere/elastic.v5"
+import "github.com/olivere/elastic"
```
+### Elastic 6.0
+
+Elastic 6.0 targets Elasticsearch 6.x which was [released on 14th November 2017](https://www.elastic.co/blog/elasticsearch-6-0-0-released).
+
+Notice that there are will be a lot of [breaking changes in Elasticsearch 6.0](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking-changes-6.0.html)
+and we used this as an opportunity to [clean up and refactor Elastic](https://github.com/olivere/elastic/blob/release-branch.v6/CHANGELOG-6.0.md)
+as we did in the transition from earlier versions of Elastic.
+
### Elastic 5.0
Elastic 5.0 targets Elasticsearch 5.0.0 and later. Elasticsearch 5.0.0 was
@@ -107,7 +120,7 @@ The client connects to Elasticsearch on `http://127.0.0.1:9200` by default.
You typically create one client for your app. Here's a complete example of
creating a client, creating an index, adding a document, executing a search etc.
-An example is available [here](https://olivere.github.io/elastic/)
+An example is available [here](https://olivere.github.io/elastic/).
Here's a [link to a complete working example for v3](https://gist.github.com/olivere/114347ff9d9cfdca7bdc0ecea8b82263).
@@ -143,11 +156,10 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for more details.
- [x] Context Suggester
- [x] Multi Search API
- [x] Count API
-- [ ] Search Exists API
- [ ] Validate API
- [x] Explain API
- [x] Profile API
-- [x] Field Stats API
+- [x] Field Capabilities API
### Aggregations
@@ -167,9 +179,11 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for more details.
- [x] Top Hits
- [x] Value Count
- Bucket Aggregations
+ - [ ] Adjacency Matrix
- [x] Children
- [x] Date Histogram
- [x] Date Range
+ - [ ] Diversified Sampler
- [x] Filter
- [x] Filters
- [x] Geo Distance
@@ -183,6 +197,7 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for more details.
- [x] Reverse Nested
- [x] Sampler
- [x] Significant Terms
+ - [x] Significant Text
- [x] Terms
- Pipeline Aggregations
- [x] Avg Bucket
@@ -222,7 +237,7 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for more details.
- [x] Index Templates
- [ ] Shadow Replica Indices
- [x] Indices Stats
-- [ ] Indices Segments
+- [x] Indices Segments
- [ ] Indices Recovery
- [ ] Indices Shard Stores
- [ ] Clear Cache
diff --git a/vendor/gopkg.in/olivere/elastic.v5/acknowledged_response.go b/vendor/gopkg.in/olivere/elastic.v5/acknowledged_response.go
index 83f954f44..2045ab85e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/acknowledged_response.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/acknowledged_response.go
@@ -7,5 +7,7 @@ package elastic
// AcknowledgedResponse is returned from various APIs. It simply indicates
// whether the operation is ack'd or not.
type AcknowledgedResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk.go b/vendor/gopkg.in/olivere/elastic.v5/bulk.go
index f2fa0ea73..f4228294f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk.go
@@ -11,7 +11,7 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// BulkService allows for batching bulk requests and sending them to
@@ -23,10 +23,11 @@ import (
// reuse BulkService to send many batches. You do not have to create a new
// BulkService for each batch.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for more details.
type BulkService struct {
- client *Client
+ client *Client
+ retrier Retrier
index string
typ string
@@ -57,6 +58,13 @@ func (s *BulkService) reset() {
s.sizeInBytesCursor = 0
}
+// Retrier allows to set specific retry logic for this BulkService.
+// If not specified, it will use the client's default retrier.
+func (s *BulkService) Retrier(retrier Retrier) *BulkService {
+ s.retrier = retrier
+ return s
+}
+
// Index specifies the index to use for all batches. You may also leave
// this blank and specify the index in the individual bulk requests.
func (s *BulkService) Index(index string) *BulkService {
@@ -159,7 +167,8 @@ func (s *BulkService) NumberOfActions() int {
}
func (s *BulkService) bodyAsString() (string, error) {
- var buf bytes.Buffer
+ // Pre-allocate to reduce allocs
+ buf := bytes.NewBuffer(make([]byte, 0, s.EstimatedSizeInBytes()))
for _, req := range s.requests {
source, err := req.Source()
@@ -234,7 +243,14 @@ func (s *BulkService) Do(ctx context.Context) (*BulkResponse, error) {
}
// Get response
- res, err := s.client.PerformRequestWithContentType(ctx, "POST", path, params, body, "application/x-ndjson")
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ ContentType: "application/x-ndjson",
+ Retrier: s.retrier,
+ })
if err != nil {
return nil, err
}
@@ -304,11 +320,14 @@ type BulkResponseItem struct {
Type string `json:"_type,omitempty"`
Id string `json:"_id,omitempty"`
Version int64 `json:"_version,omitempty"`
- Status int `json:"status,omitempty"`
Result string `json:"result,omitempty"`
+ Shards *shardsInfo `json:"_shards,omitempty"`
+ SeqNo int64 `json:"_seq_no,omitempty"`
+ PrimaryTerm int64 `json:"_primary_term,omitempty"`
+ Status int `json:"status,omitempty"`
ForcedRefresh bool `json:"forced_refresh,omitempty"`
- Found bool `json:"found,omitempty"`
Error *ErrorDetails `json:"error,omitempty"`
+ GetResult *GetResult `json:"get,omitempty"`
}
// Indexed returns all bulk request results of "index" actions.
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request.go
index 5d4a2a5a7..e6c98c553 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request.go
@@ -4,6 +4,8 @@
package elastic
+//go:generate easyjson bulk_delete_request.go
+
import (
"encoding/json"
"fmt"
@@ -14,7 +16,7 @@ import (
// BulkDeleteRequest is a request to remove a document from Elasticsearch.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
type BulkDeleteRequest struct {
BulkableRequest
@@ -27,6 +29,22 @@ type BulkDeleteRequest struct {
versionType string // default is "internal"
source []string
+
+ useEasyJSON bool
+}
+
+//easyjson:json
+type bulkDeleteRequestCommand map[string]bulkDeleteRequestCommandOp
+
+//easyjson:json
+type bulkDeleteRequestCommandOp struct {
+ Index string `json:"_index,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Parent string `json:"parent,omitempty"`
+ Routing string `json:"routing,omitempty"`
+ Version int64 `json:"version,omitempty"`
+ VersionType string `json:"version_type,omitempty"`
}
// NewBulkDeleteRequest returns a new BulkDeleteRequest.
@@ -34,6 +52,16 @@ func NewBulkDeleteRequest() *BulkDeleteRequest {
return &BulkDeleteRequest{}
}
+// UseEasyJSON is an experimental setting that enables serialization
+// with github.com/mailru/easyjson, which should in faster serialization
+// time and less allocations, but removed compatibility with encoding/json,
+// usage of unsafe etc. See https://github.com/mailru/easyjson#issues-notes-and-limitations
+// for details. This setting is disabled by default.
+func (r *BulkDeleteRequest) UseEasyJSON(enable bool) *BulkDeleteRequest {
+ r.useEasyJSON = enable
+ return r
+}
+
// Index specifies the Elasticsearch index to use for this delete request.
// If unspecified, the index set on the BulkService will be used.
func (r *BulkDeleteRequest) Index(index string) *BulkDeleteRequest {
@@ -81,7 +109,7 @@ func (r *BulkDeleteRequest) Version(version int64) *BulkDeleteRequest {
}
// VersionType can be "internal" (default), "external", "external_gte",
-// "external_gt", or "force".
+// or "external_gt".
func (r *BulkDeleteRequest) VersionType(versionType string) *BulkDeleteRequest {
r.versionType = versionType
r.source = nil
@@ -100,45 +128,38 @@ func (r *BulkDeleteRequest) String() string {
// Source returns the on-wire representation of the delete request,
// split into an action-and-meta-data line and an (optional) source line.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
func (r *BulkDeleteRequest) Source() ([]string, error) {
if r.source != nil {
return r.source, nil
}
- lines := make([]string, 1)
-
- source := make(map[string]interface{})
- deleteCommand := make(map[string]interface{})
- if r.index != "" {
- deleteCommand["_index"] = r.index
+ command := bulkDeleteRequestCommand{
+ "delete": bulkDeleteRequestCommandOp{
+ Index: r.index,
+ Type: r.typ,
+ Id: r.id,
+ Routing: r.routing,
+ Parent: r.parent,
+ Version: r.version,
+ VersionType: r.versionType,
+ },
}
- if r.typ != "" {
- deleteCommand["_type"] = r.typ
- }
- if r.id != "" {
- deleteCommand["_id"] = r.id
- }
- if r.parent != "" {
- deleteCommand["_parent"] = r.parent
- }
- if r.routing != "" {
- deleteCommand["_routing"] = r.routing
- }
- if r.version > 0 {
- deleteCommand["_version"] = r.version
- }
- if r.versionType != "" {
- deleteCommand["_version_type"] = r.versionType
- }
- source["delete"] = deleteCommand
- body, err := json.Marshal(source)
+ var err error
+ var body []byte
+ if r.useEasyJSON {
+ // easyjson
+ body, err = command.MarshalJSON()
+ } else {
+ // encoding/json
+ body, err = json.Marshal(command)
+ }
if err != nil {
return nil, err
}
- lines[0] = string(body)
+ lines := []string{string(body)}
r.source = lines
return lines, nil
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_easyjson.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_easyjson.go
new file mode 100644
index 000000000..df3452ce6
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_easyjson.go
@@ -0,0 +1,230 @@
+// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
+
+package elastic
+
+import (
+ json "encoding/json"
+ easyjson "github.com/mailru/easyjson"
+ jlexer "github.com/mailru/easyjson/jlexer"
+ jwriter "github.com/mailru/easyjson/jwriter"
+)
+
+// suppress unused package warning
+var (
+ _ *json.RawMessage
+ _ *jlexer.Lexer
+ _ *jwriter.Writer
+ _ easyjson.Marshaler
+)
+
+func easyjson8092efb6DecodeGithubComOlivereElastic(in *jlexer.Lexer, out *bulkDeleteRequestCommandOp) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ if isTopLevel {
+ in.Consumed()
+ }
+ in.Skip()
+ return
+ }
+ in.Delim('{')
+ for !in.IsDelim('}') {
+ key := in.UnsafeString()
+ in.WantColon()
+ if in.IsNull() {
+ in.Skip()
+ in.WantComma()
+ continue
+ }
+ switch key {
+ case "_index":
+ out.Index = string(in.String())
+ case "_type":
+ out.Type = string(in.String())
+ case "_id":
+ out.Id = string(in.String())
+ case "parent":
+ out.Parent = string(in.String())
+ case "routing":
+ out.Routing = string(in.String())
+ case "version":
+ out.Version = int64(in.Int64())
+ case "version_type":
+ out.VersionType = string(in.String())
+ default:
+ in.SkipRecursive()
+ }
+ in.WantComma()
+ }
+ in.Delim('}')
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson8092efb6EncodeGithubComOlivereElastic(out *jwriter.Writer, in bulkDeleteRequestCommandOp) {
+ out.RawByte('{')
+ first := true
+ _ = first
+ if in.Index != "" {
+ const prefix string = ",\"_index\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Index))
+ }
+ if in.Type != "" {
+ const prefix string = ",\"_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Type))
+ }
+ if in.Id != "" {
+ const prefix string = ",\"_id\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Id))
+ }
+ if in.Parent != "" {
+ const prefix string = ",\"parent\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Parent))
+ }
+ if in.Routing != "" {
+ const prefix string = ",\"routing\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Routing))
+ }
+ if in.Version != 0 {
+ const prefix string = ",\"version\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Int64(int64(in.Version))
+ }
+ if in.VersionType != "" {
+ const prefix string = ",\"version_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.VersionType))
+ }
+ out.RawByte('}')
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkDeleteRequestCommandOp) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson8092efb6EncodeGithubComOlivereElastic(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkDeleteRequestCommandOp) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson8092efb6EncodeGithubComOlivereElastic(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkDeleteRequestCommandOp) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson8092efb6DecodeGithubComOlivereElastic(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkDeleteRequestCommandOp) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson8092efb6DecodeGithubComOlivereElastic(l, v)
+}
+func easyjson8092efb6DecodeGithubComOlivereElastic1(in *jlexer.Lexer, out *bulkDeleteRequestCommand) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ in.Skip()
+ } else {
+ in.Delim('{')
+ if !in.IsDelim('}') {
+ *out = make(bulkDeleteRequestCommand)
+ } else {
+ *out = nil
+ }
+ for !in.IsDelim('}') {
+ key := string(in.String())
+ in.WantColon()
+ var v1 bulkDeleteRequestCommandOp
+ (v1).UnmarshalEasyJSON(in)
+ (*out)[key] = v1
+ in.WantComma()
+ }
+ in.Delim('}')
+ }
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson8092efb6EncodeGithubComOlivereElastic1(out *jwriter.Writer, in bulkDeleteRequestCommand) {
+ if in == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
+ out.RawString(`null`)
+ } else {
+ out.RawByte('{')
+ v2First := true
+ for v2Name, v2Value := range in {
+ if v2First {
+ v2First = false
+ } else {
+ out.RawByte(',')
+ }
+ out.String(string(v2Name))
+ out.RawByte(':')
+ (v2Value).MarshalEasyJSON(out)
+ }
+ out.RawByte('}')
+ }
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkDeleteRequestCommand) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson8092efb6EncodeGithubComOlivereElastic1(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkDeleteRequestCommand) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson8092efb6EncodeGithubComOlivereElastic1(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkDeleteRequestCommand) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson8092efb6DecodeGithubComOlivereElastic1(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkDeleteRequestCommand) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson8092efb6DecodeGithubComOlivereElastic1(l, v)
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
index 6ac429d8b..8635e34d1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
@@ -15,23 +15,23 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
}{
// #0
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1"}}`,
},
},
// #1
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1").Parent("2"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Parent("2"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_parent":"2","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1","parent":"2"}}`,
},
},
// #2
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1").Routing("3"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Routing("3"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_routing":"3","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1","routing":"3"}}`,
},
},
}
@@ -58,11 +58,22 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
var bulkDeleteRequestSerializationResult string
func BenchmarkBulkDeleteRequestSerialization(b *testing.B) {
- r := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
+ b.Run("stdlib", func(b *testing.B) {
+ r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(false))
+ })
+ b.Run("easyjson", func(b *testing.B) {
+ r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(true))
+ })
+}
+
+func benchmarkBulkDeleteRequestSerialization(b *testing.B, r *BulkDeleteRequest) {
var s string
for n := 0; n < b.N; n++ {
s = r.String()
r.source = nil // Don't let caching spoil the benchmark
}
bulkDeleteRequestSerializationResult = s // ensure the compiler doesn't optimize
+ b.ReportAllocs()
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request.go
index 1c9302881..321d2e25a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request.go
@@ -4,6 +4,8 @@
package elastic
+//go:generate easyjson bulk_index_request.go
+
import (
"encoding/json"
"fmt"
@@ -12,7 +14,7 @@ import (
// BulkIndexRequest is a request to add a document to Elasticsearch.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
type BulkIndexRequest struct {
BulkableRequest
@@ -27,9 +29,27 @@ type BulkIndexRequest struct {
doc interface{}
pipeline string
retryOnConflict *int
- ttl string
source []string
+
+ useEasyJSON bool
+}
+
+//easyjson:json
+type bulkIndexRequestCommand map[string]bulkIndexRequestCommandOp
+
+//easyjson:json
+type bulkIndexRequestCommandOp struct {
+ Index string `json:"_index,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Parent string `json:"parent,omitempty"`
+ // RetryOnConflict is "_retry_on_conflict" for 6.0 and "retry_on_conflict" for 6.1+.
+ RetryOnConflict *int `json:"retry_on_conflict,omitempty"`
+ Routing string `json:"routing,omitempty"`
+ Version int64 `json:"version,omitempty"`
+ VersionType string `json:"version_type,omitempty"`
+ Pipeline string `json:"pipeline,omitempty"`
}
// NewBulkIndexRequest returns a new BulkIndexRequest.
@@ -40,6 +60,16 @@ func NewBulkIndexRequest() *BulkIndexRequest {
}
}
+// UseEasyJSON is an experimental setting that enables serialization
+// with github.com/mailru/easyjson, which should in faster serialization
+// time and less allocations, but removed compatibility with encoding/json,
+// usage of unsafe etc. See https://github.com/mailru/easyjson#issues-notes-and-limitations
+// for details. This setting is disabled by default.
+func (r *BulkIndexRequest) UseEasyJSON(enable bool) *BulkIndexRequest {
+ r.useEasyJSON = enable
+ return r
+}
+
// Index specifies the Elasticsearch index to use for this index request.
// If unspecified, the index set on the BulkService will be used.
func (r *BulkIndexRequest) Index(index string) *BulkIndexRequest {
@@ -65,7 +95,7 @@ func (r *BulkIndexRequest) Id(id string) *BulkIndexRequest {
// OpType specifies if this request should follow create-only or upsert
// behavior. This follows the OpType of the standard document index API.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-index_.html#operation-type
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html#operation-type
// for details.
func (r *BulkIndexRequest) OpType(opType string) *BulkIndexRequest {
r.opType = opType
@@ -98,7 +128,7 @@ func (r *BulkIndexRequest) Version(version int64) *BulkIndexRequest {
// VersionType specifies how versions are created. It can be e.g. internal,
// external, external_gte, or force.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-index_.html#index-versioning
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html#index-versioning
// for details.
func (r *BulkIndexRequest) VersionType(versionType string) *BulkIndexRequest {
r.versionType = versionType
@@ -120,13 +150,6 @@ func (r *BulkIndexRequest) RetryOnConflict(retryOnConflict int) *BulkIndexReques
return r
}
-// TTL is an expiration time for the document.
-func (r *BulkIndexRequest) TTL(ttl string) *BulkIndexRequest {
- r.ttl = ttl
- r.source = nil
- return r
-}
-
// Pipeline to use while processing the request.
func (r *BulkIndexRequest) Pipeline(pipeline string) *BulkIndexRequest {
r.pipeline = pipeline
@@ -146,7 +169,7 @@ func (r *BulkIndexRequest) String() string {
// Source returns the on-wire representation of the index request,
// split into an action-and-meta-data line and an (optional) source line.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
func (r *BulkIndexRequest) Source() ([]string, error) {
// { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
@@ -159,44 +182,35 @@ func (r *BulkIndexRequest) Source() ([]string, error) {
lines := make([]string, 2)
// "index" ...
- command := make(map[string]interface{})
- indexCommand := make(map[string]interface{})
- if r.index != "" {
- indexCommand["_index"] = r.index
- }
- if r.typ != "" {
- indexCommand["_type"] = r.typ
- }
- if r.id != "" {
- indexCommand["_id"] = r.id
- }
- if r.routing != "" {
- indexCommand["_routing"] = r.routing
- }
- if r.parent != "" {
- indexCommand["_parent"] = r.parent
- }
- if r.version > 0 {
- indexCommand["_version"] = r.version
+ indexCommand := bulkIndexRequestCommandOp{
+ Index: r.index,
+ Type: r.typ,
+ Id: r.id,
+ Routing: r.routing,
+ Parent: r.parent,
+ Version: r.version,
+ VersionType: r.versionType,
+ RetryOnConflict: r.retryOnConflict,
+ Pipeline: r.pipeline,
}
- if r.versionType != "" {
- indexCommand["_version_type"] = r.versionType
+ command := bulkIndexRequestCommand{
+ r.opType: indexCommand,
}
- if r.retryOnConflict != nil {
- indexCommand["_retry_on_conflict"] = *r.retryOnConflict
- }
- if r.ttl != "" {
- indexCommand["_ttl"] = r.ttl
- }
- if r.pipeline != "" {
- indexCommand["pipeline"] = r.pipeline
+
+ var err error
+ var body []byte
+ if r.useEasyJSON {
+ // easyjson
+ body, err = command.MarshalJSON()
+ } else {
+ // encoding/json
+ body, err = json.Marshal(command)
}
- command[r.opType] = indexCommand
- line, err := json.Marshal(command)
if err != nil {
return nil, err
}
- lines[0] = string(line)
+
+ lines[0] = string(body)
// "field1" ...
if r.doc != nil {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_easyjson.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_easyjson.go
new file mode 100644
index 000000000..f8792978f
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_easyjson.go
@@ -0,0 +1,262 @@
+// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
+
+package elastic
+
+import (
+ json "encoding/json"
+ easyjson "github.com/mailru/easyjson"
+ jlexer "github.com/mailru/easyjson/jlexer"
+ jwriter "github.com/mailru/easyjson/jwriter"
+)
+
+// suppress unused package warning
+var (
+ _ *json.RawMessage
+ _ *jlexer.Lexer
+ _ *jwriter.Writer
+ _ easyjson.Marshaler
+)
+
+func easyjson9de0fcbfDecodeGithubComOlivereElastic(in *jlexer.Lexer, out *bulkIndexRequestCommandOp) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ if isTopLevel {
+ in.Consumed()
+ }
+ in.Skip()
+ return
+ }
+ in.Delim('{')
+ for !in.IsDelim('}') {
+ key := in.UnsafeString()
+ in.WantColon()
+ if in.IsNull() {
+ in.Skip()
+ in.WantComma()
+ continue
+ }
+ switch key {
+ case "_index":
+ out.Index = string(in.String())
+ case "_id":
+ out.Id = string(in.String())
+ case "_type":
+ out.Type = string(in.String())
+ case "parent":
+ out.Parent = string(in.String())
+ case "retry_on_conflict":
+ if in.IsNull() {
+ in.Skip()
+ out.RetryOnConflict = nil
+ } else {
+ if out.RetryOnConflict == nil {
+ out.RetryOnConflict = new(int)
+ }
+ *out.RetryOnConflict = int(in.Int())
+ }
+ case "routing":
+ out.Routing = string(in.String())
+ case "version":
+ out.Version = int64(in.Int64())
+ case "version_type":
+ out.VersionType = string(in.String())
+ case "pipeline":
+ out.Pipeline = string(in.String())
+ default:
+ in.SkipRecursive()
+ }
+ in.WantComma()
+ }
+ in.Delim('}')
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson9de0fcbfEncodeGithubComOlivereElastic(out *jwriter.Writer, in bulkIndexRequestCommandOp) {
+ out.RawByte('{')
+ first := true
+ _ = first
+ if in.Index != "" {
+ const prefix string = ",\"_index\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Index))
+ }
+ if in.Id != "" {
+ const prefix string = ",\"_id\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Id))
+ }
+ if in.Type != "" {
+ const prefix string = ",\"_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Type))
+ }
+ if in.Parent != "" {
+ const prefix string = ",\"parent\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Parent))
+ }
+ if in.RetryOnConflict != nil {
+ const prefix string = ",\"retry_on_conflict\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Int(int(*in.RetryOnConflict))
+ }
+ if in.Routing != "" {
+ const prefix string = ",\"routing\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Routing))
+ }
+ if in.Version != 0 {
+ const prefix string = ",\"version\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Int64(int64(in.Version))
+ }
+ if in.VersionType != "" {
+ const prefix string = ",\"version_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.VersionType))
+ }
+ if in.Pipeline != "" {
+ const prefix string = ",\"pipeline\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Pipeline))
+ }
+ out.RawByte('}')
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkIndexRequestCommandOp) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson9de0fcbfEncodeGithubComOlivereElastic(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkIndexRequestCommandOp) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson9de0fcbfEncodeGithubComOlivereElastic(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkIndexRequestCommandOp) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson9de0fcbfDecodeGithubComOlivereElastic(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkIndexRequestCommandOp) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson9de0fcbfDecodeGithubComOlivereElastic(l, v)
+}
+func easyjson9de0fcbfDecodeGithubComOlivereElastic1(in *jlexer.Lexer, out *bulkIndexRequestCommand) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ in.Skip()
+ } else {
+ in.Delim('{')
+ if !in.IsDelim('}') {
+ *out = make(bulkIndexRequestCommand)
+ } else {
+ *out = nil
+ }
+ for !in.IsDelim('}') {
+ key := string(in.String())
+ in.WantColon()
+ var v1 bulkIndexRequestCommandOp
+ (v1).UnmarshalEasyJSON(in)
+ (*out)[key] = v1
+ in.WantComma()
+ }
+ in.Delim('}')
+ }
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson9de0fcbfEncodeGithubComOlivereElastic1(out *jwriter.Writer, in bulkIndexRequestCommand) {
+ if in == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
+ out.RawString(`null`)
+ } else {
+ out.RawByte('{')
+ v2First := true
+ for v2Name, v2Value := range in {
+ if v2First {
+ v2First = false
+ } else {
+ out.RawByte(',')
+ }
+ out.String(string(v2Name))
+ out.RawByte(':')
+ (v2Value).MarshalEasyJSON(out)
+ }
+ out.RawByte('}')
+ }
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkIndexRequestCommand) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson9de0fcbfEncodeGithubComOlivereElastic1(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkIndexRequestCommand) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson9de0fcbfEncodeGithubComOlivereElastic1(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkIndexRequestCommand) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson9de0fcbfDecodeGithubComOlivereElastic1(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkIndexRequestCommand) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson9de0fcbfDecodeGithubComOlivereElastic1(l, v)
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_test.go
index fe95bd65c..79baf51fb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_index_request_test.go
@@ -16,55 +16,56 @@ func TestBulkIndexRequestSerialization(t *testing.T) {
}{
// #0
{
- Request: NewBulkIndexRequest().Index("index1").Type("tweet").Id("1").
+ Request: NewBulkIndexRequest().Index("index1").Type("doc").Id("1").
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"index":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"index":{"_index":"index1","_id":"1","_type":"doc"}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
// #1
{
- Request: NewBulkIndexRequest().OpType("create").Index("index1").Type("tweet").Id("1").
+ Request: NewBulkIndexRequest().OpType("create").Index("index1").Type("doc").Id("1").
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"create":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"create":{"_index":"index1","_id":"1","_type":"doc"}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
// #2
{
- Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("tweet").Id("1").
+ Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"index":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"index":{"_index":"index1","_id":"1","_type":"doc"}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
// #3
{
- Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("tweet").Id("1").RetryOnConflict(42).
+ Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").RetryOnConflict(42).
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"index":{"_id":"1","_index":"index1","_retry_on_conflict":42,"_type":"tweet"}}`,
+ `{"index":{"_index":"index1","_id":"1","_type":"doc","retry_on_conflict":42}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
// #4
{
- Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("tweet").Id("1").Pipeline("my_pipeline").
+ Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").Pipeline("my_pipeline").
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"index":{"_id":"1","_index":"index1","_type":"tweet","pipeline":"my_pipeline"}}`,
+ `{"index":{"_index":"index1","_id":"1","_type":"doc","pipeline":"my_pipeline"}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
// #5
{
- Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("tweet").Id("1").TTL("1m").
+ Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").
+ Routing("123").
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
Expected: []string{
- `{"index":{"_id":"1","_index":"index1","_ttl":"1m","_type":"tweet"}}`,
+ `{"index":{"_index":"index1","_id":"1","_type":"doc","routing":"123"}}`,
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
},
},
@@ -92,12 +93,24 @@ func TestBulkIndexRequestSerialization(t *testing.T) {
var bulkIndexRequestSerializationResult string
func BenchmarkBulkIndexRequestSerialization(b *testing.B) {
- r := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").
- Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)})
+ b.Run("stdlib", func(b *testing.B) {
+ r := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").
+ Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)})
+ benchmarkBulkIndexRequestSerialization(b, r.UseEasyJSON(false))
+ })
+ b.Run("easyjson", func(b *testing.B) {
+ r := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").
+ Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)})
+ benchmarkBulkIndexRequestSerialization(b, r.UseEasyJSON(true))
+ })
+}
+
+func benchmarkBulkIndexRequestSerialization(b *testing.B, r *BulkIndexRequest) {
var s string
for n := 0; n < b.N; n++ {
s = r.String()
r.source = nil // Don't let caching spoil the benchmark
}
bulkIndexRequestSerializationResult = s // ensure the compiler doesn't optimize
+ b.ReportAllocs()
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go
index 9566c9e9e..b2709a880 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go
@@ -29,28 +29,29 @@ import (
// Elasticsearch Java API as documented in
// https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-bulk-processor.html.
type BulkProcessorService struct {
- c *Client
- beforeFn BulkBeforeFunc
- afterFn BulkAfterFunc
- name string // name of processor
- numWorkers int // # of workers (>= 1)
- bulkActions int // # of requests after which to commit
- bulkSize int // # of bytes after which to commit
- flushInterval time.Duration // periodic flush interval
- wantStats bool // indicates whether to gather statistics
- initialTimeout time.Duration // initial wait time before retry on errors
- maxTimeout time.Duration // max time to wait for retry on errors
+ c *Client
+ beforeFn BulkBeforeFunc
+ afterFn BulkAfterFunc
+ name string // name of processor
+ numWorkers int // # of workers (>= 1)
+ bulkActions int // # of requests after which to commit
+ bulkSize int // # of bytes after which to commit
+ flushInterval time.Duration // periodic flush interval
+ wantStats bool // indicates whether to gather statistics
+ backoff Backoff // a custom Backoff to use for errors
}
// NewBulkProcessorService creates a new BulkProcessorService.
func NewBulkProcessorService(client *Client) *BulkProcessorService {
return &BulkProcessorService{
- c: client,
- numWorkers: 1,
- bulkActions: 1000,
- bulkSize: 5 << 20, // 5 MB
- initialTimeout: time.Duration(200) * time.Millisecond,
- maxTimeout: time.Duration(10000) * time.Millisecond,
+ c: client,
+ numWorkers: 1,
+ bulkActions: 1000,
+ bulkSize: 5 << 20, // 5 MB
+ backoff: NewExponentialBackoff(
+ time.Duration(200)*time.Millisecond,
+ time.Duration(10000)*time.Millisecond,
+ ),
}
}
@@ -120,6 +121,12 @@ func (s *BulkProcessorService) Stats(wantStats bool) *BulkProcessorService {
return s
}
+// Set the backoff strategy to use for errors
+func (s *BulkProcessorService) Backoff(backoff Backoff) *BulkProcessorService {
+ s.backoff = backoff
+ return s
+}
+
// Do creates a new BulkProcessor and starts it.
// Consider the BulkProcessor as a running instance that accepts bulk requests
// and commits them to Elasticsearch, spreading the work across one or more
@@ -146,8 +153,7 @@ func (s *BulkProcessorService) Do(ctx context.Context) (*BulkProcessor, error) {
s.bulkSize,
s.flushInterval,
s.wantStats,
- s.initialTimeout,
- s.maxTimeout)
+ s.backoff)
err := p.Start(ctx)
if err != nil {
@@ -221,22 +227,21 @@ func (st *BulkProcessorWorkerStats) dup() *BulkProcessorWorkerStats {
// BulkProcessor is returned by setting up a BulkProcessorService and
// calling the Do method.
type BulkProcessor struct {
- c *Client
- beforeFn BulkBeforeFunc
- afterFn BulkAfterFunc
- name string
- bulkActions int
- bulkSize int
- numWorkers int
- executionId int64
- requestsC chan BulkableRequest
- workerWg sync.WaitGroup
- workers []*bulkWorker
- flushInterval time.Duration
- flusherStopC chan struct{}
- wantStats bool
- initialTimeout time.Duration // initial wait time before retry on errors
- maxTimeout time.Duration // max time to wait for retry on errors
+ c *Client
+ beforeFn BulkBeforeFunc
+ afterFn BulkAfterFunc
+ name string
+ bulkActions int
+ bulkSize int
+ numWorkers int
+ executionId int64
+ requestsC chan BulkableRequest
+ workerWg sync.WaitGroup
+ workers []*bulkWorker
+ flushInterval time.Duration
+ flusherStopC chan struct{}
+ wantStats bool
+ backoff Backoff
startedMu sync.Mutex // guards the following block
started bool
@@ -255,20 +260,18 @@ func newBulkProcessor(
bulkSize int,
flushInterval time.Duration,
wantStats bool,
- initialTimeout time.Duration,
- maxTimeout time.Duration) *BulkProcessor {
+ backoff Backoff) *BulkProcessor {
return &BulkProcessor{
- c: client,
- beforeFn: beforeFn,
- afterFn: afterFn,
- name: name,
- numWorkers: numWorkers,
- bulkActions: bulkActions,
- bulkSize: bulkSize,
- flushInterval: flushInterval,
- wantStats: wantStats,
- initialTimeout: initialTimeout,
- maxTimeout: maxTimeout,
+ c: client,
+ beforeFn: beforeFn,
+ afterFn: afterFn,
+ name: name,
+ numWorkers: numWorkers,
+ bulkActions: bulkActions,
+ bulkSize: bulkSize,
+ flushInterval: flushInterval,
+ wantStats: wantStats,
+ backoff: backoff,
}
}
@@ -473,7 +476,7 @@ func (w *bulkWorker) commit(ctx context.Context) error {
}
// notifyFunc will be called if retry fails
notifyFunc := func(err error) {
- w.p.c.errorf("elastic: bulk processor %q failed but will retry: %v", w.p.name, err)
+ w.p.c.errorf("elastic: bulk processor %q failed but may retry: %v", w.p.name, err)
}
id := atomic.AddInt64(&w.p.executionId, 1)
@@ -494,8 +497,7 @@ func (w *bulkWorker) commit(ctx context.Context) error {
}
// Commit bulk requests
- policy := NewExponentialBackoff(w.p.initialTimeout, w.p.maxTimeout)
- err := RetryNotify(commitFunc, policy, notifyFunc)
+ err := RetryNotify(commitFunc, w.p.backoff, notifyFunc)
w.updateStats(res)
if err != nil {
w.p.c.errorf("elastic: bulk processor %q failed: %v", w.p.name, err)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_processor_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_processor_test.go
index a47e99652..bb97ca217 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_processor_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_processor_test.go
@@ -38,6 +38,9 @@ func TestBulkProcessorDefaults(t *testing.T) {
if got, want := p.wantStats, false; got != want {
t.Errorf("expected %v; got: %v", want, got)
}
+ if p.backoff == nil {
+ t.Fatalf("expected non-nill backoff; got: %v", p.backoff)
+ }
}
func TestBulkProcessorCommitOnBulkActions(t *testing.T) {
@@ -126,7 +129,7 @@ func TestBulkProcessorBasedOnFlushInterval(t *testing.T) {
for i := 1; i <= numDocs; i++ {
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
- request := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id(fmt.Sprintf("%d", i)).Doc(tweet)
+ request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
p.Add(request)
}
@@ -209,7 +212,7 @@ func TestBulkProcessorClose(t *testing.T) {
for i := 1; i <= numDocs; i++ {
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
- request := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id(fmt.Sprintf("%d", i)).Doc(tweet)
+ request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
p.Add(request)
}
@@ -275,7 +278,7 @@ func TestBulkProcessorFlush(t *testing.T) {
for i := 1; i <= numDocs; i++ {
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
- request := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id(fmt.Sprintf("%d", i)).Doc(tweet)
+ request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
p.Add(request)
}
@@ -356,7 +359,7 @@ func testBulkProcessor(t *testing.T, numDocs int, svc *BulkProcessorService) {
for i := 1; i <= numDocs; i++ {
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%07d. %s", i, randomString(1+rand.Intn(63)))}
- request := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id(fmt.Sprintf("%d", i)).Doc(tweet)
+ request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
p.Add(request)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
index 394439630..f31ed6613 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
@@ -8,6 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "math/rand"
"net/http"
"net/http/httptest"
"testing"
@@ -19,9 +20,9 @@ func TestBulk(t *testing.T) {
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
tweet2 := tweet{User: "sandrae", Message: "Dancing all night long. Yeah."}
- index1Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet1)
- index2Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("2").Doc(tweet2)
- delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
+ index1Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(tweet1)
+ index2Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("2").Doc(tweet2)
+ delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
bulkRequest := client.Bulk()
bulkRequest = bulkRequest.Add(index1Req)
@@ -45,7 +46,7 @@ func TestBulk(t *testing.T) {
}
// Document with Id="1" should not exist
- exists, err := client.Exists().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ exists, err := client.Exists().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -54,7 +55,7 @@ func TestBulk(t *testing.T) {
}
// Document with Id="2" should exist
- exists, err = client.Exists().Index(testIndexName).Type("tweet").Id("2").Do(context.TODO())
+ exists, err = client.Exists().Index(testIndexName).Type("doc").Id("2").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -68,7 +69,7 @@ func TestBulk(t *testing.T) {
}{
42,
}
- update1Req := NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("2").Doc(&updateDoc)
+ update1Req := NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("2").Doc(&updateDoc)
bulkRequest = client.Bulk()
bulkRequest = bulkRequest.Add(update1Req)
@@ -89,7 +90,7 @@ func TestBulk(t *testing.T) {
}
// Document with Id="1" should have a retweets count of 42
- doc, err := client.Get().Index(testIndexName).Type("tweet").Id("2").Do(context.TODO())
+ doc, err := client.Get().Index(testIndexName).Type("doc").Id("2").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -112,7 +113,7 @@ func TestBulk(t *testing.T) {
}
// Update with script
- update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("2").
+ update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("2").
RetryOnConflict(3).
Script(NewScript("ctx._source.retweets += params.v").Param("v", 1))
bulkRequest = client.Bulk()
@@ -133,7 +134,7 @@ func TestBulk(t *testing.T) {
}
// Document with Id="1" should have a retweets count of 43
- doc, err = client.Get().Index(testIndexName).Type("tweet").Id("2").Do(context.TODO())
+ doc, err = client.Get().Index(testIndexName).Type("doc").Id("2").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -161,11 +162,11 @@ func TestBulkWithIndexSetOnClient(t *testing.T) {
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
tweet2 := tweet{User: "sandrae", Message: "Dancing all night long. Yeah."}
- index1Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet1)
- index2Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("2").Doc(tweet2)
- delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
+ index1Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(tweet1).Routing("1")
+ index2Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("2").Doc(tweet2)
+ delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
- bulkRequest := client.Bulk().Index(testIndexName).Type("tweet")
+ bulkRequest := client.Bulk().Index(testIndexName).Type("doc")
bulkRequest = bulkRequest.Add(index1Req)
bulkRequest = bulkRequest.Add(index2Req)
bulkRequest = bulkRequest.Add(delete1Req)
@@ -183,7 +184,7 @@ func TestBulkWithIndexSetOnClient(t *testing.T) {
}
// Document with Id="1" should not exist
- exists, err := client.Exists().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ exists, err := client.Exists().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -192,7 +193,7 @@ func TestBulkWithIndexSetOnClient(t *testing.T) {
}
// Document with Id="2" should exist
- exists, err = client.Exists().Index(testIndexName).Type("tweet").Id("2").Do(context.TODO())
+ exists, err = client.Exists().Index(testIndexName).Type("doc").Id("2").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -201,16 +202,18 @@ func TestBulkWithIndexSetOnClient(t *testing.T) {
}
}
-func TestBulkRequestsSerialization(t *testing.T) {
+func TestBulkIndexDeleteUpdate(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
+ //client := setupTestClientAndCreateIndexAndLog(t)
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
tweet2 := tweet{User: "sandrae", Message: "Dancing all night long. Yeah."}
- index1Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet1)
- index2Req := NewBulkIndexRequest().OpType("create").Index(testIndexName).Type("tweet").Id("2").Doc(tweet2)
- delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
- update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("2").
+ index1Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(tweet1)
+ index2Req := NewBulkIndexRequest().OpType("create").Index(testIndexName).Type("doc").Id("2").Doc(tweet2)
+ delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("2").
+ ReturnSource(true).
Doc(struct {
Retweets int `json:"retweets"`
}{
@@ -227,13 +230,13 @@ func TestBulkRequestsSerialization(t *testing.T) {
t.Errorf("expected bulkRequest.NumberOfActions %d; got %d", 4, bulkRequest.NumberOfActions())
}
- expected := `{"index":{"_id":"1","_index":"` + testIndexName + `","_type":"tweet"}}
+ expected := `{"index":{"_index":"` + testIndexName + `","_id":"1","_type":"doc"}}
{"user":"olivere","message":"Welcome to Golang and Elasticsearch.","retweets":0,"created":"0001-01-01T00:00:00Z"}
-{"create":{"_id":"2","_index":"` + testIndexName + `","_type":"tweet"}}
+{"create":{"_index":"` + testIndexName + `","_id":"2","_type":"doc"}}
{"user":"sandrae","message":"Dancing all night long. Yeah.","retweets":0,"created":"0001-01-01T00:00:00Z"}
-{"delete":{"_id":"1","_index":"` + testIndexName + `","_type":"tweet"}}
-{"update":{"_id":"2","_index":"` + testIndexName + `","_type":"tweet"}}
-{"doc":{"retweets":42}}
+{"delete":{"_index":"` + testIndexName + `","_type":"doc","_id":"1"}}
+{"update":{"_index":"` + testIndexName + `","_type":"doc","_id":"2"}}
+{"doc":{"retweets":42},"_source":true}
`
got, err := bulkRequest.bodyAsString()
if err != nil {
@@ -244,7 +247,7 @@ func TestBulkRequestsSerialization(t *testing.T) {
}
// Run the bulk request
- bulkResponse, err := bulkRequest.Do(context.TODO())
+ bulkResponse, err := bulkRequest.Pretty(true).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -290,6 +293,9 @@ func TestBulkRequestsSerialization(t *testing.T) {
if created[0].Status != 201 {
t.Errorf("expected created[0].Status == %d; got %d", 201, created[0].Status)
}
+ if want, have := "created", created[0].Result; want != have {
+ t.Errorf("expected created[0].Result == %q; got %q", want, have)
+ }
// Deleted actions
deleted := bulkResponse.Deleted()
@@ -305,8 +311,8 @@ func TestBulkRequestsSerialization(t *testing.T) {
if deleted[0].Status != 200 {
t.Errorf("expected deleted[0].Status == %d; got %d", 200, deleted[0].Status)
}
- if !deleted[0].Found {
- t.Errorf("expected deleted[0].Found == %v; got %v", true, deleted[0].Found)
+ if want, have := "deleted", deleted[0].Result; want != have {
+ t.Errorf("expected deleted[0].Result == %q; got %q", want, have)
}
// Updated actions
@@ -326,6 +332,25 @@ func TestBulkRequestsSerialization(t *testing.T) {
if updated[0].Version != 2 {
t.Errorf("expected updated[0].Version == %d; got %d", 2, updated[0].Version)
}
+ if want, have := "updated", updated[0].Result; want != have {
+ t.Errorf("expected updated[0].Result == %q; got %q", want, have)
+ }
+ if updated[0].GetResult == nil {
+ t.Fatalf("expected updated[0].GetResult to be != nil; got nil")
+ }
+ if updated[0].GetResult.Source == nil {
+ t.Fatalf("expected updated[0].GetResult.Source to be != nil; got nil")
+ }
+ if want, have := true, updated[0].GetResult.Found; want != have {
+ t.Fatalf("expected updated[0].GetResult.Found to be != %v; got %v", want, have)
+ }
+ var doc tweet
+ if err := json.Unmarshal(*updated[0].GetResult.Source, &doc); err != nil {
+ t.Fatalf("expected to unmarshal updated[0].GetResult.Source; got %v", err)
+ }
+ if want, have := 42, doc.Retweets; want != have {
+ t.Fatalf("expected updated tweet to have Retweets = %v; got %v", want, have)
+ }
// Succeeded actions
succeeded := bulkResponse.Succeeded()
@@ -371,7 +396,7 @@ func TestFailedBulkRequests(t *testing.T) {
"items" : [ {
"index" : {
"_index" : "elastic-test",
- "_type" : "tweet",
+ "_type" : "doc",
"_id" : "1",
"_version" : 1,
"status" : 201
@@ -379,7 +404,7 @@ func TestFailedBulkRequests(t *testing.T) {
}, {
"create" : {
"_index" : "elastic-test",
- "_type" : "tweet",
+ "_type" : "doc",
"_id" : "2",
"_version" : 1,
"status" : 423,
@@ -391,7 +416,7 @@ func TestFailedBulkRequests(t *testing.T) {
}, {
"delete" : {
"_index" : "elastic-test",
- "_type" : "tweet",
+ "_type" : "doc",
"_id" : "1",
"_version" : 2,
"status" : 404,
@@ -400,7 +425,7 @@ func TestFailedBulkRequests(t *testing.T) {
}, {
"update" : {
"_index" : "elastic-test",
- "_type" : "tweet",
+ "_type" : "doc",
"_id" : "2",
"_version" : 2,
"status" : 200
@@ -425,10 +450,10 @@ func TestBulkEstimatedSizeInBytes(t *testing.T) {
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
tweet2 := tweet{User: "sandrae", Message: "Dancing all night long. Yeah."}
- index1Req := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet1)
- index2Req := NewBulkIndexRequest().OpType("create").Index(testIndexName).Type("tweet").Id("2").Doc(tweet2)
- delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
- update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("2").
+ index1Req := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(tweet1)
+ index2Req := NewBulkIndexRequest().OpType("create").Index(testIndexName).Type("doc").Id("2").Doc(tweet2)
+ delete1Req := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ update2Req := NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("2").
Doc(struct {
Retweets int `json:"retweets"`
}{
@@ -468,13 +493,39 @@ func TestBulkEstimatedSizeInBytes(t *testing.T) {
func TestBulkEstimateSizeInBytesLength(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
s := client.Bulk()
- r := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
+ r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
s = s.Add(r)
if got, want := s.estimateSizeInBytes(r), int64(1+len(r.String())); got != want {
t.Fatalf("expected %d; got: %d", want, got)
}
}
+func TestBulkContentType(t *testing.T) {
+ var header http.Header
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ header = r.Header
+ fmt.Fprintln(w, `{}`)
+ }))
+ defer ts.Close()
+
+ client, err := NewSimpleClient(SetURL(ts.URL))
+ if err != nil {
+ t.Fatal(err)
+ }
+ indexReq := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."})
+ if _, err := client.Bulk().Add(indexReq).Do(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ if header == nil {
+ t.Fatalf("expected header, got %v", header)
+ }
+ if want, have := "application/x-ndjson", header.Get("Content-Type"); want != have {
+ t.Fatalf("Content-Type: want %q, have %q", want, have)
+ }
+}
+
+// -- Benchmarks --
+
var benchmarkBulkEstimatedSizeInBytes int64
func BenchmarkBulkEstimatedSizeInBytesWith1Request(b *testing.B) {
@@ -482,9 +533,9 @@ func BenchmarkBulkEstimatedSizeInBytesWith1Request(b *testing.B) {
s := client.Bulk()
var result int64
for n := 0; n < b.N; n++ {
- s = s.Add(NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(struct{ A string }{"1"}))
- s = s.Add(NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("1").Doc(struct{ A string }{"2"}))
- s = s.Add(NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1"))
+ s = s.Add(NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(struct{ A string }{"1"}))
+ s = s.Add(NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("1").Doc(struct{ A string }{"2"}))
+ s = s.Add(NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1"))
result = s.EstimatedSizeInBytes()
s.reset()
}
@@ -498,9 +549,9 @@ func BenchmarkBulkEstimatedSizeInBytesWith100Requests(b *testing.B) {
var result int64
for n := 0; n < b.N; n++ {
for i := 0; i < 100; i++ {
- s = s.Add(NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(struct{ A string }{"1"}))
- s = s.Add(NewBulkUpdateRequest().Index(testIndexName).Type("tweet").Id("1").Doc(struct{ A string }{"2"}))
- s = s.Add(NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1"))
+ s = s.Add(NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").Doc(struct{ A string }{"1"}))
+ s = s.Add(NewBulkUpdateRequest().Index(testIndexName).Type("doc").Id("1").Doc(struct{ A string }{"2"}))
+ s = s.Add(NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1"))
}
result = s.EstimatedSizeInBytes()
s.reset()
@@ -509,26 +560,41 @@ func BenchmarkBulkEstimatedSizeInBytesWith100Requests(b *testing.B) {
benchmarkBulkEstimatedSizeInBytes = result // ensure the compiler doesn't optimize
}
-func TestBulkContentType(t *testing.T) {
- var header http.Header
- ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- header = r.Header
- fmt.Fprintln(w, `{}`)
- }))
- defer ts.Close()
+func BenchmarkBulkAllocs(b *testing.B) {
+ b.Run("1000 docs with 64 byte", func(b *testing.B) { benchmarkBulkAllocs(b, 64, 1000) })
+ b.Run("1000 docs with 1 KiB", func(b *testing.B) { benchmarkBulkAllocs(b, 1024, 1000) })
+ b.Run("1000 docs with 4 KiB", func(b *testing.B) { benchmarkBulkAllocs(b, 4096, 1000) })
+ b.Run("1000 docs with 16 KiB", func(b *testing.B) { benchmarkBulkAllocs(b, 16*1024, 1000) })
+ b.Run("1000 docs with 64 KiB", func(b *testing.B) { benchmarkBulkAllocs(b, 64*1024, 1000) })
+ b.Run("1000 docs with 256 KiB", func(b *testing.B) { benchmarkBulkAllocs(b, 256*1024, 1000) })
+ b.Run("1000 docs with 1 MiB", func(b *testing.B) { benchmarkBulkAllocs(b, 1024*1024, 1000) })
+}
- client, err := NewSimpleClient(SetURL(ts.URL))
- if err != nil {
- t.Fatal(err)
- }
- indexReq := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."})
- if _, err := client.Bulk().Add(indexReq).Do(context.Background()); err != nil {
- t.Fatal(err)
+const (
+ charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
+)
+
+func benchmarkBulkAllocs(b *testing.B, size, num int) {
+ buf := make([]byte, size)
+ for i := range buf {
+ buf[i] = charset[rand.Intn(len(charset))]
}
- if header == nil {
- t.Fatalf("expected header, got %v", header)
+
+ s := &BulkService{}
+ n := 0
+ for {
+ n++
+ s = s.Add(NewBulkIndexRequest().Index("test").Type("doc").Id("1").Doc(struct {
+ S string `json:"s"`
+ }{
+ S: string(buf),
+ }))
+ if n >= num {
+ break
+ }
}
- if want, have := "application/x-ndjson", header.Get("Content-Type"); want != have {
- t.Fatalf("Content-Type: want %q, have %q", want, have)
+ for i := 0; i < b.N; i++ {
+ s.bodyAsString()
}
+ b.ReportAllocs()
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request.go
index b0dbf0917..50e5adb8f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request.go
@@ -4,6 +4,8 @@
package elastic
+//go:generate easyjson bulk_update_request.go
+
import (
"encoding/json"
"fmt"
@@ -12,7 +14,7 @@ import (
// BulkUpdateRequest is a request to update a document in Elasticsearch.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
type BulkUpdateRequest struct {
BulkableRequest
@@ -31,8 +33,38 @@ type BulkUpdateRequest struct {
docAsUpsert *bool
detectNoop *bool
doc interface{}
+ returnSource *bool
source []string
+
+ useEasyJSON bool
+}
+
+//easyjson:json
+type bulkUpdateRequestCommand map[string]bulkUpdateRequestCommandOp
+
+//easyjson:json
+type bulkUpdateRequestCommandOp struct {
+ Index string `json:"_index,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Parent string `json:"parent,omitempty"`
+ // RetryOnConflict is "_retry_on_conflict" for 6.0 and "retry_on_conflict" for 6.1+.
+ RetryOnConflict *int `json:"retry_on_conflict,omitempty"`
+ Routing string `json:"routing,omitempty"`
+ Version int64 `json:"version,omitempty"`
+ VersionType string `json:"version_type,omitempty"`
+}
+
+//easyjson:json
+type bulkUpdateRequestCommandData struct {
+ DetectNoop *bool `json:"detect_noop,omitempty"`
+ Doc interface{} `json:"doc,omitempty"`
+ DocAsUpsert *bool `json:"doc_as_upsert,omitempty"`
+ Script interface{} `json:"script,omitempty"`
+ ScriptedUpsert *bool `json:"scripted_upsert,omitempty"`
+ Upsert interface{} `json:"upsert,omitempty"`
+ Source *bool `json:"_source,omitempty"`
}
// NewBulkUpdateRequest returns a new BulkUpdateRequest.
@@ -40,6 +72,16 @@ func NewBulkUpdateRequest() *BulkUpdateRequest {
return &BulkUpdateRequest{}
}
+// UseEasyJSON is an experimental setting that enables serialization
+// with github.com/mailru/easyjson, which should in faster serialization
+// time and less allocations, but removed compatibility with encoding/json,
+// usage of unsafe etc. See https://github.com/mailru/easyjson#issues-notes-and-limitations
+// for details. This setting is disabled by default.
+func (r *BulkUpdateRequest) UseEasyJSON(enable bool) *BulkUpdateRequest {
+ r.useEasyJSON = enable
+ return r
+}
+
// Index specifies the Elasticsearch index to use for this update request.
// If unspecified, the index set on the BulkService will be used.
func (r *BulkUpdateRequest) Index(index string) *BulkUpdateRequest {
@@ -78,8 +120,8 @@ func (r *BulkUpdateRequest) Parent(parent string) *BulkUpdateRequest {
}
// Script specifies an update script.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html#bulk-update
-// and https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html#bulk-update
+// and https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html
// for details.
func (r *BulkUpdateRequest) Script(script *Script) *BulkUpdateRequest {
r.script = script
@@ -90,7 +132,7 @@ func (r *BulkUpdateRequest) Script(script *Script) *BulkUpdateRequest {
// ScripedUpsert specifies if your script will run regardless of
// whether the document exists or not.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-update.html#_literal_scripted_upsert_literal
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-update.html#_literal_scripted_upsert_literal
func (r *BulkUpdateRequest) ScriptedUpsert(upsert bool) *BulkUpdateRequest {
r.scriptedUpsert = &upsert
r.source = nil
@@ -113,7 +155,7 @@ func (r *BulkUpdateRequest) Version(version int64) *BulkUpdateRequest {
}
// VersionType can be "internal" (default), "external", "external_gte",
-// "external_gt", or "force".
+// or "external_gt".
func (r *BulkUpdateRequest) VersionType(versionType string) *BulkUpdateRequest {
r.versionType = versionType
r.source = nil
@@ -130,7 +172,7 @@ func (r *BulkUpdateRequest) Doc(doc interface{}) *BulkUpdateRequest {
// DocAsUpsert indicates whether the contents of Doc should be used as
// the Upsert value.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-update.html#_literal_doc_as_upsert_literal
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-update.html#_literal_doc_as_upsert_literal
// for details.
func (r *BulkUpdateRequest) DocAsUpsert(docAsUpsert bool) *BulkUpdateRequest {
r.docAsUpsert = &docAsUpsert
@@ -155,6 +197,15 @@ func (r *BulkUpdateRequest) Upsert(doc interface{}) *BulkUpdateRequest {
return r
}
+// ReturnSource specifies whether Elasticsearch should return the source
+// after the update. In the request, this responds to the `_source` field.
+// It is false by default.
+func (r *BulkUpdateRequest) ReturnSource(source bool) *BulkUpdateRequest {
+ r.returnSource = &source
+ r.source = nil
+ return r
+}
+
// String returns the on-wire representation of the update request,
// concatenated as a single string.
func (r *BulkUpdateRequest) String() string {
@@ -165,28 +216,9 @@ func (r *BulkUpdateRequest) String() string {
return strings.Join(lines, "\n")
}
-func (r *BulkUpdateRequest) getSourceAsString(data interface{}) (string, error) {
- switch t := data.(type) {
- default:
- body, err := json.Marshal(data)
- if err != nil {
- return "", err
- }
- return string(body), nil
- case json.RawMessage:
- return string(t), nil
- case *json.RawMessage:
- return string(*t), nil
- case string:
- return t, nil
- case *string:
- return *t, nil
- }
-}
-
// Source returns the on-wire representation of the update request,
// split into an action-and-meta-data line and an (optional) source line.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details.
func (r *BulkUpdateRequest) Source() ([]string, error) {
// { "update" : { "_index" : "test", "_type" : "type1", "_id" : "1", ... } }
@@ -202,69 +234,65 @@ func (r *BulkUpdateRequest) Source() ([]string, error) {
lines := make([]string, 2)
// "update" ...
- command := make(map[string]interface{})
- updateCommand := make(map[string]interface{})
- if r.index != "" {
- updateCommand["_index"] = r.index
- }
- if r.typ != "" {
- updateCommand["_type"] = r.typ
- }
- if r.id != "" {
- updateCommand["_id"] = r.id
- }
- if r.routing != "" {
- updateCommand["_routing"] = r.routing
- }
- if r.parent != "" {
- updateCommand["_parent"] = r.parent
- }
- if r.version > 0 {
- updateCommand["_version"] = r.version
+ updateCommand := bulkUpdateRequestCommandOp{
+ Index: r.index,
+ Type: r.typ,
+ Id: r.id,
+ Routing: r.routing,
+ Parent: r.parent,
+ Version: r.version,
+ VersionType: r.versionType,
+ RetryOnConflict: r.retryOnConflict,
}
- if r.versionType != "" {
- updateCommand["_version_type"] = r.versionType
+ command := bulkUpdateRequestCommand{
+ "update": updateCommand,
}
- if r.retryOnConflict != nil {
- updateCommand["_retry_on_conflict"] = *r.retryOnConflict
+
+ var err error
+ var body []byte
+ if r.useEasyJSON {
+ // easyjson
+ body, err = command.MarshalJSON()
+ } else {
+ // encoding/json
+ body, err = json.Marshal(command)
}
- command["update"] = updateCommand
- line, err := json.Marshal(command)
if err != nil {
return nil, err
}
- lines[0] = string(line)
+
+ lines[0] = string(body)
// 2nd line: {"doc" : { ... }} or {"script": {...}}
- source := make(map[string]interface{})
- if r.docAsUpsert != nil {
- source["doc_as_upsert"] = *r.docAsUpsert
- }
- if r.detectNoop != nil {
- source["detect_noop"] = *r.detectNoop
- }
- if r.upsert != nil {
- source["upsert"] = r.upsert
+ data := bulkUpdateRequestCommandData{
+ DocAsUpsert: r.docAsUpsert,
+ DetectNoop: r.detectNoop,
+ Upsert: r.upsert,
+ ScriptedUpsert: r.scriptedUpsert,
+ Doc: r.doc,
+ Source: r.returnSource,
}
- if r.scriptedUpsert != nil {
- source["scripted_upsert"] = *r.scriptedUpsert
- }
- if r.doc != nil {
- // {"doc":{...}}
- source["doc"] = r.doc
- } else if r.script != nil {
- // {"script":...}
- src, err := r.script.Source()
+ if r.script != nil {
+ script, err := r.script.Source()
if err != nil {
return nil, err
}
- source["script"] = src
+ data.Script = script
+ }
+
+ if r.useEasyJSON {
+ // easyjson
+ body, err = data.MarshalJSON()
+ } else {
+ // encoding/json
+ body, err = json.Marshal(data)
}
- lines[1], err = r.getSourceAsString(source)
if err != nil {
return nil, err
}
+ lines[1] = string(body)
+
r.source = lines
return lines, nil
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_easyjson.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_easyjson.go
new file mode 100644
index 000000000..d2c2cbfc7
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_easyjson.go
@@ -0,0 +1,461 @@
+// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
+
+package elastic
+
+import (
+ json "encoding/json"
+ easyjson "github.com/mailru/easyjson"
+ jlexer "github.com/mailru/easyjson/jlexer"
+ jwriter "github.com/mailru/easyjson/jwriter"
+)
+
+// suppress unused package warning
+var (
+ _ *json.RawMessage
+ _ *jlexer.Lexer
+ _ *jwriter.Writer
+ _ easyjson.Marshaler
+)
+
+func easyjson1ed00e60DecodeGithubComOlivereElastic(in *jlexer.Lexer, out *bulkUpdateRequestCommandOp) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ if isTopLevel {
+ in.Consumed()
+ }
+ in.Skip()
+ return
+ }
+ in.Delim('{')
+ for !in.IsDelim('}') {
+ key := in.UnsafeString()
+ in.WantColon()
+ if in.IsNull() {
+ in.Skip()
+ in.WantComma()
+ continue
+ }
+ switch key {
+ case "_index":
+ out.Index = string(in.String())
+ case "_type":
+ out.Type = string(in.String())
+ case "_id":
+ out.Id = string(in.String())
+ case "parent":
+ out.Parent = string(in.String())
+ case "retry_on_conflict":
+ if in.IsNull() {
+ in.Skip()
+ out.RetryOnConflict = nil
+ } else {
+ if out.RetryOnConflict == nil {
+ out.RetryOnConflict = new(int)
+ }
+ *out.RetryOnConflict = int(in.Int())
+ }
+ case "routing":
+ out.Routing = string(in.String())
+ case "version":
+ out.Version = int64(in.Int64())
+ case "version_type":
+ out.VersionType = string(in.String())
+ default:
+ in.SkipRecursive()
+ }
+ in.WantComma()
+ }
+ in.Delim('}')
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson1ed00e60EncodeGithubComOlivereElastic(out *jwriter.Writer, in bulkUpdateRequestCommandOp) {
+ out.RawByte('{')
+ first := true
+ _ = first
+ if in.Index != "" {
+ const prefix string = ",\"_index\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Index))
+ }
+ if in.Type != "" {
+ const prefix string = ",\"_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Type))
+ }
+ if in.Id != "" {
+ const prefix string = ",\"_id\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Id))
+ }
+ if in.Parent != "" {
+ const prefix string = ",\"parent\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Parent))
+ }
+ if in.RetryOnConflict != nil {
+ const prefix string = ",\"retry_on_conflict\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Int(int(*in.RetryOnConflict))
+ }
+ if in.Routing != "" {
+ const prefix string = ",\"routing\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.Routing))
+ }
+ if in.Version != 0 {
+ const prefix string = ",\"version\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Int64(int64(in.Version))
+ }
+ if in.VersionType != "" {
+ const prefix string = ",\"version_type\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.String(string(in.VersionType))
+ }
+ out.RawByte('}')
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkUpdateRequestCommandOp) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson1ed00e60EncodeGithubComOlivereElastic(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkUpdateRequestCommandOp) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson1ed00e60EncodeGithubComOlivereElastic(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkUpdateRequestCommandOp) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson1ed00e60DecodeGithubComOlivereElastic(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkUpdateRequestCommandOp) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson1ed00e60DecodeGithubComOlivereElastic(l, v)
+}
+func easyjson1ed00e60DecodeGithubComOlivereElastic1(in *jlexer.Lexer, out *bulkUpdateRequestCommandData) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ if isTopLevel {
+ in.Consumed()
+ }
+ in.Skip()
+ return
+ }
+ in.Delim('{')
+ for !in.IsDelim('}') {
+ key := in.UnsafeString()
+ in.WantColon()
+ if in.IsNull() {
+ in.Skip()
+ in.WantComma()
+ continue
+ }
+ switch key {
+ case "detect_noop":
+ if in.IsNull() {
+ in.Skip()
+ out.DetectNoop = nil
+ } else {
+ if out.DetectNoop == nil {
+ out.DetectNoop = new(bool)
+ }
+ *out.DetectNoop = bool(in.Bool())
+ }
+ case "doc":
+ if m, ok := out.Doc.(easyjson.Unmarshaler); ok {
+ m.UnmarshalEasyJSON(in)
+ } else if m, ok := out.Doc.(json.Unmarshaler); ok {
+ _ = m.UnmarshalJSON(in.Raw())
+ } else {
+ out.Doc = in.Interface()
+ }
+ case "doc_as_upsert":
+ if in.IsNull() {
+ in.Skip()
+ out.DocAsUpsert = nil
+ } else {
+ if out.DocAsUpsert == nil {
+ out.DocAsUpsert = new(bool)
+ }
+ *out.DocAsUpsert = bool(in.Bool())
+ }
+ case "script":
+ if m, ok := out.Script.(easyjson.Unmarshaler); ok {
+ m.UnmarshalEasyJSON(in)
+ } else if m, ok := out.Script.(json.Unmarshaler); ok {
+ _ = m.UnmarshalJSON(in.Raw())
+ } else {
+ out.Script = in.Interface()
+ }
+ case "scripted_upsert":
+ if in.IsNull() {
+ in.Skip()
+ out.ScriptedUpsert = nil
+ } else {
+ if out.ScriptedUpsert == nil {
+ out.ScriptedUpsert = new(bool)
+ }
+ *out.ScriptedUpsert = bool(in.Bool())
+ }
+ case "upsert":
+ if m, ok := out.Upsert.(easyjson.Unmarshaler); ok {
+ m.UnmarshalEasyJSON(in)
+ } else if m, ok := out.Upsert.(json.Unmarshaler); ok {
+ _ = m.UnmarshalJSON(in.Raw())
+ } else {
+ out.Upsert = in.Interface()
+ }
+ case "_source":
+ if in.IsNull() {
+ in.Skip()
+ out.Source = nil
+ } else {
+ if out.Source == nil {
+ out.Source = new(bool)
+ }
+ *out.Source = bool(in.Bool())
+ }
+ default:
+ in.SkipRecursive()
+ }
+ in.WantComma()
+ }
+ in.Delim('}')
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson1ed00e60EncodeGithubComOlivereElastic1(out *jwriter.Writer, in bulkUpdateRequestCommandData) {
+ out.RawByte('{')
+ first := true
+ _ = first
+ if in.DetectNoop != nil {
+ const prefix string = ",\"detect_noop\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Bool(bool(*in.DetectNoop))
+ }
+ if in.Doc != nil {
+ const prefix string = ",\"doc\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ if m, ok := in.Doc.(easyjson.Marshaler); ok {
+ m.MarshalEasyJSON(out)
+ } else if m, ok := in.Doc.(json.Marshaler); ok {
+ out.Raw(m.MarshalJSON())
+ } else {
+ out.Raw(json.Marshal(in.Doc))
+ }
+ }
+ if in.DocAsUpsert != nil {
+ const prefix string = ",\"doc_as_upsert\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Bool(bool(*in.DocAsUpsert))
+ }
+ if in.Script != nil {
+ const prefix string = ",\"script\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ if m, ok := in.Script.(easyjson.Marshaler); ok {
+ m.MarshalEasyJSON(out)
+ } else if m, ok := in.Script.(json.Marshaler); ok {
+ out.Raw(m.MarshalJSON())
+ } else {
+ out.Raw(json.Marshal(in.Script))
+ }
+ }
+ if in.ScriptedUpsert != nil {
+ const prefix string = ",\"scripted_upsert\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Bool(bool(*in.ScriptedUpsert))
+ }
+ if in.Upsert != nil {
+ const prefix string = ",\"upsert\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ if m, ok := in.Upsert.(easyjson.Marshaler); ok {
+ m.MarshalEasyJSON(out)
+ } else if m, ok := in.Upsert.(json.Marshaler); ok {
+ out.Raw(m.MarshalJSON())
+ } else {
+ out.Raw(json.Marshal(in.Upsert))
+ }
+ }
+ if in.Source != nil {
+ const prefix string = ",\"_source\":"
+ if first {
+ first = false
+ out.RawString(prefix[1:])
+ } else {
+ out.RawString(prefix)
+ }
+ out.Bool(bool(*in.Source))
+ }
+ out.RawByte('}')
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkUpdateRequestCommandData) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson1ed00e60EncodeGithubComOlivereElastic1(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkUpdateRequestCommandData) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson1ed00e60EncodeGithubComOlivereElastic1(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkUpdateRequestCommandData) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson1ed00e60DecodeGithubComOlivereElastic1(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkUpdateRequestCommandData) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson1ed00e60DecodeGithubComOlivereElastic1(l, v)
+}
+func easyjson1ed00e60DecodeGithubComOlivereElastic2(in *jlexer.Lexer, out *bulkUpdateRequestCommand) {
+ isTopLevel := in.IsStart()
+ if in.IsNull() {
+ in.Skip()
+ } else {
+ in.Delim('{')
+ if !in.IsDelim('}') {
+ *out = make(bulkUpdateRequestCommand)
+ } else {
+ *out = nil
+ }
+ for !in.IsDelim('}') {
+ key := string(in.String())
+ in.WantColon()
+ var v1 bulkUpdateRequestCommandOp
+ (v1).UnmarshalEasyJSON(in)
+ (*out)[key] = v1
+ in.WantComma()
+ }
+ in.Delim('}')
+ }
+ if isTopLevel {
+ in.Consumed()
+ }
+}
+func easyjson1ed00e60EncodeGithubComOlivereElastic2(out *jwriter.Writer, in bulkUpdateRequestCommand) {
+ if in == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
+ out.RawString(`null`)
+ } else {
+ out.RawByte('{')
+ v2First := true
+ for v2Name, v2Value := range in {
+ if v2First {
+ v2First = false
+ } else {
+ out.RawByte(',')
+ }
+ out.String(string(v2Name))
+ out.RawByte(':')
+ (v2Value).MarshalEasyJSON(out)
+ }
+ out.RawByte('}')
+ }
+}
+
+// MarshalJSON supports json.Marshaler interface
+func (v bulkUpdateRequestCommand) MarshalJSON() ([]byte, error) {
+ w := jwriter.Writer{}
+ easyjson1ed00e60EncodeGithubComOlivereElastic2(&w, v)
+ return w.Buffer.BuildBytes(), w.Error
+}
+
+// MarshalEasyJSON supports easyjson.Marshaler interface
+func (v bulkUpdateRequestCommand) MarshalEasyJSON(w *jwriter.Writer) {
+ easyjson1ed00e60EncodeGithubComOlivereElastic2(w, v)
+}
+
+// UnmarshalJSON supports json.Unmarshaler interface
+func (v *bulkUpdateRequestCommand) UnmarshalJSON(data []byte) error {
+ r := jlexer.Lexer{Data: data}
+ easyjson1ed00e60DecodeGithubComOlivereElastic2(&r, v)
+ return r.Error()
+}
+
+// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
+func (v *bulkUpdateRequestCommand) UnmarshalEasyJSON(l *jlexer.Lexer) {
+ easyjson1ed00e60DecodeGithubComOlivereElastic2(l, v)
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_test.go
index afe873890..53e73bd40 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_update_request_test.go
@@ -15,19 +15,20 @@ func TestBulkUpdateRequestSerialization(t *testing.T) {
}{
// #0
{
- Request: NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").Doc(struct {
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").Doc(struct {
Counter int64 `json:"counter"`
}{
Counter: 42,
}),
Expected: []string{
- `{"update":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"update":{"_index":"index1","_type":"doc","_id":"1"}}`,
`{"doc":{"counter":42}}`,
},
},
// #1
{
- Request: NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").
+ Routing("123").
RetryOnConflict(3).
DocAsUpsert(true).
Doc(struct {
@@ -36,13 +37,13 @@ func TestBulkUpdateRequestSerialization(t *testing.T) {
Counter: 42,
}),
Expected: []string{
- `{"update":{"_id":"1","_index":"index1","_retry_on_conflict":3,"_type":"tweet"}}`,
+ `{"update":{"_index":"index1","_type":"doc","_id":"1","retry_on_conflict":3,"routing":"123"}}`,
`{"doc":{"counter":42},"doc_as_upsert":true}`,
},
},
// #2
{
- Request: NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").
RetryOnConflict(3).
Script(NewScript(`ctx._source.retweets += param1`).Lang("javascript").Param("param1", 42)).
Upsert(struct {
@@ -51,25 +52,25 @@ func TestBulkUpdateRequestSerialization(t *testing.T) {
Counter: 42,
}),
Expected: []string{
- `{"update":{"_id":"1","_index":"index1","_retry_on_conflict":3,"_type":"tweet"}}`,
- `{"script":{"inline":"ctx._source.retweets += param1","lang":"javascript","params":{"param1":42}},"upsert":{"counter":42}}`,
+ `{"update":{"_index":"index1","_type":"doc","_id":"1","retry_on_conflict":3}}`,
+ `{"script":{"lang":"javascript","params":{"param1":42},"source":"ctx._source.retweets += param1"},"upsert":{"counter":42}}`,
},
},
// #3
{
- Request: NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").DetectNoop(true).Doc(struct {
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").DetectNoop(true).Doc(struct {
Counter int64 `json:"counter"`
}{
Counter: 42,
}),
Expected: []string{
- `{"update":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"update":{"_index":"index1","_type":"doc","_id":"1"}}`,
`{"detect_noop":true,"doc":{"counter":42}}`,
},
},
// #4
{
- Request: NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").
RetryOnConflict(3).
ScriptedUpsert(true).
Script(NewScript(`ctx._source.retweets += param1`).Lang("javascript").Param("param1", 42)).
@@ -79,8 +80,20 @@ func TestBulkUpdateRequestSerialization(t *testing.T) {
Counter: 42,
}),
Expected: []string{
- `{"update":{"_id":"1","_index":"index1","_retry_on_conflict":3,"_type":"tweet"}}`,
- `{"script":{"inline":"ctx._source.retweets += param1","lang":"javascript","params":{"param1":42}},"scripted_upsert":true,"upsert":{"counter":42}}`,
+ `{"update":{"_index":"index1","_type":"doc","_id":"1","retry_on_conflict":3}}`,
+ `{"script":{"lang":"javascript","params":{"param1":42},"source":"ctx._source.retweets += param1"},"scripted_upsert":true,"upsert":{"counter":42}}`,
+ },
+ },
+ // #5
+ {
+ Request: NewBulkUpdateRequest().Index("index1").Type("doc").Id("4").ReturnSource(true).Doc(struct {
+ Counter int64 `json:"counter"`
+ }{
+ Counter: 42,
+ }),
+ Expected: []string{
+ `{"update":{"_index":"index1","_type":"doc","_id":"4"}}`,
+ `{"doc":{"counter":42},"_source":true}`,
},
},
}
@@ -107,15 +120,30 @@ func TestBulkUpdateRequestSerialization(t *testing.T) {
var bulkUpdateRequestSerializationResult string
func BenchmarkBulkUpdateRequestSerialization(b *testing.B) {
- r := NewBulkUpdateRequest().Index("index1").Type("tweet").Id("1").Doc(struct {
- Counter int64 `json:"counter"`
- }{
- Counter: 42,
+ b.Run("stdlib", func(b *testing.B) {
+ r := NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").Doc(struct {
+ Counter int64 `json:"counter"`
+ }{
+ Counter: 42,
+ })
+ benchmarkBulkUpdateRequestSerialization(b, r.UseEasyJSON(false))
})
+ b.Run("easyjson", func(b *testing.B) {
+ r := NewBulkUpdateRequest().Index("index1").Type("doc").Id("1").Doc(struct {
+ Counter int64 `json:"counter"`
+ }{
+ Counter: 42,
+ }).UseEasyJSON(false)
+ benchmarkBulkUpdateRequestSerialization(b, r.UseEasyJSON(true))
+ })
+}
+
+func benchmarkBulkUpdateRequestSerialization(b *testing.B, r *BulkUpdateRequest) {
var s string
for n := 0; n < b.N; n++ {
s = r.String()
r.source = nil // Don't let caching spoil the benchmark
}
bulkUpdateRequestSerializationResult = s // ensure the compiler doesn't optimize
+ b.ReportAllocs()
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/clear_scroll.go b/vendor/gopkg.in/olivere/elastic.v5/clear_scroll.go
index 83e592875..4f449504c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/clear_scroll.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/clear_scroll.go
@@ -12,7 +12,7 @@ import (
// ClearScrollService clears one or more scroll contexts by their ids.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html#_clear_scroll_api
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html#_clear_scroll_api
// for details.
type ClearScrollService struct {
client *Client
@@ -49,7 +49,7 @@ func (s *ClearScrollService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
return path, params, nil
}
@@ -85,7 +85,12 @@ func (s *ClearScrollService) Do(ctx context.Context) (*ClearScrollResponse, erro
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/clear_scroll_test.go b/vendor/gopkg.in/olivere/elastic.v5/clear_scroll_test.go
index 56a9d936c..4037d3cd6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/clear_scroll_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/clear_scroll_test.go
@@ -19,17 +19,17 @@ func TestClearScroll(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client.go b/vendor/gopkg.in/olivere/elastic.v5/client.go
index 9a48d9ac7..1eb0ec54f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/client.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/client.go
@@ -21,12 +21,12 @@ import (
"github.com/pkg/errors"
- "gopkg.in/olivere/elastic.v5/config"
+ "github.com/olivere/elastic/config"
)
const (
// Version is the current version of Elastic.
- Version = "5.0.53"
+ Version = "6.1.4"
// DefaultURL is the default endpoint of Elasticsearch on the local machine.
// It is used e.g. when initializing a new Client without a specific URL.
@@ -76,9 +76,6 @@ const (
// a GET request with a body.
DefaultSendGetBodyAs = "GET"
- // DefaultGzipEnabled specifies if gzip compression is enabled by default.
- DefaultGzipEnabled = false
-
// off is used to disable timeouts.
off = -1 * time.Second
)
@@ -135,7 +132,6 @@ type Client struct {
basicAuthPassword string // password for HTTP Basic Auth
sendGetBodyAs string // override for when sending a GET with a body
requiredPlugins []string // list of required plugins
- gzipEnabled bool // gzip compression enabled or disabled (default)
retrier Retrier // strategy for retries
}
@@ -158,7 +154,7 @@ type Client struct {
//
// If the sniffer is enabled (the default), the new client then sniffes
// the cluster via the Nodes Info API
-// (see https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-nodes-info.html#cluster-nodes-info).
+// (see https://www.elastic.co/guide/en/elasticsearch/reference/6.0/cluster-nodes-info.html#cluster-nodes-info).
// It uses the URLs specified by the caller. The caller is responsible
// to only pass a list of URLs of nodes that belong to the same cluster.
// This sniffing process is run on startup and periodically.
@@ -209,7 +205,6 @@ func NewClient(options ...ClientOptionFunc) (*Client, error) {
snifferCallback: nopSnifferCallback,
snifferStop: make(chan bool),
sendGetBodyAs: DefaultSendGetBodyAs,
- gzipEnabled: DefaultGzipEnabled,
retrier: noRetries, // no retries by default
}
@@ -367,7 +362,6 @@ func NewSimpleClient(options ...ClientOptionFunc) (*Client, error) {
snifferCallback: nopSnifferCallback,
snifferStop: make(chan bool),
sendGetBodyAs: DefaultSendGetBodyAs,
- gzipEnabled: DefaultGzipEnabled,
retrier: noRetries, // no retries by default
}
@@ -596,14 +590,6 @@ func SetMaxRetries(maxRetries int) ClientOptionFunc {
}
}
-// SetGzip enables or disables gzip compression (disabled by default).
-func SetGzip(enabled bool) ClientOptionFunc {
- return func(c *Client) error {
- c.gzipEnabled = enabled
- return nil
- }
-}
-
// SetDecoder sets the Decoder to use when decoding data from Elasticsearch.
// DefaultDecoder is used by default.
func SetDecoder(decoder Decoder) ClientOptionFunc {
@@ -1086,6 +1072,7 @@ func (c *Client) startupHealthcheck(timeout time.Duration) error {
c.mu.Unlock()
// If we don't get a connection after "timeout", we bail.
+ var lastErr error
start := time.Now()
for {
// Make a copy of the HTTP client provided via options to respect
@@ -1104,6 +1091,8 @@ func (c *Client) startupHealthcheck(timeout time.Duration) error {
res, err := cl.Do(req)
if err == nil && res != nil && res.StatusCode >= 200 && res.StatusCode < 300 {
return nil
+ } else if err != nil {
+ lastErr = err
}
}
time.Sleep(1 * time.Second)
@@ -1111,6 +1100,9 @@ func (c *Client) startupHealthcheck(timeout time.Duration) error {
break
}
}
+ if lastErr != nil {
+ return errors.Wrapf(ErrNoClient, "health check timeout: %v", lastErr)
+ }
return errors.Wrap(ErrNoClient, "health check timeout")
}
@@ -1167,19 +1159,26 @@ func (c *Client) mustActiveConn() error {
return errors.Wrap(ErrNoClient, "no active connection found")
}
-// PerformRequest does a HTTP request to Elasticsearch.
-// See PerformRequestWithContentType for details.
-func (c *Client) PerformRequest(ctx context.Context, method, path string, params url.Values, body interface{}, ignoreErrors ...int) (*Response, error) {
- return c.PerformRequestWithContentType(ctx, method, path, params, body, "application/json", ignoreErrors...)
+// -- PerformRequest --
+
+// PerformRequestOptions must be passed into PerformRequest.
+type PerformRequestOptions struct {
+ Method string
+ Path string
+ Params url.Values
+ Body interface{}
+ ContentType string
+ IgnoreErrors []int
+ Retrier Retrier
}
-// PerformRequestWithContentType executes a HTTP request with a specific content type.
+// PerformRequest does a HTTP request to Elasticsearch.
// It returns a response (which might be nil) and an error on failure.
//
// Optionally, a list of HTTP error codes to ignore can be passed.
// This is necessary for services that expect e.g. HTTP status 404 as a
// valid outcome (Exists, IndicesExists, IndicesTypeExists).
-func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path string, params url.Values, body interface{}, contentType string, ignoreErrors ...int) (*Response, error) {
+func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions) (*Response, error) {
start := time.Now().UTC()
c.mu.RLock()
@@ -1188,7 +1187,10 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
basicAuthUsername := c.basicAuthUsername
basicAuthPassword := c.basicAuthPassword
sendGetBodyAs := c.sendGetBodyAs
- gzipEnabled := c.gzipEnabled
+ retrier := c.retrier
+ if opt.Retrier != nil {
+ retrier = opt.Retrier
+ }
c.mu.RUnlock()
var err error
@@ -1199,14 +1201,14 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
var n int
// Change method if sendGetBodyAs is specified.
- if method == "GET" && body != nil && sendGetBodyAs != "GET" {
- method = sendGetBodyAs
+ if opt.Method == "GET" && opt.Body != nil && sendGetBodyAs != "GET" {
+ opt.Method = sendGetBodyAs
}
for {
- pathWithParams := path
- if len(params) > 0 {
- pathWithParams += "?" + params.Encode()
+ pathWithParams := opt.Path
+ if len(opt.Params) > 0 {
+ pathWithParams += "?" + opt.Params.Encode()
}
// Get a connection
@@ -1217,7 +1219,7 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
// Force a healtcheck as all connections seem to be dead.
c.healthcheck(timeout, false)
}
- wait, ok, rerr := c.retrier.Retry(ctx, n, nil, nil, err)
+ wait, ok, rerr := retrier.Retry(ctx, n, nil, nil, err)
if rerr != nil {
return nil, rerr
}
@@ -1233,24 +1235,24 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
return nil, err
}
- req, err = NewRequest(method, conn.URL()+pathWithParams)
+ req, err = NewRequest(opt.Method, conn.URL()+pathWithParams)
if err != nil {
- c.errorf("elastic: cannot create request for %s %s: %v", strings.ToUpper(method), conn.URL()+pathWithParams, err)
+ c.errorf("elastic: cannot create request for %s %s: %v", strings.ToUpper(opt.Method), conn.URL()+pathWithParams, err)
return nil, err
}
if basicAuth {
req.SetBasicAuth(basicAuthUsername, basicAuthPassword)
}
- if contentType != "" {
- req.Header.Set("Content-Type", contentType)
+ if opt.ContentType != "" {
+ req.Header.Set("Content-Type", opt.ContentType)
}
// Set body
- if body != nil {
- err = req.SetBody(body, gzipEnabled)
+ if opt.Body != nil {
+ err = req.SetBody(opt.Body)
if err != nil {
- c.errorf("elastic: couldn't set body %+v for request: %v", body, err)
+ c.errorf("elastic: couldn't set body %+v for request: %v", opt.Body, err)
return nil, err
}
}
@@ -1273,7 +1275,7 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
}
if err != nil {
n++
- wait, ok, rerr := c.retrier.Retry(ctx, n, (*http.Request)(req), res, err)
+ wait, ok, rerr := retrier.Retry(ctx, n, (*http.Request)(req), res, err)
if rerr != nil {
c.errorf("elastic: %s is dead", conn.URL())
conn.MarkAsDead()
@@ -1295,8 +1297,13 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
// Tracing
c.dumpResponse(res)
+ // Log deprecation warnings as errors
+ if s := res.Header.Get("Warning"); s != "" {
+ c.errorf(s)
+ }
+
// Check for errors
- if err := checkResponse((*http.Request)(req), res, ignoreErrors...); err != nil {
+ if err := checkResponse((*http.Request)(req), res, opt.IgnoreErrors...); err != nil {
// No retry if request succeeded
// We still try to return a response.
resp, _ = c.newResponse(res)
@@ -1316,7 +1323,7 @@ func (c *Client) PerformRequestWithContentType(ctx context.Context, method, path
duration := time.Now().UTC().Sub(start)
c.infof("%s %s [status:%d, request:%.3fs]",
- strings.ToUpper(method),
+ strings.ToUpper(opt.Method),
req.URL,
resp.StatusCode,
float64(int64(duration/time.Millisecond))/1000)
@@ -1378,7 +1385,7 @@ func (c *Client) BulkProcessor() *BulkProcessorService {
// Reindex copies data from a source index into a destination index.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-reindex.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html
// for details on the Reindex API.
func (c *Client) Reindex() *ReindexService {
return NewReindexService(c)
@@ -1405,11 +1412,6 @@ func (c *Client) Search(indices ...string) *SearchService {
return NewSearchService(c).Index(indices...)
}
-// Suggest returns a service to return suggestions.
-func (c *Client) Suggest(indices ...string) *SuggestService {
- return NewSuggestService(c).Index(indices...)
-}
-
// MultiSearch is the entry point for multi searches.
func (c *Client) MultiSearch() *MultiSearchService {
return NewMultiSearchService(c)
@@ -1430,9 +1432,9 @@ func (c *Client) Explain(index, typ, id string) *ExplainService {
// TODO Search Exists API
// TODO Validate API
-// FieldStats returns statistical information about fields in indices.
-func (c *Client) FieldStats(indices ...string) *FieldStatsService {
- return NewFieldStatsService(c).Index(indices...)
+// FieldCaps returns statistical information about fields in indices.
+func (c *Client) FieldCaps(indices ...string) *FieldCapsService {
+ return NewFieldCapsService(c).Index(indices...)
}
// Exists checks if a document exists.
@@ -1516,6 +1518,11 @@ func (c *Client) IndexPutSettings(indices ...string) *IndicesPutSettingsService
return NewIndicesPutSettingsService(c).Index(indices...)
}
+// IndexSegments retrieves low level segment information for all, one or more indices.
+func (c *Client) IndexSegments(indices ...string) *IndicesSegmentsService {
+ return NewIndicesSegmentsService(c).Index(indices...)
+}
+
// IndexAnalyze performs the analysis process on a text and returns the
// token breakdown of the text.
func (c *Client) IndexAnalyze() *IndicesAnalyzeService {
@@ -1549,24 +1556,6 @@ func (c *Client) Aliases() *AliasesService {
return NewAliasesService(c)
}
-// GetTemplate gets a search template.
-// Use IndexXXXTemplate funcs to manage index templates.
-func (c *Client) GetTemplate() *GetTemplateService {
- return NewGetTemplateService(c)
-}
-
-// PutTemplate creates or updates a search template.
-// Use IndexXXXTemplate funcs to manage index templates.
-func (c *Client) PutTemplate() *PutTemplateService {
- return NewPutTemplateService(c)
-}
-
-// DeleteTemplate deletes a search template.
-// Use IndexXXXTemplate funcs to manage index templates.
-func (c *Client) DeleteTemplate() *DeleteTemplateService {
- return NewDeleteTemplateService(c)
-}
-
// IndexGetTemplate gets an index template.
// Use XXXTemplate funcs to manage search templates.
func (c *Client) IndexGetTemplate(names ...string) *IndicesGetTemplateService {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client_test.go b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
index 6caf7b797..4d0440ee0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/client_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
@@ -279,6 +279,9 @@ func TestClientHealthcheckStartupTimeout(t *testing.T) {
if !IsConnErr(err) {
t.Fatal(err)
}
+ if !strings.Contains(err.Error(), "connection refused") {
+ t.Fatalf("expected error to contain %q, have %q", "connection refused", err.Error())
+ }
if duration < 5*time.Second {
t.Fatalf("expected a timeout in more than 5 seconds; got: %v", duration)
}
@@ -873,7 +876,10 @@ func TestPerformRequest(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -895,7 +901,10 @@ func TestPerformRequestWithSimpleClient(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -921,7 +930,10 @@ func TestPerformRequestWithLogger(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -960,7 +972,10 @@ func TestPerformRequestWithLoggerAndTracer(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -995,7 +1010,10 @@ func TestPerformRequestWithTracerOnError(t *testing.T) {
t.Fatal(err)
}
- client.PerformRequest(context.TODO(), "GET", "/no-such-index", nil, nil)
+ client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/no-such-index",
+ })
tgot := tw.String()
if tgot == "" {
@@ -1019,7 +1037,10 @@ func TestPerformRequestWithCustomLogger(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -1082,7 +1103,10 @@ func TestPerformRequestRetryOnHttpError(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1112,7 +1136,10 @@ func TestPerformRequestNoRetryOnValidButUnsuccessfulHttpStatus(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1141,7 +1168,11 @@ func TestPerformRequestWithSetBodyError(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, failingBody{})
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ Body: failingBody{},
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1178,7 +1209,10 @@ func TestPerformRequestWithCancel(t *testing.T) {
resc := make(chan result, 1)
go func() {
- res, err := client.PerformRequest(ctx, "GET", "/", nil, nil)
+ res, err := client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
resc <- result{res: res, err: err}
}()
select {
@@ -1213,7 +1247,10 @@ func TestPerformRequestWithTimeout(t *testing.T) {
resc := make(chan result, 1)
go func() {
- res, err := client.PerformRequest(ctx, "GET", "/", nil, nil)
+ res, err := client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
resc <- result{res: res, err: err}
}()
select {
@@ -1261,7 +1298,10 @@ func testPerformRequestWithCompression(t *testing.T, hc *http.Client) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/cluster-test/cluster-test.go b/vendor/gopkg.in/olivere/elastic.v5/cluster-test/cluster-test.go
index 249b35c04..96b0c5d9b 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/cluster-test/cluster-test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/cluster-test/cluster-test.go
@@ -18,7 +18,7 @@ import (
"sync/atomic"
"time"
- elastic "gopkg.in/olivere/elastic.v5"
+ elastic "github.com/olivere/elastic"
)
type Tweet struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/cluster_health.go b/vendor/gopkg.in/olivere/elastic.v5/cluster_health.go
index a3ee72cd1..f960cfe8e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/cluster_health.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/cluster_health.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// ClusterHealthService allows to get a very simple status on the health of the cluster.
@@ -131,7 +131,7 @@ func (s *ClusterHealthService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.level != "" {
params.Set("level", s.level)
@@ -179,7 +179,11 @@ func (s *ClusterHealthService) Do(ctx context.Context) (*ClusterHealthResponse,
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/cluster_state.go b/vendor/gopkg.in/olivere/elastic.v5/cluster_state.go
index d6e608211..54e9aa428 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/cluster_state.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/cluster_state.go
@@ -10,12 +10,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// ClusterStateService allows to get a comprehensive state information of the whole cluster.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-state.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/cluster-state.html
// for details.
type ClusterStateService struct {
client *Client
@@ -123,7 +123,7 @@ func (s *ClusterStateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
@@ -165,7 +165,11 @@ func (s *ClusterStateService) Do(ctx context.Context) (*ClusterStateResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -235,10 +239,10 @@ type clusterStateRoutingNode struct {
}
type indexTemplateMetaData struct {
- Template string `json:"template"` // e.g. "store-*"
- Order int `json:"order"`
- Settings map[string]interface{} `json:"settings"` // index settings
- Mappings map[string]interface{} `json:"mappings"` // type name -> mapping
+ IndexPatterns []string `json:"index_patterns"` // e.g. ["store-*"]
+ Order int `json:"order"`
+ Settings map[string]interface{} `json:"settings"` // index settings
+ Mappings map[string]interface{} `json:"mappings"` // type name -> mapping
}
type indexMetaData struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go b/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
index 8c5374d0f..4d05c2e97 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// ClusterStatsService is documented at
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-stats.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/cluster-stats.html.
type ClusterStatsService struct {
client *Client
pretty bool
@@ -78,7 +78,7 @@ func (s *ClusterStatsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.flatSettings != nil {
params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings))
@@ -108,7 +108,11 @@ func (s *ClusterStatsService) Do(ctx context.Context) (*ClusterStatsResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -175,10 +179,8 @@ type ClusterStatsIndicesDocs struct {
}
type ClusterStatsIndicesStore struct {
- Size string `json:"size"` // e.g. "5.3gb"
- SizeInBytes int64 `json:"size_in_bytes"`
- ThrottleTime string `json:"throttle_time"` // e.g. "0s"
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis"`
+ Size string `json:"size"` // e.g. "5.3gb"
+ SizeInBytes int64 `json:"size_in_bytes"`
}
type ClusterStatsIndicesFieldData struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/count.go b/vendor/gopkg.in/olivere/elastic.v5/count.go
index 89b69ce03..44416fab0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/count.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/count.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// CountService is a convenient service for determining the
@@ -207,7 +207,7 @@ func (s *CountService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
@@ -286,7 +286,12 @@ func (s *CountService) Do(ctx context.Context) (int64, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return 0, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/count_test.go b/vendor/gopkg.in/olivere/elastic.v5/count_test.go
index dd2b7556f..a0ee52112 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/count_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/count_test.go
@@ -58,17 +58,17 @@ func TestCount(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -88,7 +88,7 @@ func TestCount(t *testing.T) {
}
// Count documents
- count, err = client.Count(testIndexName).Type("tweet").Do(context.TODO())
+ count, err = client.Count(testIndexName).Type("doc").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -117,7 +117,7 @@ func TestCount(t *testing.T) {
// Count with query and type
query = NewTermQuery("user", "olivere")
- count, err = client.Count(testIndexName).Type("tweet").Query(query).Do(context.TODO())
+ count, err = client.Count(testIndexName).Type("doc").Query(query).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/decoder_test.go b/vendor/gopkg.in/olivere/elastic.v5/decoder_test.go
index 15263fb8d..2c3dde8ca 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/decoder_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/decoder_test.go
@@ -34,7 +34,7 @@ func TestDecoder(t *testing.T) {
// Add a document
indexResult, err := client.Index().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id("1").
BodyJson(&tweet).
Do(context.TODO())
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete.go b/vendor/gopkg.in/olivere/elastic.v5/delete.go
index b1b06c2c3..1e20de11f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/delete.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/delete.go
@@ -7,17 +7,16 @@ package elastic
import (
"context"
"fmt"
- "net/url"
-
"net/http"
+ "net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// DeleteService allows to delete a typed JSON document from a specified
// index based on its id.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-delete.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-delete.html
// for details.
type DeleteService struct {
client *Client
@@ -126,7 +125,7 @@ func (s *DeleteService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.refresh != "" {
params.Set("refresh", s.refresh)
@@ -186,7 +185,12 @@ func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil, http.StatusNotFound)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ IgnoreErrors: []int{http.StatusNotFound},
+ })
if err != nil {
return nil, err
}
@@ -209,12 +213,14 @@ func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) {
// DeleteResponse is the outcome of running DeleteService.Do.
type DeleteResponse struct {
- Index string `json:"_index"`
- Type string `json:"_type"`
- Id string `json:"_id"`
- Version int64 `json:"_version"`
- Shards *shardsInfo `json:"_shards"`
+ Index string `json:"_index,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Version int64 `json:"_version,omitempty"`
Result string `json:"result,omitempty"`
+ Shards *shardsInfo `json:"_shards,omitempty"`
+ SeqNo int64 `json:"_seq_no,omitempty"`
+ PrimaryTerm int64 `json:"_primary_term,omitempty"`
+ Status int `json:"status,omitempty"`
ForcedRefresh bool `json:"forced_refresh,omitempty"`
- Found bool `json:"found"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete_by_query.go b/vendor/gopkg.in/olivere/elastic.v5/delete_by_query.go
index a890bd84f..694d81c2a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/delete_by_query.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/delete_by_query.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// DeleteByQueryService deletes documents that match a query.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-delete-by-query.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-delete-by-query.html.
type DeleteByQueryService struct {
client *Client
index []string
@@ -598,7 +598,12 @@ func (s *DeleteByQueryService) Do(ctx context.Context) (*BulkIndexByScrollRespon
}
// Get response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete_by_query_test.go b/vendor/gopkg.in/olivere/elastic.v5/delete_by_query_test.go
index 9208ebce3..40e45b871 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/delete_by_query_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/delete_by_query_test.go
@@ -87,17 +87,17 @@ func TestDeleteByQuery(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -120,7 +120,7 @@ func TestDeleteByQuery(t *testing.T) {
q := NewTermQuery("user", "sandrae")
res, err := client.DeleteByQuery().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Query(q).
Pretty(true).
Do(context.TODO())
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete_template.go b/vendor/gopkg.in/olivere/elastic.v5/delete_template.go
deleted file mode 100644
index 4775baf84..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/delete_template.go
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "fmt"
- "net/url"
-
- "gopkg.in/olivere/elastic.v5/uritemplates"
-)
-
-// DeleteTemplateService deletes a search template. More information can
-// be found at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-template.html.
-type DeleteTemplateService struct {
- client *Client
- pretty bool
- id string
- version *int
- versionType string
-}
-
-// NewDeleteTemplateService creates a new DeleteTemplateService.
-func NewDeleteTemplateService(client *Client) *DeleteTemplateService {
- return &DeleteTemplateService{
- client: client,
- }
-}
-
-// Id is the template ID.
-func (s *DeleteTemplateService) Id(id string) *DeleteTemplateService {
- s.id = id
- return s
-}
-
-// Version an explicit version number for concurrency control.
-func (s *DeleteTemplateService) Version(version int) *DeleteTemplateService {
- s.version = &version
- return s
-}
-
-// VersionType specifies a version type.
-func (s *DeleteTemplateService) VersionType(versionType string) *DeleteTemplateService {
- s.versionType = versionType
- return s
-}
-
-// buildURL builds the URL for the operation.
-func (s *DeleteTemplateService) buildURL() (string, url.Values, error) {
- // Build URL
- path, err := uritemplates.Expand("/_search/template/{id}", map[string]string{
- "id": s.id,
- })
- if err != nil {
- return "", url.Values{}, err
- }
-
- // Add query string parameters
- params := url.Values{}
- if s.version != nil {
- params.Set("version", fmt.Sprintf("%d", *s.version))
- }
- if s.versionType != "" {
- params.Set("version_type", s.versionType)
- }
-
- return path, params, nil
-}
-
-// Validate checks if the operation is valid.
-func (s *DeleteTemplateService) Validate() error {
- var invalid []string
- if s.id == "" {
- invalid = append(invalid, "Id")
- }
- if len(invalid) > 0 {
- return fmt.Errorf("missing required fields: %v", invalid)
- }
- return nil
-}
-
-// Do executes the operation.
-func (s *DeleteTemplateService) Do(ctx context.Context) (*AcknowledgedResponse, error) {
- // Check pre-conditions
- if err := s.Validate(); err != nil {
- return nil, err
- }
-
- // Get URL for request
- path, params, err := s.buildURL()
- if err != nil {
- return nil, err
- }
-
- // Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil)
- if err != nil {
- return nil, err
- }
-
- // Return operation response
- ret := new(AcknowledgedResponse)
- if err := s.client.decoder.Decode(res.Body, ret); err != nil {
- return nil, err
- }
- return ret, nil
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete_template_test.go b/vendor/gopkg.in/olivere/elastic.v5/delete_template_test.go
deleted file mode 100644
index 9a6324198..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/delete_template_test.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "testing"
-)
-
-func TestDeleteTemplateValidate(t *testing.T) {
- client := setupTestClient(t)
-
- // No template id -> fail with error
- res, err := NewDeleteTemplateService(client).Do(context.TODO())
- if err == nil {
- t.Fatalf("expected Delete to fail without index name")
- }
- if res != nil {
- t.Fatalf("expected result to be == nil; got: %v", res)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete_test.go b/vendor/gopkg.in/olivere/elastic.v5/delete_test.go
index 1daf5499d..571fcf589 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/delete_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/delete_test.go
@@ -17,17 +17,17 @@ func TestDelete(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -47,12 +47,12 @@ func TestDelete(t *testing.T) {
}
// Delete document 1
- res, err := client.Delete().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ res, err := client.Delete().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- if res.Found != true {
- t.Errorf("expected Found = true; got %v", res.Found)
+ if want, have := "deleted", res.Result; want != have {
+ t.Errorf("expected Result = %q; got %q", want, have)
}
_, err = client.Flush().Index(testIndexName).Do(context.TODO())
if err != nil {
@@ -67,7 +67,7 @@ func TestDelete(t *testing.T) {
}
// Delete non existent document 99
- res, err = client.Delete().Index(testIndexName).Type("tweet").Id("99").Refresh("true").Do(context.TODO())
+ res, err = client.Delete().Index(testIndexName).Type("doc").Id("99").Refresh("true").Do(context.TODO())
if err == nil {
t.Fatal("expected error")
}
@@ -80,20 +80,17 @@ func TestDelete(t *testing.T) {
if res == nil {
t.Fatal("expected response")
}
- if res.Found {
- t.Errorf("expected Found = false; got %v", res.Found)
- }
if have, want := res.Id, "99"; have != want {
t.Errorf("expected _id = %q, got %q", have, want)
}
if have, want := res.Index, testIndexName; have != want {
t.Errorf("expected _index = %q, got %q", have, want)
}
- if have, want := res.Type, "tweet"; have != want {
+ if have, want := res.Type, "doc"; have != want {
t.Errorf("expected _type = %q, got %q", have, want)
}
if have, want := res.Result, "not_found"; have != want {
- t.Errorf("expected result = %q, got %q", have, want)
+ t.Errorf("expected Result = %q, got %q", have, want)
}
count, err = client.Count(testIndexName).Do(context.TODO())
@@ -109,7 +106,7 @@ func TestDeleteValidate(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t)
// No index name -> fail with error
- res, err := NewDeleteService(client).Type("tweet").Id("1").Do(context.TODO())
+ res, err := NewDeleteService(client).Type("doc").Id("1").Do(context.TODO())
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
@@ -127,7 +124,7 @@ func TestDeleteValidate(t *testing.T) {
}
// No id -> fail with error
- res, err = NewDeleteService(client).Index(testIndexName).Type("tweet").Do(context.TODO())
+ res, err = NewDeleteService(client).Index(testIndexName).Type("doc").Do(context.TODO())
if err == nil {
t.Fatalf("expected Delete to fail without id")
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/docker-compose.yml b/vendor/gopkg.in/olivere/elastic.v5/docker-compose.yml
deleted file mode 100644
index 002eac7fa..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/docker-compose.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-version: '3'
-
-services:
- elasticsearch:
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3
- # container_name: elasticsearch
- hostname: elasticsearch
- environment:
- - bootstrap.memory_lock=true
- - xpack.security.enabled=false
- - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- ulimits:
- nproc: 65536
- nofile:
- soft: 65536
- hard: 65536
- memlock:
- soft: -1
- hard: -1
- volumes:
- - ./etc:/usr/share/elasticsearch/config
- ports:
- - 9200:9200
diff --git a/vendor/gopkg.in/olivere/elastic.v5/example_test.go b/vendor/gopkg.in/olivere/elastic.v5/example_test.go
index f8441d7bf..62dc15d89 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/example_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/example_test.go
@@ -13,7 +13,7 @@ import (
"reflect"
"time"
- elastic "gopkg.in/olivere/elastic.v5"
+ elastic "github.com/olivere/elastic"
)
type Tweet struct {
@@ -71,12 +71,7 @@ func Example() {
"number_of_replicas":0
},
"mappings":{
- "_default_": {
- "_all": {
- "enabled": true
- }
- },
- "tweet":{
+ "doc":{
"properties":{
"user":{
"type":"keyword"
@@ -117,7 +112,7 @@ func Example() {
tweet1 := Tweet{User: "olivere", Message: "Take Five", Retweets: 0}
put1, err := client.Index().
Index("twitter").
- Type("tweet").
+ Type("doc").
Id("1").
BodyJson(tweet1).
Do(context.Background())
@@ -131,7 +126,7 @@ func Example() {
tweet2 := `{"user" : "olivere", "message" : "It's a Raggy Waltz"}`
put2, err := client.Index().
Index("twitter").
- Type("tweet").
+ Type("doc").
Id("2").
BodyString(tweet2).
Do(context.Background())
@@ -144,7 +139,7 @@ func Example() {
// Get tweet with specified ID
get1, err := client.Get().
Index("twitter").
- Type("tweet").
+ Type("doc").
Id("1").
Do(context.Background())
if err != nil {
@@ -217,7 +212,7 @@ func Example() {
// Update a tweet by the update API of Elasticsearch.
// We just increment the number of retweets.
script := elastic.NewScript("ctx._source.retweets += params.num").Param("num", 1)
- update, err := client.Update().Index("twitter").Type("tweet").Id("1").
+ update, err := client.Update().Index("twitter").Type("doc").Id("1").
Script(script).
Upsert(map[string]interface{}{"retweets": 0}).
Do(context.Background())
@@ -485,58 +480,6 @@ func ExampleSearchResult() {
}
}
-func ExamplePutTemplateService() {
- client, err := elastic.NewClient()
- if err != nil {
- panic(err)
- }
-
- // Create search template
- tmpl := `{"template":{"query":{"match":{"title":"{{query_string}}"}}}}`
-
- // Create template
- resp, err := client.PutTemplate().
- Id("my-search-template"). // Name of the template
- BodyString(tmpl). // Search template itself
- Do(context.Background()) // Execute
- if err != nil {
- panic(err)
- }
- if resp.Acknowledged {
- fmt.Println("search template creation acknowledged")
- }
-}
-
-func ExampleGetTemplateService() {
- client, err := elastic.NewClient()
- if err != nil {
- panic(err)
- }
-
- // Get template stored under "my-search-template"
- resp, err := client.GetTemplate().Id("my-search-template").Do(context.Background())
- if err != nil {
- panic(err)
- }
- fmt.Printf("search template is: %q\n", resp.Template)
-}
-
-func ExampleDeleteTemplateService() {
- client, err := elastic.NewClient()
- if err != nil {
- panic(err)
- }
-
- // Delete template
- resp, err := client.DeleteTemplate().Id("my-search-template").Do(context.Background())
- if err != nil {
- panic(err)
- }
- if resp != nil && resp.Acknowledged {
- fmt.Println("template deleted")
- }
-}
-
func ExampleClusterHealthService() {
client, err := elastic.NewClient()
if err != nil {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/exists.go b/vendor/gopkg.in/olivere/elastic.v5/exists.go
index 7cae2bde8..ae5a88fa7 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/exists.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/exists.go
@@ -10,12 +10,12 @@ import (
"net/http"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// ExistsService checks for the existence of a document using HEAD.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-get.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-get.html
// for details.
type ExistsService struct {
client *Client
@@ -107,7 +107,7 @@ func (s *ExistsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.realtime != nil {
params.Set("realtime", fmt.Sprintf("%v", *s.realtime))
@@ -159,7 +159,12 @@ func (s *ExistsService) Do(ctx context.Context) (bool, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "HEAD", path, params, nil, 404)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "HEAD",
+ Path: path,
+ Params: params,
+ IgnoreErrors: []int{404},
+ })
if err != nil {
return false, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/exists_test.go b/vendor/gopkg.in/olivere/elastic.v5/exists_test.go
index af6a04e80..9b834223d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/exists_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/exists_test.go
@@ -12,7 +12,7 @@ import (
func TestExists(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
- exists, err := client.Exists().Index(testIndexName).Type("comment").Id("1").Parent("tweet").Do(context.TODO())
+ exists, err := client.Exists().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -25,7 +25,7 @@ func TestExistsValidate(t *testing.T) {
client := setupTestClient(t)
// No index -> fail with error
- res, err := NewExistsService(client).Type("tweet").Id("1").Do(context.TODO())
+ res, err := NewExistsService(client).Type("doc").Id("1").Do(context.TODO())
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
@@ -43,7 +43,7 @@ func TestExistsValidate(t *testing.T) {
}
// No id -> fail with error
- res, err = NewExistsService(client).Index(testIndexName).Type("tweet").Do(context.TODO())
+ res, err = NewExistsService(client).Index(testIndexName).Type("doc").Do(context.TODO())
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/explain.go b/vendor/gopkg.in/olivere/elastic.v5/explain.go
index bdfa00f1d..2b975ad5d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/explain.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/explain.go
@@ -10,12 +10,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// ExplainService computes a score explanation for a query and
// a specific document.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-explain.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-explain.html.
type ExplainService struct {
client *Client
pretty bool
@@ -208,7 +208,7 @@ func (s *ExplainService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.xSource) > 0 {
params.Set("_source", strings.Join(s.xSource, ","))
@@ -298,7 +298,12 @@ func (s *ExplainService) Do(ctx context.Context) (*ExplainResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/explain_test.go b/vendor/gopkg.in/olivere/elastic.v5/explain_test.go
index e71bf6675..22cb9668a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/explain_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/explain_test.go
@@ -17,7 +17,7 @@ func TestExplain(t *testing.T) {
// Add a document
indexResult, err := client.Index().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id("1").
BodyJson(&tweet1).
Refresh("true").
@@ -31,7 +31,7 @@ func TestExplain(t *testing.T) {
// Explain
query := NewTermQuery("user", "olivere")
- expl, err := client.Explain(testIndexName, "tweet", "1").Query(query).Do(context.TODO())
+ expl, err := client.Explain(testIndexName, "doc", "1").Query(query).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/fetch_source_context.go b/vendor/gopkg.in/olivere/elastic.v5/fetch_source_context.go
index 53e7fcd90..874c4c1da 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/fetch_source_context.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/fetch_source_context.go
@@ -14,7 +14,7 @@ import (
// with various endpoints, e.g. when searching for documents, retrieving
// individual documents, or even updating documents.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-request-source-filtering.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-source-filtering.html
// for details.
type FetchSourceContext struct {
fetchSource bool
diff --git a/vendor/gopkg.in/olivere/elastic.v5/field_caps.go b/vendor/gopkg.in/olivere/elastic.v5/field_caps.go
new file mode 100644
index 000000000..393cd3ce8
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/field_caps.go
@@ -0,0 +1,202 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "github.com/olivere/elastic/uritemplates"
+)
+
+// FieldCapsService allows retrieving the capabilities of fields among multiple indices.
+//
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-field-caps.html
+// for details
+type FieldCapsService struct {
+ client *Client
+ pretty bool
+ index []string
+ allowNoIndices *bool
+ expandWildcards string
+ fields []string
+ ignoreUnavailable *bool
+ bodyJson interface{}
+ bodyString string
+}
+
+// NewFieldCapsService creates a new FieldCapsService
+func NewFieldCapsService(client *Client) *FieldCapsService {
+ return &FieldCapsService{
+ client: client,
+ }
+}
+
+// Index is a list of index names; use `_all` or empty string to perform
+// the operation on all indices.
+func (s *FieldCapsService) Index(index ...string) *FieldCapsService {
+ s.index = append(s.index, index...)
+ return s
+}
+
+// AllowNoIndices indicates whether to ignore if a wildcard indices expression
+// resolves into no concrete indices.
+// (This includes `_all` string or when no indices have been specified).
+func (s *FieldCapsService) AllowNoIndices(allowNoIndices bool) *FieldCapsService {
+ s.allowNoIndices = &allowNoIndices
+ return s
+}
+
+// ExpandWildcards indicates whether to expand wildcard expression to
+// concrete indices that are open, closed or both.
+func (s *FieldCapsService) ExpandWildcards(expandWildcards string) *FieldCapsService {
+ s.expandWildcards = expandWildcards
+ return s
+}
+
+// Fields is a list of fields for to get field capabilities.
+func (s *FieldCapsService) Fields(fields ...string) *FieldCapsService {
+ s.fields = append(s.fields, fields...)
+ return s
+}
+
+// IgnoreUnavailable is documented as: Whether specified concrete indices should be ignored when unavailable (missing or closed).
+func (s *FieldCapsService) IgnoreUnavailable(ignoreUnavailable bool) *FieldCapsService {
+ s.ignoreUnavailable = &ignoreUnavailable
+ return s
+}
+
+// Pretty indicates that the JSON response be indented and human readable.
+func (s *FieldCapsService) Pretty(pretty bool) *FieldCapsService {
+ s.pretty = pretty
+ return s
+}
+
+// BodyJson is documented as: Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds.
+func (s *FieldCapsService) BodyJson(body interface{}) *FieldCapsService {
+ s.bodyJson = body
+ return s
+}
+
+// BodyString is documented as: Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds.
+func (s *FieldCapsService) BodyString(body string) *FieldCapsService {
+ s.bodyString = body
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *FieldCapsService) buildURL() (string, url.Values, error) {
+ // Build URL
+ var err error
+ var path string
+ if len(s.index) > 0 {
+ path, err = uritemplates.Expand("/{index}/_field_caps", map[string]string{
+ "index": strings.Join(s.index, ","),
+ })
+ } else {
+ path = "/_field_caps"
+ }
+ if err != nil {
+ return "", url.Values{}, err
+ }
+
+ // Add query string parameters
+ params := url.Values{}
+ if s.pretty {
+ params.Set("pretty", "true")
+ }
+ if s.allowNoIndices != nil {
+ params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
+ }
+ if s.expandWildcards != "" {
+ params.Set("expand_wildcards", s.expandWildcards)
+ }
+ if len(s.fields) > 0 {
+ params.Set("fields", strings.Join(s.fields, ","))
+ }
+ if s.ignoreUnavailable != nil {
+ params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *FieldCapsService) Validate() error {
+ return nil
+}
+
+// Do executes the operation.
+func (s *FieldCapsService) Do(ctx context.Context) (*FieldCapsResponse, error) {
+ // Check pre-conditions
+ if err := s.Validate(); err != nil {
+ return nil, err
+ }
+
+ // Get URL for request
+ path, params, err := s.buildURL()
+ if err != nil {
+ return nil, err
+ }
+
+ // Setup HTTP request body
+ var body interface{}
+ if s.bodyJson != nil {
+ body = s.bodyJson
+ } else {
+ body = s.bodyString
+ }
+
+ // Get HTTP response
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ IgnoreErrors: []int{http.StatusNotFound},
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ // TODO(oe): Is 404 really a valid response here?
+ if res.StatusCode == http.StatusNotFound {
+ return &FieldCapsResponse{}, nil
+ }
+
+ // Return operation response
+ ret := new(FieldCapsResponse)
+ if err := s.client.decoder.Decode(res.Body, ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// -- Request --
+
+// FieldCapsRequest can be used to set up the body to be used in the
+// Field Capabilities API.
+type FieldCapsRequest struct {
+ Fields []string `json:"fields"`
+}
+
+// -- Response --
+
+// FieldCapsResponse contains field capabilities.
+type FieldCapsResponse struct {
+ Fields map[string]FieldCaps `json:"fields,omitempty"`
+}
+
+// FieldCaps contains capabilities of an individual field.
+type FieldCaps struct {
+ Type string `json:"type"`
+ Searchable bool `json:"searchable"`
+ Aggregatable bool `json:"aggregatable"`
+ Indices []string `json:"indices,omitempty"`
+ NonSearchableIndices []string `json:"non_searchable_indices,omitempty"`
+ NonAggregatableIndices []string `json:"non_aggregatable_indices,omitempty"`
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/field_caps_test.go b/vendor/gopkg.in/olivere/elastic.v5/field_caps_test.go
new file mode 100644
index 000000000..e299fd516
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/field_caps_test.go
@@ -0,0 +1,146 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "encoding/json"
+ "net/url"
+ "reflect"
+ "sort"
+ "testing"
+)
+
+func TestFieldCapsURLs(t *testing.T) {
+ tests := []struct {
+ Service *FieldCapsService
+ ExpectedPath string
+ ExpectedParams url.Values
+ }{
+ {
+ Service: &FieldCapsService{},
+ ExpectedPath: "/_field_caps",
+ ExpectedParams: url.Values{},
+ },
+ {
+ Service: &FieldCapsService{
+ index: []string{"index1", "index2"},
+ },
+ ExpectedPath: "/index1%2Cindex2/_field_caps",
+ ExpectedParams: url.Values{},
+ },
+ {
+ Service: &FieldCapsService{
+ index: []string{"index_*"},
+ pretty: true,
+ },
+ ExpectedPath: "/index_%2A/_field_caps",
+ ExpectedParams: url.Values{"pretty": []string{"true"}},
+ },
+ }
+
+ for _, test := range tests {
+ gotPath, gotParams, err := test.Service.buildURL()
+ if err != nil {
+ t.Fatalf("expected no error; got: %v", err)
+ }
+ if gotPath != test.ExpectedPath {
+ t.Errorf("expected URL path = %q; got: %q", test.ExpectedPath, gotPath)
+ }
+ if gotParams.Encode() != test.ExpectedParams.Encode() {
+ t.Errorf("expected URL params = %v; got: %v", test.ExpectedParams, gotParams)
+ }
+ }
+}
+
+func TestFieldCapsRequestSerialize(t *testing.T) {
+ req := &FieldCapsRequest{
+ Fields: []string{"creation_date", "answer_count"},
+ }
+ data, err := json.Marshal(req)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"fields":["creation_date","answer_count"]}`
+ if got != expected {
+ t.Fatalf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestFieldCapsRequestDeserialize(t *testing.T) {
+ body := `{
+ "fields" : ["creation_date", "answer_count"]
+ }`
+
+ var request FieldCapsRequest
+ if err := json.Unmarshal([]byte(body), &request); err != nil {
+ t.Fatalf("unexpected error during unmarshalling: %v", err)
+ }
+
+ sort.Sort(lexicographically{request.Fields})
+
+ expectedFields := []string{"answer_count", "creation_date"}
+ if !reflect.DeepEqual(request.Fields, expectedFields) {
+ t.Fatalf("expected fields to be %v, got %v", expectedFields, request.Fields)
+ }
+}
+
+func TestFieldCapsResponseUnmarshalling(t *testing.T) {
+ clusterStats := `{
+ "_shards": {
+ "total": 1,
+ "successful": 1,
+ "failed": 0
+ },
+ "fields": {
+ "creation_date": {
+ "type": "date",
+ "searchable": true,
+ "aggregatable": true,
+ "indices": ["index1", "index2"],
+ "non_searchable_indices": null,
+ "non_aggregatable_indices": null
+ },
+ "answer": {
+ "type": "keyword",
+ "searchable": true,
+ "aggregatable": true
+ }
+ }
+ }`
+
+ var resp FieldCapsResponse
+ if err := json.Unmarshal([]byte(clusterStats), &resp); err != nil {
+ t.Errorf("unexpected error during unmarshalling: %v", err)
+ }
+
+ caps, ok := resp.Fields["creation_date"]
+ if !ok {
+ t.Errorf("expected creation_date to be in the fields map, didn't find it")
+ }
+ if want, have := true, caps.Searchable; want != have {
+ t.Errorf("expected creation_date searchable to be %v, got %v", want, have)
+ }
+ if want, have := true, caps.Aggregatable; want != have {
+ t.Errorf("expected creation_date aggregatable to be %v, got %v", want, have)
+ }
+ if want, have := []string{"index1", "index2"}, caps.Indices; !reflect.DeepEqual(want, have) {
+ t.Errorf("expected creation_date indices to be %v, got %v", want, have)
+ }
+}
+
+func TestFieldCaps123(t *testing.T) {
+ client := setupTestClientAndCreateIndexAndAddDocs(t)
+ // client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", 0)))
+
+ res, err := client.FieldCaps("_all").Fields("user", "message", "retweets", "created").Pretty(true).Do(context.TODO())
+ if err != nil {
+ t.Fatalf("expected no error; got: %v", err)
+ }
+ if res == nil {
+ t.Fatalf("expected response; got: %v", res)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/field_stats.go b/vendor/gopkg.in/olivere/elastic.v5/field_stats.go
deleted file mode 100644
index c2104c5cb..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/field_stats.go
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "fmt"
- "net/http"
- "net/url"
- "strings"
-
- "gopkg.in/olivere/elastic.v5/uritemplates"
-)
-
-const (
- FieldStatsClusterLevel = "cluster"
- FieldStatsIndicesLevel = "indices"
-)
-
-// FieldStatsService allows finding statistical properties of a field without executing a search,
-// but looking up measurements that are natively available in the Lucene index.
-//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-field-stats.html
-// for details
-type FieldStatsService struct {
- client *Client
- pretty bool
- level string
- index []string
- allowNoIndices *bool
- expandWildcards string
- fields []string
- ignoreUnavailable *bool
- bodyJson interface{}
- bodyString string
-}
-
-// NewFieldStatsService creates a new FieldStatsService
-func NewFieldStatsService(client *Client) *FieldStatsService {
- return &FieldStatsService{
- client: client,
- index: make([]string, 0),
- fields: make([]string, 0),
- }
-}
-
-// Index is a list of index names; use `_all` or empty string to perform
-// the operation on all indices.
-func (s *FieldStatsService) Index(index ...string) *FieldStatsService {
- s.index = append(s.index, index...)
- return s
-}
-
-// AllowNoIndices indicates whether to ignore if a wildcard indices expression
-// resolves into no concrete indices.
-// (This includes `_all` string or when no indices have been specified).
-func (s *FieldStatsService) AllowNoIndices(allowNoIndices bool) *FieldStatsService {
- s.allowNoIndices = &allowNoIndices
- return s
-}
-
-// ExpandWildcards indicates whether to expand wildcard expression to
-// concrete indices that are open, closed or both.
-func (s *FieldStatsService) ExpandWildcards(expandWildcards string) *FieldStatsService {
- s.expandWildcards = expandWildcards
- return s
-}
-
-// Fields is a list of fields for to get field statistics
-// for (min value, max value, and more).
-func (s *FieldStatsService) Fields(fields ...string) *FieldStatsService {
- s.fields = append(s.fields, fields...)
- return s
-}
-
-// IgnoreUnavailable is documented as: Whether specified concrete indices should be ignored when unavailable (missing or closed).
-func (s *FieldStatsService) IgnoreUnavailable(ignoreUnavailable bool) *FieldStatsService {
- s.ignoreUnavailable = &ignoreUnavailable
- return s
-}
-
-// Level sets if stats should be returned on a per index level or on a cluster wide level;
-// should be one of 'cluster' or 'indices'; defaults to former
-func (s *FieldStatsService) Level(level string) *FieldStatsService {
- s.level = level
- return s
-}
-
-// ClusterLevel is a helper that sets Level to "cluster".
-func (s *FieldStatsService) ClusterLevel() *FieldStatsService {
- s.level = FieldStatsClusterLevel
- return s
-}
-
-// IndicesLevel is a helper that sets Level to "indices".
-func (s *FieldStatsService) IndicesLevel() *FieldStatsService {
- s.level = FieldStatsIndicesLevel
- return s
-}
-
-// Pretty indicates that the JSON response be indented and human readable.
-func (s *FieldStatsService) Pretty(pretty bool) *FieldStatsService {
- s.pretty = pretty
- return s
-}
-
-// BodyJson is documented as: Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds.
-func (s *FieldStatsService) BodyJson(body interface{}) *FieldStatsService {
- s.bodyJson = body
- return s
-}
-
-// BodyString is documented as: Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds.
-func (s *FieldStatsService) BodyString(body string) *FieldStatsService {
- s.bodyString = body
- return s
-}
-
-// buildURL builds the URL for the operation.
-func (s *FieldStatsService) buildURL() (string, url.Values, error) {
- // Build URL
- var err error
- var path string
- if len(s.index) > 0 {
- path, err = uritemplates.Expand("/{index}/_field_stats", map[string]string{
- "index": strings.Join(s.index, ","),
- })
- } else {
- path = "/_field_stats"
- }
- if err != nil {
- return "", url.Values{}, err
- }
-
- // Add query string parameters
- params := url.Values{}
- if s.allowNoIndices != nil {
- params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
- }
- if s.expandWildcards != "" {
- params.Set("expand_wildcards", s.expandWildcards)
- }
- if len(s.fields) > 0 {
- params.Set("fields", strings.Join(s.fields, ","))
- }
- if s.ignoreUnavailable != nil {
- params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
- }
- if s.level != "" {
- params.Set("level", s.level)
- }
- return path, params, nil
-}
-
-// Validate checks if the operation is valid.
-func (s *FieldStatsService) Validate() error {
- var invalid []string
- if s.level != "" && (s.level != FieldStatsIndicesLevel && s.level != FieldStatsClusterLevel) {
- invalid = append(invalid, "Level")
- }
- if len(invalid) != 0 {
- return fmt.Errorf("missing or invalid required fields: %v", invalid)
- }
- return nil
-}
-
-// Do executes the operation.
-func (s *FieldStatsService) Do(ctx context.Context) (*FieldStatsResponse, error) {
- // Check pre-conditions
- if err := s.Validate(); err != nil {
- return nil, err
- }
-
- // Get URL for request
- path, params, err := s.buildURL()
- if err != nil {
- return nil, err
- }
-
- // Setup HTTP request body
- var body interface{}
- if s.bodyJson != nil {
- body = s.bodyJson
- } else {
- body = s.bodyString
- }
-
- // Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body, http.StatusNotFound)
- if err != nil {
- return nil, err
- }
-
- // TODO(oe): Is 404 really a valid response here?
- if res.StatusCode == http.StatusNotFound {
- return &FieldStatsResponse{make(map[string]IndexFieldStats)}, nil
- }
-
- // Return operation response
- ret := new(FieldStatsResponse)
- if err := s.client.decoder.Decode(res.Body, ret); err != nil {
- return nil, err
- }
- return ret, nil
-}
-
-// -- Request --
-
-// FieldStatsRequest can be used to set up the body to be used in the
-// Field Stats API.
-type FieldStatsRequest struct {
- Fields []string `json:"fields"`
- IndexConstraints map[string]*FieldStatsConstraints `json:"index_constraints,omitempty"`
-}
-
-// FieldStatsConstraints is a constraint on a field.
-type FieldStatsConstraints struct {
- Min *FieldStatsComparison `json:"min_value,omitempty"`
- Max *FieldStatsComparison `json:"max_value,omitempty"`
-}
-
-// FieldStatsComparison contain all comparison operations that can be used
-// in FieldStatsConstraints.
-type FieldStatsComparison struct {
- Lte interface{} `json:"lte,omitempty"`
- Lt interface{} `json:"lt,omitempty"`
- Gte interface{} `json:"gte,omitempty"`
- Gt interface{} `json:"gt,omitempty"`
-}
-
-// -- Response --
-
-// FieldStatsResponse is the response body content
-type FieldStatsResponse struct {
- Indices map[string]IndexFieldStats `json:"indices,omitempty"`
-}
-
-// IndexFieldStats contains field stats for an index
-type IndexFieldStats struct {
- Fields map[string]FieldStats `json:"fields,omitempty"`
-}
-
-// FieldStats contains stats of an individual field
-type FieldStats struct {
- Type string `json:"type"`
- MaxDoc int64 `json:"max_doc"`
- DocCount int64 `json:"doc_count"`
- Density int64 `json:"density"`
- SumDocFrequeny int64 `json:"sum_doc_freq"`
- SumTotalTermFrequency int64 `json:"sum_total_term_freq"`
- Searchable bool `json:"searchable"`
- Aggregatable bool `json:"aggregatable"`
- MinValue interface{} `json:"min_value"`
- MinValueAsString string `json:"min_value_as_string"`
- MaxValue interface{} `json:"max_value"`
- MaxValueAsString string `json:"max_value_as_string"`
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/field_stats_test.go b/vendor/gopkg.in/olivere/elastic.v5/field_stats_test.go
deleted file mode 100644
index 48e973840..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/field_stats_test.go
+++ /dev/null
@@ -1,282 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "encoding/json"
- "net/url"
- "reflect"
- "sort"
- "testing"
-)
-
-func TestFieldStatsURLs(t *testing.T) {
- tests := []struct {
- Service *FieldStatsService
- ExpectedPath string
- ExpectedParams url.Values
- }{
- {
- Service: &FieldStatsService{},
- ExpectedPath: "/_field_stats",
- ExpectedParams: url.Values{},
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsClusterLevel,
- },
- ExpectedPath: "/_field_stats",
- ExpectedParams: url.Values{"level": []string{FieldStatsClusterLevel}},
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsIndicesLevel,
- },
- ExpectedPath: "/_field_stats",
- ExpectedParams: url.Values{"level": []string{FieldStatsIndicesLevel}},
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsClusterLevel,
- index: []string{"index1"},
- },
- ExpectedPath: "/index1/_field_stats",
- ExpectedParams: url.Values{"level": []string{FieldStatsClusterLevel}},
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsIndicesLevel,
- index: []string{"index1", "index2"},
- },
- ExpectedPath: "/index1%2Cindex2/_field_stats",
- ExpectedParams: url.Values{"level": []string{FieldStatsIndicesLevel}},
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsIndicesLevel,
- index: []string{"index_*"},
- },
- ExpectedPath: "/index_%2A/_field_stats",
- ExpectedParams: url.Values{"level": []string{FieldStatsIndicesLevel}},
- },
- }
-
- for _, test := range tests {
- gotPath, gotParams, err := test.Service.buildURL()
- if err != nil {
- t.Fatalf("expected no error; got: %v", err)
- }
- if gotPath != test.ExpectedPath {
- t.Errorf("expected URL path = %q; got: %q", test.ExpectedPath, gotPath)
- }
- if gotParams.Encode() != test.ExpectedParams.Encode() {
- t.Errorf("expected URL params = %v; got: %v", test.ExpectedParams, gotParams)
- }
- }
-}
-
-func TestFieldStatsValidate(t *testing.T) {
- tests := []struct {
- Service *FieldStatsService
- Valid bool
- }{
- {
- Service: &FieldStatsService{},
- Valid: true,
- },
- {
- Service: &FieldStatsService{
- fields: []string{"field"},
- },
- Valid: true,
- },
- {
- Service: &FieldStatsService{
- bodyJson: &FieldStatsRequest{
- Fields: []string{"field"},
- },
- },
- Valid: true,
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsClusterLevel,
- bodyJson: &FieldStatsRequest{
- Fields: []string{"field"},
- },
- },
- Valid: true,
- },
- {
- Service: &FieldStatsService{
- level: FieldStatsIndicesLevel,
- bodyJson: &FieldStatsRequest{
- Fields: []string{"field"},
- },
- },
- Valid: true,
- },
- {
- Service: &FieldStatsService{
- level: "random",
- },
- Valid: false,
- },
- }
-
- for _, test := range tests {
- err := test.Service.Validate()
- isValid := err == nil
- if isValid != test.Valid {
- t.Errorf("expected validity to be %v, got %v", test.Valid, isValid)
- }
- }
-}
-
-func TestFieldStatsRequestSerialize(t *testing.T) {
- req := &FieldStatsRequest{
- Fields: []string{"creation_date", "answer_count"},
- IndexConstraints: map[string]*FieldStatsConstraints{
- "creation_date": &FieldStatsConstraints{
- Min: &FieldStatsComparison{Gte: "2014-01-01T00:00:00.000Z"},
- Max: &FieldStatsComparison{Lt: "2015-01-01T10:00:00.000Z"},
- },
- },
- }
- data, err := json.Marshal(req)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"fields":["creation_date","answer_count"],"index_constraints":{"creation_date":{"min_value":{"gte":"2014-01-01T00:00:00.000Z"},"max_value":{"lt":"2015-01-01T10:00:00.000Z"}}}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
-
-func TestFieldStatsRequestDeserialize(t *testing.T) {
- body := `{
- "fields" : ["creation_date", "answer_count"],
- "index_constraints" : {
- "creation_date" : {
- "min_value" : {
- "gte" : "2014-01-01T00:00:00.000Z"
- },
- "max_value" : {
- "lt" : "2015-01-01T10:00:00.000Z"
- }
- }
- }
- }`
-
- var request FieldStatsRequest
- if err := json.Unmarshal([]byte(body), &request); err != nil {
- t.Errorf("unexpected error during unmarshalling: %v", err)
- }
-
- sort.Sort(lexicographically{request.Fields})
-
- expectedFields := []string{"answer_count", "creation_date"}
- if !reflect.DeepEqual(request.Fields, expectedFields) {
- t.Errorf("expected fields to be %v, got %v", expectedFields, request.Fields)
- }
-
- constraints, ok := request.IndexConstraints["creation_date"]
- if !ok {
- t.Errorf("expected field creation_date, didn't find it!")
- }
- if constraints.Min.Lt != nil {
- t.Errorf("expected min value less than constraint to be empty, got %v", constraints.Min.Lt)
- }
- if constraints.Min.Gte != "2014-01-01T00:00:00.000Z" {
- t.Errorf("expected min value >= %v, found %v", "2014-01-01T00:00:00.000Z", constraints.Min.Gte)
- }
- if constraints.Max.Lt != "2015-01-01T10:00:00.000Z" {
- t.Errorf("expected max value < %v, found %v", "2015-01-01T10:00:00.000Z", constraints.Max.Lt)
- }
-}
-
-func TestFieldStatsResponseUnmarshalling(t *testing.T) {
- clusterStats := `{
- "_shards": {
- "total": 1,
- "successful": 1,
- "failed": 0
- },
- "indices": {
- "_all": {
- "fields": {
- "creation_date": {
- "type": "date",
- "max_doc": 1326564,
- "doc_count": 564633,
- "density": 42,
- "sum_doc_freq": 2258532,
- "sum_total_term_freq": -1,
- "searchable": true,
- "aggregatable": true,
- "min_value":1483016404000,
- "min_value_as_string": "2016-12-29T13:00:04.000Z",
- "max_value":1484152326000,
- "max_value_as_string": "2017-01-11T16:32:06.000Z"
- },
- "answer_count": {
- "max_doc": 1326564,
- "doc_count": 139885,
- "density": 10,
- "sum_doc_freq": 559540,
- "sum_total_term_freq": -1,
- "searchable": true,
- "aggregatable": true,
- "min_value":1483016404000,
- "min_value_as_string": "2016-12-29T13:00:04.000Z",
- "max_value":1484152326000,
- "max_value_as_string": "2017-01-11T16:32:06.000Z"
- }
- }
- }
- }
- }`
-
- var response FieldStatsResponse
- if err := json.Unmarshal([]byte(clusterStats), &response); err != nil {
- t.Errorf("unexpected error during unmarshalling: %v", err)
- }
-
- stats, ok := response.Indices["_all"]
- if !ok {
- t.Errorf("expected _all to be in the indices map, didn't find it")
- }
-
- fieldStats, ok := stats.Fields["creation_date"]
- if !ok {
- t.Errorf("expected creation_date to be in the fields map, didn't find it")
- }
- if want, have := true, fieldStats.Searchable; want != have {
- t.Errorf("expected creation_date searchable to be %v, got %v", want, have)
- }
- if want, have := true, fieldStats.Aggregatable; want != have {
- t.Errorf("expected creation_date aggregatable to be %v, got %v", want, have)
- }
- if want, have := "2016-12-29T13:00:04.000Z", fieldStats.MinValueAsString; want != have {
- t.Errorf("expected creation_date min value string to be %q, got %q", want, have)
- }
-}
-
-type lexicographically struct {
- strings []string
-}
-
-func (l lexicographically) Len() int {
- return len(l.strings)
-}
-
-func (l lexicographically) Less(i, j int) bool {
- return l.strings[i] < l.strings[j]
-}
-
-func (l lexicographically) Swap(i, j int) {
- l.strings[i], l.strings[j] = l.strings[j], l.strings[i]
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/get.go b/vendor/gopkg.in/olivere/elastic.v5/get.go
index ef569e174..efcc748bb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/get.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/get.go
@@ -11,13 +11,13 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// GetService allows to get a typed JSON document from the index based
// on its id.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-get.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-get.html
// for details.
type GetService struct {
client *Client
@@ -172,7 +172,7 @@ func (s *GetService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.routing != "" {
params.Set("routing", s.routing)
@@ -223,7 +223,11 @@ func (s *GetService) Do(ctx context.Context) (*GetResult, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/get_template.go b/vendor/gopkg.in/olivere/elastic.v5/get_template.go
deleted file mode 100644
index 93279a3a7..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/get_template.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "fmt"
- "net/url"
-
- "gopkg.in/olivere/elastic.v5/uritemplates"
-)
-
-// GetTemplateService reads a search template.
-// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-template.html.
-type GetTemplateService struct {
- client *Client
- pretty bool
- id string
- version interface{}
- versionType string
-}
-
-// NewGetTemplateService creates a new GetTemplateService.
-func NewGetTemplateService(client *Client) *GetTemplateService {
- return &GetTemplateService{
- client: client,
- }
-}
-
-// Id is the template ID.
-func (s *GetTemplateService) Id(id string) *GetTemplateService {
- s.id = id
- return s
-}
-
-// Version is an explicit version number for concurrency control.
-func (s *GetTemplateService) Version(version interface{}) *GetTemplateService {
- s.version = version
- return s
-}
-
-// VersionType is a specific version type.
-func (s *GetTemplateService) VersionType(versionType string) *GetTemplateService {
- s.versionType = versionType
- return s
-}
-
-// buildURL builds the URL for the operation.
-func (s *GetTemplateService) buildURL() (string, url.Values, error) {
- // Build URL
- path, err := uritemplates.Expand("/_search/template/{id}", map[string]string{
- "id": s.id,
- })
- if err != nil {
- return "", url.Values{}, err
- }
-
- // Add query string parameters
- params := url.Values{}
- if s.version != nil {
- params.Set("version", fmt.Sprintf("%v", s.version))
- }
- if s.versionType != "" {
- params.Set("version_type", s.versionType)
- }
-
- return path, params, nil
-}
-
-// Validate checks if the operation is valid.
-func (s *GetTemplateService) Validate() error {
- var invalid []string
- if s.id == "" {
- invalid = append(invalid, "Id")
- }
- if len(invalid) > 0 {
- return fmt.Errorf("missing required fields: %v", invalid)
- }
- return nil
-}
-
-// Do executes the operation and returns the template.
-func (s *GetTemplateService) Do(ctx context.Context) (*GetTemplateResponse, error) {
- // Check pre-conditions
- if err := s.Validate(); err != nil {
- return nil, err
- }
-
- // Get URL for request
- path, params, err := s.buildURL()
- if err != nil {
- return nil, err
- }
-
- // Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
- if err != nil {
- return nil, err
- }
-
- // Return result
- ret := new(GetTemplateResponse)
- if err := s.client.decoder.Decode(res.Body, ret); err != nil {
- return nil, err
- }
- return ret, nil
-}
-
-type GetTemplateResponse struct {
- Template string `json:"template"`
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/get_template_test.go b/vendor/gopkg.in/olivere/elastic.v5/get_template_test.go
deleted file mode 100644
index 16d063fcc..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/get_template_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "testing"
-)
-
-func TestGetPutDeleteTemplate(t *testing.T) {
- client := setupTestClientAndCreateIndex(t)
-
- // This is a search template, not an index template!
- tmpl := `{
- "template": {
- "query" : { "term" : { "{{my_field}}" : "{{my_value}}" } },
- "size" : "{{my_size}}"
- },
- "params":{
- "my_field" : "user",
- "my_value" : "olivere",
- "my_size" : 5
- }
-}`
- putres, err := client.PutTemplate().Id("elastic-template").BodyString(tmpl).Do(context.TODO())
- if err != nil {
- t.Fatalf("expected no error; got: %v", err)
- }
- if putres == nil {
- t.Fatalf("expected response; got: %v", putres)
- }
- if !putres.Acknowledged {
- t.Fatalf("expected template creation to be acknowledged; got: %v", putres.Acknowledged)
- }
-
- // Always delete template
- defer client.DeleteTemplate().Id("elastic-template").Do(context.TODO())
-
- // Get template
- getres, err := client.GetTemplate().Id("elastic-template").Do(context.TODO())
- if err != nil {
- t.Fatalf("expected no error; got: %v", err)
- }
- if getres == nil {
- t.Fatalf("expected response; got: %v", getres)
- }
- if getres.Template == "" {
- t.Errorf("expected template %q; got: %q", tmpl, getres.Template)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/get_test.go b/vendor/gopkg.in/olivere/elastic.v5/get_test.go
index 8ad5a43d8..f9504bdbf 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/get_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/get_test.go
@@ -14,13 +14,13 @@ func TestGet(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Get document 1
- res, err := client.Get().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ res, err := client.Get().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -32,7 +32,7 @@ func TestGet(t *testing.T) {
}
// Get non existent document 99
- res, err = client.Get().Index(testIndexName).Type("tweet").Id("99").Do(context.TODO())
+ res, err = client.Get().Index(testIndexName).Type("doc").Id("99").Do(context.TODO())
if err == nil {
t.Fatalf("expected error; got: %v", err)
}
@@ -48,13 +48,13 @@ func TestGetWithSourceFiltering(t *testing.T) {
client := setupTestClientAndCreateIndex(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Get document 1, without source
- res, err := client.Get().Index(testIndexName).Type("tweet").Id("1").FetchSource(false).Do(context.TODO())
+ res, err := client.Get().Index(testIndexName).Type("doc").Id("1").FetchSource(false).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -67,7 +67,7 @@ func TestGetWithSourceFiltering(t *testing.T) {
// Get document 1, exclude Message field
fsc := NewFetchSourceContext(true).Exclude("message")
- res, err = client.Get().Index(testIndexName).Type("tweet").Id("1").FetchSourceContext(fsc).Do(context.TODO())
+ res, err = client.Get().Index(testIndexName).Type("doc").Id("1").FetchSourceContext(fsc).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -94,13 +94,13 @@ func TestGetWithFields(t *testing.T) {
client := setupTestClientAndCreateIndex(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Get document 1, specifying fields
- res, err := client.Get().Index(testIndexName).Type("tweet").Id("1").StoredFields("message").Do(context.TODO())
+ res, err := client.Get().Index(testIndexName).Type("doc").Id("1").StoredFields("message").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -151,16 +151,16 @@ func TestGetValidate(t *testing.T) {
if _, err := client.Get().Index(testIndexName).Do(context.TODO()); err == nil {
t.Fatal("expected Get to fail")
}
- if _, err := client.Get().Type("tweet").Do(context.TODO()); err == nil {
+ if _, err := client.Get().Type("doc").Do(context.TODO()); err == nil {
t.Fatal("expected Get to fail")
}
if _, err := client.Get().Id("1").Do(context.TODO()); err == nil {
t.Fatal("expected Get to fail")
}
- if _, err := client.Get().Index(testIndexName).Type("tweet").Do(context.TODO()); err == nil {
+ if _, err := client.Get().Index(testIndexName).Type("doc").Do(context.TODO()); err == nil {
t.Fatal("expected Get to fail")
}
- if _, err := client.Get().Type("tweet").Id("1").Do(context.TODO()); err == nil {
+ if _, err := client.Get().Type("doc").Id("1").Do(context.TODO()); err == nil {
t.Fatal("expected Get to fail")
}
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/highlight.go b/vendor/gopkg.in/olivere/elastic.v5/highlight.go
index d28f03c3a..6d8d2ba63 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/highlight.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/highlight.go
@@ -6,7 +6,7 @@ package elastic
// Highlight allows highlighting search results on one or more fields.
// For details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-highlighting.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-highlighting.html
type Highlight struct {
fields []*HighlighterField
tagsSchema *string
@@ -20,6 +20,8 @@ type Highlight struct {
requireFieldMatch *bool
boundaryMaxScan *int
boundaryChars *string
+ boundaryScannerType *string
+ boundaryScannerLocale *string
highlighterType *string
fragmenter *string
highlightQuery Query
@@ -103,6 +105,16 @@ func (hl *Highlight) BoundaryChars(boundaryChars string) *Highlight {
return hl
}
+func (hl *Highlight) BoundaryScannerType(boundaryScannerType string) *Highlight {
+ hl.boundaryScannerType = &boundaryScannerType
+ return hl
+}
+
+func (hl *Highlight) BoundaryScannerLocale(boundaryScannerLocale string) *Highlight {
+ hl.boundaryScannerLocale = &boundaryScannerLocale
+ return hl
+}
+
func (hl *Highlight) HighlighterType(highlighterType string) *Highlight {
hl.highlighterType = &highlighterType
return hl
@@ -178,6 +190,12 @@ func (hl *Highlight) Source() (interface{}, error) {
if hl.boundaryChars != nil {
source["boundary_chars"] = *hl.boundaryChars
}
+ if hl.boundaryScannerType != nil {
+ source["boundary_scanner"] = *hl.boundaryScannerType
+ }
+ if hl.boundaryScannerLocale != nil {
+ source["boundary_scanner_locale"] = *hl.boundaryScannerLocale
+ }
if hl.highlighterType != nil {
source["type"] = *hl.highlighterType
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/highlight_test.go b/vendor/gopkg.in/olivere/elastic.v5/highlight_test.go
index 9687cfb79..c7b972c44 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/highlight_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/highlight_test.go
@@ -117,8 +117,10 @@ func TestHighlighterWithExplicitFieldOrder(t *testing.T) {
}
}
-func TestHighlightWithBoundaryChars(t *testing.T) {
- builder := NewHighlight().BoundaryChars(" \t\r")
+func TestHighlightWithBoundarySettings(t *testing.T) {
+ builder := NewHighlight().
+ BoundaryChars(" \t\r").
+ BoundaryScannerType("word")
src, err := builder.Source()
if err != nil {
t.Fatal(err)
@@ -128,7 +130,7 @@ func TestHighlightWithBoundaryChars(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"boundary_chars":" \t\r"}`
+ expected := `{"boundary_chars":" \t\r","boundary_scanner":"word"}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -142,17 +144,17 @@ func TestHighlightWithTermQuery(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun to do."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/index.go b/vendor/gopkg.in/olivere/elastic.v5/index.go
index a4e4ae0d1..4a4c3278e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/index.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/index.go
@@ -9,13 +9,13 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndexService adds or updates a typed JSON document in a specified index,
// making it searchable.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-index_.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html
// for details.
type IndexService struct {
client *Client
@@ -172,7 +172,7 @@ func (s *IndexService) buildURL() (string, string, url.Values, error) {
})
} else {
// Automatic ID generation
- // See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-index_.html#index-creation
+ // See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html#index-creation
method = "POST"
path, err = uritemplates.Expand("/{index}/{type}/", map[string]string{
"index": s.index,
@@ -186,7 +186,7 @@ func (s *IndexService) buildURL() (string, string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.waitForActiveShards != "" {
params.Set("wait_for_active_shards", s.waitForActiveShards)
@@ -264,7 +264,12 @@ func (s *IndexService) Do(ctx context.Context) (*IndexResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, method, path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: method,
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -279,10 +284,14 @@ func (s *IndexService) Do(ctx context.Context) (*IndexResponse, error) {
// IndexResponse is the result of indexing a document in Elasticsearch.
type IndexResponse struct {
- // TODO _shards { total, failed, successful }
- Index string `json:"_index"`
- Type string `json:"_type"`
- Id string `json:"_id"`
- Version int `json:"_version"`
- Created bool `json:"created"`
+ Index string `json:"_index,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Version int64 `json:"_version,omitempty"`
+ Result string `json:"result,omitempty"`
+ Shards *shardsInfo `json:"_shards,omitempty"`
+ SeqNo int64 `json:"_seq_no,omitempty"`
+ PrimaryTerm int64 `json:"_primary_term,omitempty"`
+ Status int `json:"status,omitempty"`
+ ForcedRefresh bool `json:"forced_refresh,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/index_test.go b/vendor/gopkg.in/olivere/elastic.v5/index_test.go
index 5e997f3b8..1a0c38576 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/index_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/index_test.go
@@ -18,7 +18,7 @@ func TestIndexLifecycle(t *testing.T) {
// Add a document
indexResult, err := client.Index().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id("1").
BodyJson(&tweet1).
Do(context.TODO())
@@ -30,7 +30,7 @@ func TestIndexLifecycle(t *testing.T) {
}
// Exists
- exists, err := client.Exists().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ exists, err := client.Exists().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -41,7 +41,7 @@ func TestIndexLifecycle(t *testing.T) {
// Get document
getResult, err := client.Get().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id("1").
Do(context.TODO())
if err != nil {
@@ -50,8 +50,8 @@ func TestIndexLifecycle(t *testing.T) {
if getResult.Index != testIndexName {
t.Errorf("expected GetResult.Index %q; got %q", testIndexName, getResult.Index)
}
- if getResult.Type != "tweet" {
- t.Errorf("expected GetResult.Type %q; got %q", "tweet", getResult.Type)
+ if getResult.Type != "doc" {
+ t.Errorf("expected GetResult.Type %q; got %q", "doc", getResult.Type)
}
if getResult.Id != "1" {
t.Errorf("expected GetResult.Id %q; got %q", "1", getResult.Id)
@@ -74,7 +74,7 @@ func TestIndexLifecycle(t *testing.T) {
}
// Delete document again
- deleteResult, err := client.Delete().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ deleteResult, err := client.Delete().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -83,7 +83,7 @@ func TestIndexLifecycle(t *testing.T) {
}
// Exists
- exists, err = client.Exists().Index(testIndexName).Type("tweet").Id("1").Do(context.TODO())
+ exists, err = client.Exists().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -100,7 +100,7 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
// Add a document
indexResult, err := client.Index().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
BodyJson(&tweet1).
Do(context.TODO())
if err != nil {
@@ -115,7 +115,7 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
id := indexResult.Id
// Exists
- exists, err := client.Exists().Index(testIndexName).Type("tweet").Id(id).Do(context.TODO())
+ exists, err := client.Exists().Index(testIndexName).Type("doc").Id(id).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -126,7 +126,7 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
// Get document
getResult, err := client.Get().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id(id).
Do(context.TODO())
if err != nil {
@@ -135,8 +135,8 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
if getResult.Index != testIndexName {
t.Errorf("expected GetResult.Index %q; got %q", testIndexName, getResult.Index)
}
- if getResult.Type != "tweet" {
- t.Errorf("expected GetResult.Type %q; got %q", "tweet", getResult.Type)
+ if getResult.Type != "doc" {
+ t.Errorf("expected GetResult.Type %q; got %q", "doc", getResult.Type)
}
if getResult.Id != id {
t.Errorf("expected GetResult.Id %q; got %q", id, getResult.Id)
@@ -159,7 +159,7 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
}
// Delete document again
- deleteResult, err := client.Delete().Index(testIndexName).Type("tweet").Id(id).Do(context.TODO())
+ deleteResult, err := client.Delete().Index(testIndexName).Type("doc").Id(id).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -168,7 +168,7 @@ func TestIndexLifecycleWithAutomaticIDGeneration(t *testing.T) {
}
// Exists
- exists, err = client.Exists().Index(testIndexName).Type("tweet").Id(id).Do(context.TODO())
+ exists, err = client.Exists().Index(testIndexName).Type("doc").Id(id).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -183,7 +183,7 @@ func TestIndexValidate(t *testing.T) {
tweet := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
// No index name -> fail with error
- res, err := NewIndexService(client).Type("tweet").Id("1").BodyJson(&tweet).Do(context.TODO())
+ res, err := NewIndexService(client).Type("doc").Id("1").BodyJson(&tweet).Do(context.TODO())
if err == nil {
t.Fatalf("expected Index to fail without index name")
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_analyze.go b/vendor/gopkg.in/olivere/elastic.v5/indices_analyze.go
index b9000f128..fb3a91234 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_analyze.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_analyze.go
@@ -9,13 +9,13 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesAnalyzeService performs the analysis process on a text and returns
// the tokens breakdown of the text.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-analyze.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-analyze.html
// for detail.
type IndicesAnalyzeService struct {
client *Client
@@ -152,7 +152,7 @@ func (s *IndicesAnalyzeService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.format != "" {
params.Set("format", s.format)
@@ -185,11 +185,16 @@ func (s *IndicesAnalyzeService) Do(ctx context.Context) (*IndicesAnalyzeResponse
} else {
// Request parameters are deprecated in 5.1.1, and we must use a JSON
// structure in the body to pass the parameters.
- // See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-analyze.html
+ // See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-analyze.html
body = s.request
}
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_close.go b/vendor/gopkg.in/olivere/elastic.v5/indices_close.go
index 9388bc973..00ecdf966 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_close.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_close.go
@@ -9,12 +9,12 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesCloseService closes an index.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-open-close.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-open-close.html
// for details.
type IndicesCloseService struct {
client *Client
@@ -134,7 +134,11 @@ func (s *IndicesCloseService) Do(ctx context.Context) (*IndicesCloseResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -149,5 +153,7 @@ func (s *IndicesCloseService) Do(ctx context.Context) (*IndicesCloseResponse, er
// IndicesCloseResponse is the response of IndicesCloseService.Do.
type IndicesCloseResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_create.go b/vendor/gopkg.in/olivere/elastic.v5/indices_create.go
index dfd17ac09..8d8e0c25e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_create.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_create.go
@@ -9,12 +9,12 @@ import (
"errors"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesCreateService creates a new index.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-create-index.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-create-index.html
// for details.
type IndicesCreateService struct {
client *Client
@@ -91,7 +91,7 @@ func (b *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er
params := make(url.Values)
if b.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if b.masterTimeout != "" {
params.Set("master_timeout", b.masterTimeout)
@@ -109,7 +109,12 @@ func (b *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er
}
// Get response
- res, err := b.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := b.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -125,6 +130,7 @@ func (b *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er
// IndicesCreateResult is the outcome of creating a new index.
type IndicesCreateResult struct {
- Acknowledged bool `json:"acknowledged"`
- ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_delete.go b/vendor/gopkg.in/olivere/elastic.v5/indices_delete.go
index 997185237..2afeca978 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_delete.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_delete.go
@@ -10,12 +10,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesDeleteService allows to delete existing indices.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-delete-index.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-delete-index.html
// for details.
type IndicesDeleteService struct {
client *Client
@@ -71,7 +71,7 @@ func (s *IndicesDeleteService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
@@ -108,7 +108,11 @@ func (s *IndicesDeleteService) Do(ctx context.Context) (*IndicesDeleteResponse,
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_delete_template.go b/vendor/gopkg.in/olivere/elastic.v5/indices_delete_template.go
index d1b88d4bb..0ea34cf89 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_delete_template.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_delete_template.go
@@ -9,11 +9,11 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesDeleteTemplateService deletes index templates.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-templates.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-templates.html.
type IndicesDeleteTemplateService struct {
client *Client
pretty bool
@@ -66,7 +66,7 @@ func (s *IndicesDeleteTemplateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
@@ -103,7 +103,11 @@ func (s *IndicesDeleteTemplateService) Do(ctx context.Context) (*IndicesDeleteTe
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -118,5 +122,7 @@ func (s *IndicesDeleteTemplateService) Do(ctx context.Context) (*IndicesDeleteTe
// IndicesDeleteTemplateResponse is the response of IndicesDeleteTemplateService.Do.
type IndicesDeleteTemplateResponse struct {
- Acknowledged bool `json:"acknowledged,omitempty"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_exists.go b/vendor/gopkg.in/olivere/elastic.v5/indices_exists.go
index 928006e09..aa9391039 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_exists.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_exists.go
@@ -11,12 +11,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesExistsService checks if an index or indices exist or not.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-exists.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-exists.html
// for details.
type IndicesExistsService struct {
client *Client
@@ -90,7 +90,7 @@ func (s *IndicesExistsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.local != nil {
params.Set("local", fmt.Sprintf("%v", *s.local))
@@ -133,7 +133,12 @@ func (s *IndicesExistsService) Do(ctx context.Context) (bool, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "HEAD", path, params, nil, 404)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "HEAD",
+ Path: path,
+ Params: params,
+ IgnoreErrors: []int{404},
+ })
if err != nil {
return false, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template.go b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template.go
index 873d8c00c..40b06e895 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template.go
@@ -10,7 +10,7 @@ import (
"net/http"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesExistsTemplateService checks if a given template exists.
@@ -62,7 +62,7 @@ func (s *IndicesExistsTemplateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.local != nil {
params.Set("local", fmt.Sprintf("%v", *s.local))
@@ -96,7 +96,12 @@ func (s *IndicesExistsTemplateService) Do(ctx context.Context) (bool, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "HEAD", path, params, nil, 404)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "HEAD",
+ Path: path,
+ Params: params,
+ IgnoreErrors: []int{404},
+ })
if err != nil {
return false, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template_test.go
index cddf69f21..a97442971 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_template_test.go
@@ -13,13 +13,13 @@ func TestIndexExistsTemplate(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
tmpl := `{
- "template":"elastic-test*",
+ "index_patterns":["elastic-test*"],
"settings":{
"number_of_shards":1,
"number_of_replicas":0
},
"mappings":{
- "tweet":{
+ "doc":{
"properties":{
"tags":{
"type":"keyword"
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type.go b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type.go
index 95eb8f1d3..a4d1ff610 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type.go
@@ -11,12 +11,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesExistsTypeService checks if one or more types exist in one or more indices.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-types-exists.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-types-exists.html
// for details.
type IndicesExistsTypeService struct {
client *Client
@@ -97,7 +97,7 @@ func (s *IndicesExistsTypeService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
@@ -143,7 +143,12 @@ func (s *IndicesExistsTypeService) Do(ctx context.Context) (bool, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "HEAD", path, params, nil, 404)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "HEAD",
+ Path: path,
+ Params: params,
+ IgnoreErrors: []int{404},
+ })
if err != nil {
return false, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type_test.go
index 2af3c2c5d..3795bd042 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_exists_type_test.go
@@ -94,12 +94,12 @@ func TestIndicesExistsType(t *testing.T) {
}
// Check if type exists
- exists, err := client.TypeExists().Index(testIndexName).Type("tweet").Do(context.TODO())
+ exists, err := client.TypeExists().Index(testIndexName).Type("doc").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if !exists {
- t.Fatalf("type %s should exist in index %s, but doesn't\n", "tweet", testIndexName)
+ t.Fatalf("type %s should exist in index %s, but doesn't\n", "doc", testIndexName)
}
// Delete index
@@ -112,12 +112,12 @@ func TestIndicesExistsType(t *testing.T) {
}
// Check if type exists
- exists, err = client.TypeExists().Index(testIndexName).Type("tweet").Do(context.TODO())
+ exists, err = client.TypeExists().Index(testIndexName).Type("doc").Do(context.TODO())
if err != nil {
t.Fatal(err)
}
if exists {
- t.Fatalf("type %s should not exist in index %s, but it does\n", "tweet", testIndexName)
+ t.Fatalf("type %s should not exist in index %s, but it does\n", "doc", testIndexName)
}
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_flush.go b/vendor/gopkg.in/olivere/elastic.v5/indices_flush.go
index 602700af6..113e53803 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_flush.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_flush.go
@@ -10,14 +10,14 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// Flush allows to flush one or more indices. The flush process of an index
// basically frees memory from the index by flushing data to the index
// storage and clearing the internal transaction log.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-flush.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-flush.html
// for details.
type IndicesFlushService struct {
client *Client
@@ -110,7 +110,7 @@ func (s *IndicesFlushService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.force != nil {
params.Set("force", fmt.Sprintf("%v", *s.force))
@@ -149,7 +149,11 @@ func (s *IndicesFlushService) Do(ctx context.Context) (*IndicesFlushResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_forcemerge.go b/vendor/gopkg.in/olivere/elastic.v5/indices_forcemerge.go
index 709be1bc4..0e999cf19 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_forcemerge.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_forcemerge.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesForcemergeService allows to force merging of one or more indices.
@@ -125,7 +125,7 @@ func (s *IndicesForcemergeService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
@@ -170,7 +170,11 @@ func (s *IndicesForcemergeService) Do(ctx context.Context) (*IndicesForcemergeRe
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get.go
index 3b80c246d..cb4e449d5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get.go
@@ -10,12 +10,12 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesGetService retrieves information about one or more indices.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-get-index.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-get-index.html
// for more details.
type IndicesGetService struct {
client *Client
@@ -131,7 +131,7 @@ func (s *IndicesGetService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.expandWildcards != "" {
params.Set("expand_wildcards", s.expandWildcards)
@@ -180,7 +180,11 @@ func (s *IndicesGetService) Do(ctx context.Context) (map[string]*IndicesGetRespo
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases.go
index 530d7bdcd..68b186358 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// AliasesService returns the aliases associated with one or more indices.
@@ -47,11 +47,11 @@ func (s *AliasesService) buildURL() (string, url.Values, error) {
var path string
if len(s.index) > 0 {
- path, err = uritemplates.Expand("/{index}/_aliases", map[string]string{
+ path, err = uritemplates.Expand("/{index}/_alias", map[string]string{
"index": strings.Join(s.index, ","),
})
} else {
- path = "/_aliases"
+ path = "/_alias"
}
if err != nil {
return "", url.Values{}, err
@@ -72,7 +72,11 @@ func (s *AliasesService) Do(ctx context.Context) (*AliasesResult, error) {
}
// Get response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases_test.go
index 75abac835..2c8da9b7f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_aliases_test.go
@@ -18,15 +18,15 @@ func TestAliasesBuildURL(t *testing.T) {
}{
{
[]string{},
- "/_aliases",
+ "/_alias",
},
{
[]string{"index1"},
- "/index1/_aliases",
+ "/index1/_alias",
},
{
[]string{"index1", "index2"},
- "/index1%2Cindex2/_aliases",
+ "/index1%2Cindex2/_alias",
},
}
@@ -45,6 +45,7 @@ func TestAliasesBuildURL(t *testing.T) {
func TestAliases(t *testing.T) {
var err error
+ //client := setupTestClientAndCreateIndex(t, SetTraceLog(log.New(os.Stdout, "", 0)))
client := setupTestClientAndCreateIndex(t)
// Some tweets
@@ -53,16 +54,16 @@ func TestAliases(t *testing.T) {
tweet3 := tweet{User: "olivere", Message: "Another unrelated topic."}
// Add tweets to first index
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Add tweets to second index
- _, err = client.Index().Index(testIndexName2).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName2).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -80,7 +81,7 @@ func TestAliases(t *testing.T) {
// Alias should not yet exist
aliasesResult1, err := client.Aliases().
Index(testIndexName, testIndexName2).
- //Pretty(true).
+ Pretty(true).
Do(context.TODO())
if err != nil {
t.Fatal(err)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_field_mapping.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_field_mapping.go
index 3cb43d54b..e3b7eac07 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_field_mapping.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_field_mapping.go
@@ -10,13 +10,13 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesGetFieldMappingService retrieves the mapping definitions for the fields in an index
// or index/type.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-get-field-mapping.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-get-field-mapping.html
// for details.
type IndicesGetFieldMappingService struct {
client *Client
@@ -131,7 +131,7 @@ func (s *IndicesGetFieldMappingService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
@@ -170,7 +170,11 @@ func (s *IndicesGetFieldMappingService) Do(ctx context.Context) (map[string]inte
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_mapping.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_mapping.go
index 3b2258915..7f9c9cb22 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_mapping.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_mapping.go
@@ -10,13 +10,13 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesGetMappingService retrieves the mapping definitions for an index or
// index/type.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-get-mapping.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-get-mapping.html
// for details.
type IndicesGetMappingService struct {
client *Client
@@ -119,7 +119,7 @@ func (s *IndicesGetMappingService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
@@ -156,7 +156,11 @@ func (s *IndicesGetMappingService) Do(ctx context.Context) (map[string]interface
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_settings.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_settings.go
index 0e8f28d70..06fce0dfa 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_settings.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_settings.go
@@ -10,13 +10,13 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesGetSettingsService allows to retrieve settings of one
// or more indices.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-get-settings.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-get-settings.html
// for more details.
type IndicesGetSettingsService struct {
client *Client
@@ -125,7 +125,7 @@ func (s *IndicesGetSettingsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
@@ -164,7 +164,11 @@ func (s *IndicesGetSettingsService) Do(ctx context.Context) (map[string]*Indices
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_get_template.go b/vendor/gopkg.in/olivere/elastic.v5/indices_get_template.go
index 15590dc06..ad3a091a0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_get_template.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_get_template.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesGetTemplateService returns an index template.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-templates.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-templates.html.
type IndicesGetTemplateService struct {
client *Client
pretty bool
@@ -75,7 +75,7 @@ func (s *IndicesGetTemplateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.flatSettings != nil {
params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings))
@@ -105,7 +105,11 @@ func (s *IndicesGetTemplateService) Do(ctx context.Context) (map[string]*Indices
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_open.go b/vendor/gopkg.in/olivere/elastic.v5/indices_open.go
index 38277c385..1b58c5721 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_open.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_open.go
@@ -9,12 +9,12 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesOpenService opens an index.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-open-close.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-open-close.html
// for details.
type IndicesOpenService struct {
client *Client
@@ -91,7 +91,7 @@ func (s *IndicesOpenService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
@@ -138,7 +138,11 @@ func (s *IndicesOpenService) Do(ctx context.Context) (*IndicesOpenResponse, erro
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -153,5 +157,7 @@ func (s *IndicesOpenService) Do(ctx context.Context) (*IndicesOpenResponse, erro
// IndicesOpenResponse is the response of IndicesOpenService.Do.
type IndicesOpenResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias.go
index 5d965bd66..12f8e1bd5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias.go
@@ -192,7 +192,7 @@ func (a *AliasRemoveAction) Source() (interface{}, error) {
// -- Service --
// AliasService enables users to add or remove an alias.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-aliases.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-aliases.html
// for details.
type AliasService struct {
client *Client
@@ -274,7 +274,12 @@ func (s *AliasService) Do(ctx context.Context) (*AliasResult, error) {
body["actions"] = actions
// Get response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -291,5 +296,7 @@ func (s *AliasService) Do(ctx context.Context) (*AliasResult, error) {
// AliasResult is the outcome of calling Do on AliasService.
type AliasResult struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias_test.go
index 82ab6a07b..ada1dfdef 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_alias_test.go
@@ -25,18 +25,18 @@ func TestAliasLifecycle(t *testing.T) {
tweet3 := tweet{User: "olivere", Message: "Another unrelated topic."}
// Add tweets to first index
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Add tweets to second index
- _, err = client.Index().Index(testIndexName2).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName2).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping.go
index 03f26ca91..2f8a35e4c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping.go
@@ -10,13 +10,13 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesPutMappingService allows to register specific mapping definition
// for a specific type.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-put-mapping.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-put-mapping.html
// for details.
type IndicesPutMappingService struct {
client *Client
@@ -142,7 +142,7 @@ func (s *IndicesPutMappingService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
@@ -202,7 +202,12 @@ func (s *IndicesPutMappingService) Do(ctx context.Context) (*PutMappingResponse,
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -217,5 +222,7 @@ func (s *IndicesPutMappingService) Do(ctx context.Context) (*PutMappingResponse,
// PutMappingResponse is the response of IndicesPutMappingService.Do.
type PutMappingResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping_test.go
index ffac0d0f2..644e1187a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_mapping_test.go
@@ -19,18 +19,18 @@ func TestPutMappingURL(t *testing.T) {
}{
{
[]string{},
- "tweet",
- "/_mapping/tweet",
+ "doc",
+ "/_mapping/doc",
},
{
[]string{"*"},
- "tweet",
- "/%2A/_mapping/tweet",
+ "doc",
+ "/%2A/_mapping/doc",
},
{
[]string{"store-1", "store-2"},
- "tweet",
- "/store-1%2Cstore-2/_mapping/tweet",
+ "doc",
+ "/store-1%2Cstore-2/_mapping/doc",
},
}
@@ -47,9 +47,19 @@ func TestPutMappingURL(t *testing.T) {
func TestMappingLifecycle(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
+ //client := setupTestClientAndCreateIndexAndLog(t)
+
+ // Create index
+ createIndex, err := client.CreateIndex(testIndexName3).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if createIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createIndex)
+ }
mapping := `{
- "tweetdoc":{
+ "doc":{
"properties":{
"field":{
"type":"keyword"
@@ -58,7 +68,7 @@ func TestMappingLifecycle(t *testing.T) {
}
}`
- putresp, err := client.PutMapping().Index(testIndexName2).Type("tweetdoc").BodyString(mapping).Do(context.TODO())
+ putresp, err := client.PutMapping().Index(testIndexName3).Type("doc").BodyString(mapping).Do(context.TODO())
if err != nil {
t.Fatalf("expected put mapping to succeed; got: %v", err)
}
@@ -69,14 +79,14 @@ func TestMappingLifecycle(t *testing.T) {
t.Fatalf("expected put mapping ack; got: %v", putresp.Acknowledged)
}
- getresp, err := client.GetMapping().Index(testIndexName2).Type("tweetdoc").Do(context.TODO())
+ getresp, err := client.GetMapping().Index(testIndexName3).Type("doc").Do(context.TODO())
if err != nil {
t.Fatalf("expected get mapping to succeed; got: %v", err)
}
if getresp == nil {
t.Fatalf("expected get mapping response; got: %v", getresp)
}
- props, ok := getresp[testIndexName2]
+ props, ok := getresp[testIndexName3]
if !ok {
t.Fatalf("expected JSON root to be of type map[string]interface{}; got: %#v", props)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_settings.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_settings.go
index 20ae95207..1283eb669 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_settings.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_settings.go
@@ -10,14 +10,14 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesPutSettingsService changes specific index level settings in
// real time.
//
// See the documentation at
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-update-settings.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-update-settings.html.
type IndicesPutSettingsService struct {
client *Client
pretty bool
@@ -118,7 +118,7 @@ func (s *IndicesPutSettingsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
@@ -165,7 +165,12 @@ func (s *IndicesPutSettingsService) Do(ctx context.Context) (*IndicesPutSettings
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -180,5 +185,7 @@ func (s *IndicesPutSettingsService) Do(ctx context.Context) (*IndicesPutSettings
// IndicesPutSettingsResponse is the response of IndicesPutSettingsService.Do.
type IndicesPutSettingsResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_put_template.go b/vendor/gopkg.in/olivere/elastic.v5/indices_put_template.go
index 49df95f54..c0b959647 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_put_template.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_put_template.go
@@ -9,11 +9,11 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesPutTemplateService creates or updates index mappings.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-templates.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-templates.html.
type IndicesPutTemplateService struct {
client *Client
pretty bool
@@ -118,7 +118,7 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.order != nil {
params.Set("order", fmt.Sprintf("%v", s.order))
@@ -181,7 +181,12 @@ func (s *IndicesPutTemplateService) Do(ctx context.Context) (*IndicesPutTemplate
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -196,5 +201,7 @@ func (s *IndicesPutTemplateService) Do(ctx context.Context) (*IndicesPutTemplate
// IndicesPutTemplateResponse is the response of IndicesPutTemplateService.Do.
type IndicesPutTemplateResponse struct {
- Acknowledged bool `json:"acknowledged,omitempty"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_refresh.go b/vendor/gopkg.in/olivere/elastic.v5/indices_refresh.go
index dbc83ac2c..f6c7f165e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_refresh.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_refresh.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// RefreshService explicitly refreshes one or more indices.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-refresh.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-refresh.html.
type RefreshService struct {
client *Client
index []string
@@ -73,7 +73,11 @@ func (s *RefreshService) Do(ctx context.Context) (*RefreshResult, error) {
}
// Get response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_refresh_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_refresh_test.go
index a6aac44ea..8640fb602 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_refresh_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_refresh_test.go
@@ -50,17 +50,17 @@ func TestRefresh(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add some documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_rollover.go b/vendor/gopkg.in/olivere/elastic.v5/indices_rollover.go
index ef1cad033..841b3836f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_rollover.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_rollover.go
@@ -10,14 +10,14 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesRolloverService rolls an alias over to a new index when the
// existing index is considered to be too large or too old.
//
// It is documented at
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-rollover-index.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-rollover-index.html.
type IndicesRolloverService struct {
client *Client
pretty bool
@@ -189,10 +189,10 @@ func (s *IndicesRolloverService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.dryRun {
- params.Set("dry_run", "1")
+ params.Set("dry_run", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -242,7 +242,12 @@ func (s *IndicesRolloverService) Do(ctx context.Context) (*IndicesRolloverRespon
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_rollover_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_rollover_test.go
index 77ac1e851..81d7099e0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_rollover_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_rollover_test.go
@@ -97,7 +97,7 @@ func TestIndicesRolloverBodyComplex(t *testing.T) {
AddMaxIndexAgeCondition("2d").
AddMaxIndexDocsCondition(1000000).
AddSetting("index.number_of_shards", 2).
- AddMapping("tweet", map[string]interface{}{
+ AddMapping("doc", map[string]interface{}{
"properties": map[string]interface{}{
"user": map[string]interface{}{
"type": "keyword",
@@ -109,7 +109,7 @@ func TestIndicesRolloverBodyComplex(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"conditions":{"max_age":"2d","max_docs":1000000},"mappings":{"tweet":{"properties":{"user":{"type":"keyword"}}}},"settings":{"index.number_of_shards":2}}`
+ expected := `{"conditions":{"max_age":"2d","max_docs":1000000},"mappings":{"doc":{"properties":{"user":{"type":"keyword"}}}},"settings":{"index.number_of_shards":2}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_segments.go b/vendor/gopkg.in/olivere/elastic.v5/indices_segments.go
new file mode 100644
index 000000000..133d1101e
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_segments.go
@@ -0,0 +1,237 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/url"
+ "strings"
+
+ "github.com/olivere/elastic/uritemplates"
+)
+
+// IndicesSegmentsService provides low level segments information that a
+// Lucene index (shard level) is built with. Allows to be used to provide
+// more information on the state of a shard and an index, possibly
+// optimization information, data "wasted" on deletes, and so on.
+//
+// Find further documentation at
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-segments.html.
+type IndicesSegmentsService struct {
+ client *Client
+ pretty bool
+ index []string
+ allowNoIndices *bool
+ expandWildcards string
+ ignoreUnavailable *bool
+ human *bool
+ operationThreading interface{}
+ verbose *bool
+}
+
+// NewIndicesSegmentsService creates a new IndicesSegmentsService.
+func NewIndicesSegmentsService(client *Client) *IndicesSegmentsService {
+ return &IndicesSegmentsService{
+ client: client,
+ }
+}
+
+// Index is a comma-separated list of index names; use `_all` or empty string
+// to perform the operation on all indices.
+func (s *IndicesSegmentsService) Index(indices ...string) *IndicesSegmentsService {
+ s.index = append(s.index, indices...)
+ return s
+}
+
+// AllowNoIndices indicates whether to ignore if a wildcard indices expression
+// resolves into no concrete indices. (This includes `_all` string or when
+// no indices have been specified).
+func (s *IndicesSegmentsService) AllowNoIndices(allowNoIndices bool) *IndicesSegmentsService {
+ s.allowNoIndices = &allowNoIndices
+ return s
+}
+
+// ExpandWildcards indicates whether to expand wildcard expression to concrete indices
+// that are open, closed or both.
+func (s *IndicesSegmentsService) ExpandWildcards(expandWildcards string) *IndicesSegmentsService {
+ s.expandWildcards = expandWildcards
+ return s
+}
+
+// IgnoreUnavailable indicates whether specified concrete indices should be
+// ignored when unavailable (missing or closed).
+func (s *IndicesSegmentsService) IgnoreUnavailable(ignoreUnavailable bool) *IndicesSegmentsService {
+ s.ignoreUnavailable = &ignoreUnavailable
+ return s
+}
+
+// Human, when set to true, returns time and byte-values in human-readable format.
+func (s *IndicesSegmentsService) Human(human bool) *IndicesSegmentsService {
+ s.human = &human
+ return s
+}
+
+// OperationThreading is undocumented in Elasticsearch as of now.
+func (s *IndicesSegmentsService) OperationThreading(operationThreading interface{}) *IndicesSegmentsService {
+ s.operationThreading = operationThreading
+ return s
+}
+
+// Verbose, when set to true, includes detailed memory usage by Lucene.
+func (s *IndicesSegmentsService) Verbose(verbose bool) *IndicesSegmentsService {
+ s.verbose = &verbose
+ return s
+}
+
+// Pretty indicates that the JSON response be indented and human readable.
+func (s *IndicesSegmentsService) Pretty(pretty bool) *IndicesSegmentsService {
+ s.pretty = pretty
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *IndicesSegmentsService) buildURL() (string, url.Values, error) {
+ var err error
+ var path string
+
+ if len(s.index) > 0 {
+ path, err = uritemplates.Expand("/{index}/_segments", map[string]string{
+ "index": strings.Join(s.index, ","),
+ })
+ } else {
+ path = "/_segments"
+ }
+ if err != nil {
+ return "", url.Values{}, err
+ }
+
+ // Add query string parameters
+ params := url.Values{}
+ if s.pretty {
+ params.Set("pretty", "true")
+ }
+ if s.allowNoIndices != nil {
+ params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
+ }
+ if s.expandWildcards != "" {
+ params.Set("expand_wildcards", s.expandWildcards)
+ }
+ if s.ignoreUnavailable != nil {
+ params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
+ }
+ if s.human != nil {
+ params.Set("human", fmt.Sprintf("%v", *s.human))
+ }
+ if s.operationThreading != nil {
+ params.Set("operation_threading", fmt.Sprintf("%v", s.operationThreading))
+ }
+ if s.verbose != nil {
+ params.Set("verbose", fmt.Sprintf("%v", *s.verbose))
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *IndicesSegmentsService) Validate() error {
+ return nil
+}
+
+// Do executes the operation.
+func (s *IndicesSegmentsService) Do(ctx context.Context) (*IndicesSegmentsResponse, error) {
+ // Check pre-conditions
+ if err := s.Validate(); err != nil {
+ return nil, err
+ }
+
+ // Get URL for request
+ path, params, err := s.buildURL()
+ if err != nil {
+ return nil, err
+ }
+
+ // Get HTTP response
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ // Return operation response
+ ret := new(IndicesSegmentsResponse)
+ if err := json.Unmarshal(res.Body, ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// IndicesSegmentsResponse is the response of IndicesSegmentsService.Do.
+type IndicesSegmentsResponse struct {
+ // Shards provides information returned from shards.
+ Shards shardsInfo `json:"_shards"`
+
+ // Indices provides a map into the stats of an index.
+ // The key of the map is the index name.
+ Indices map[string]*IndexSegments `json:"indices,omitempty"`
+}
+
+type IndexSegments struct {
+ // Shards provides a map into the shard related information of an index.
+ // The key of the map is the number of a specific shard.
+ Shards map[string][]*IndexSegmentsShards `json:"shards,omitempty"`
+}
+
+type IndexSegmentsShards struct {
+ Routing *IndexSegmentsRouting `json:"routing,omitempty"`
+ NumCommittedSegments int64 `json:"num_committed_segments,omitempty"`
+ NumSearchSegments int64 `json:"num_search_segments"`
+
+ // Segments provides a map into the segment related information of a shard.
+ // The key of the map is the specific lucene segment id.
+ Segments map[string]*IndexSegmentsDetails `json:"segments,omitempty"`
+}
+
+type IndexSegmentsRouting struct {
+ State string `json:"state,omitempty"`
+ Primary bool `json:"primary,omitempty"`
+ Node string `json:"node,omitempty"`
+ RelocatingNode string `json:"relocating_node,omitempty"`
+}
+
+type IndexSegmentsDetails struct {
+ Generation int64 `json:"generation,omitempty"`
+ NumDocs int64 `json:"num_docs,omitempty"`
+ DeletedDocs int64 `json:"deleted_docs,omitempty"`
+ Size string `json:"size,omitempty"`
+ SizeInBytes int64 `json:"size_in_bytes,omitempty"`
+ Memory string `json:"memory,omitempty"`
+ MemoryInBytes int64 `json:"memory_in_bytes,omitempty"`
+ Committed bool `json:"committed,omitempty"`
+ Search bool `json:"search,omitempty"`
+ Version string `json:"version,omitempty"`
+ Compound bool `json:"compound,omitempty"`
+ MergeId string `json:"merge_id,omitempty"`
+ Sort []*IndexSegmentsSort `json:"sort,omitempty"`
+ RAMTree []*IndexSegmentsRamTree `json:"ram_tree,omitempty"`
+ Attributes map[string]string `json:"attributes,omitempty"`
+}
+
+type IndexSegmentsSort struct {
+ Field string `json:"field,omitempty"`
+ Mode string `json:"mode,omitempty"`
+ Missing interface{} `json:"missing,omitempty"`
+ Reverse bool `json:"reverse,omitempty"`
+}
+
+type IndexSegmentsRamTree struct {
+ Description string `json:"description,omitempty"`
+ Size string `json:"size,omitempty"`
+ SizeInBytes int64 `json:"size_in_bytes,omitempty"`
+ Children []*IndexSegmentsRamTree `json:"children,omitempty"`
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_segments_test.go b/vendor/gopkg.in/olivere/elastic.v5/indices_segments_test.go
new file mode 100644
index 000000000..2ec181cc1
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_segments_test.go
@@ -0,0 +1,86 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "testing"
+)
+
+func TestIndicesSegments(t *testing.T) {
+ client := setupTestClientAndCreateIndex(t)
+
+ tests := []struct {
+ Indices []string
+ Expected string
+ }{
+ {
+ []string{},
+ "/_segments",
+ },
+ {
+ []string{"index1"},
+ "/index1/_segments",
+ },
+ {
+ []string{"index1", "index2"},
+ "/index1%2Cindex2/_segments",
+ },
+ }
+
+ for i, test := range tests {
+ path, _, err := client.IndexSegments().Index(test.Indices...).buildURL()
+ if err != nil {
+ t.Errorf("case #%d: %v", i+1, err)
+ }
+ if path != test.Expected {
+ t.Errorf("case #%d: expected %q; got: %q", i+1, test.Expected, path)
+ }
+ }
+}
+
+func TestIndexSegments(t *testing.T) {
+ client := setupTestClientAndCreateIndexAndAddDocs(t)
+ //client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", 0)))
+
+ segments, err := client.IndexSegments(testIndexName).Pretty(true).Human(true).Do(context.TODO())
+ if err != nil {
+ t.Fatalf("expected no error; got: %v", err)
+ }
+ if segments == nil {
+ t.Fatalf("expected response; got: %v", segments)
+ }
+ indices, found := segments.Indices[testIndexName]
+ if !found {
+ t.Fatalf("expected index information about index %v; got: %v", testIndexName, found)
+ }
+ shards, found := indices.Shards["0"]
+ if !found {
+ t.Fatalf("expected shard information about index %v", testIndexName)
+ }
+ if shards == nil {
+ t.Fatalf("expected shard information to be != nil for index %v", testIndexName)
+ }
+ shard := shards[0]
+ if shard == nil {
+ t.Fatalf("expected shard information to be != nil for shard 0 in index %v", testIndexName)
+ }
+ if shard.Routing == nil {
+ t.Fatalf("expected shard routing information to be != nil for index %v", testIndexName)
+ }
+ segmentDetail, found := shard.Segments["_0"]
+ if !found {
+ t.Fatalf("expected segment detail to be != nil for index %v", testIndexName)
+ }
+ if segmentDetail == nil {
+ t.Fatalf("expected segment detail to be != nil for index %v", testIndexName)
+ }
+ if segmentDetail.NumDocs == 0 {
+ t.Fatal("expected segment to contain >= 1 docs")
+ }
+ if len(segmentDetail.Attributes) == 0 {
+ t.Fatalf("expected segment attributes map to contain at least one key, value pair for index %v", testIndexName)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_shrink.go b/vendor/gopkg.in/olivere/elastic.v5/indices_shrink.go
index ea20804a6..6ea72b281 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_shrink.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_shrink.go
@@ -10,14 +10,14 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesShrinkService allows you to shrink an existing index into a
// new index with fewer primary shards.
//
// For further details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-shrink-index.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-shrink-index.html.
type IndicesShrinkService struct {
client *Client
pretty bool
@@ -102,7 +102,7 @@ func (s *IndicesShrinkService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -153,7 +153,12 @@ func (s *IndicesShrinkService) Do(ctx context.Context) (*IndicesShrinkResponse,
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -168,6 +173,7 @@ func (s *IndicesShrinkService) Do(ctx context.Context) (*IndicesShrinkResponse,
// IndicesShrinkResponse is the response of IndicesShrinkService.Do.
type IndicesShrinkResponse struct {
- Acknowledged bool `json:"acknowledged"`
- ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/indices_stats.go b/vendor/gopkg.in/olivere/elastic.v5/indices_stats.go
index 90ae6837a..20d35a6d4 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/indices_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/indices_stats.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IndicesStatsService provides stats on various metrics of one or more
-// indices. See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-stats.html.
+// indices. See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/indices-stats.html.
type IndicesStatsService struct {
client *Client
pretty bool
@@ -135,7 +135,7 @@ func (s *IndicesStatsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.groups) > 0 {
params.Set("groups", strings.Join(s.groups, ","))
@@ -180,7 +180,11 @@ func (s *IndicesStatsService) Do(ctx context.Context) (*IndicesStatsResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -239,25 +243,20 @@ type IndexStatsDocs struct {
}
type IndexStatsStore struct {
- Size string `json:"size,omitempty"` // human size, e.g. 119.3mb
- SizeInBytes int64 `json:"size_in_bytes,omitempty"`
- ThrottleTime string `json:"throttle_time,omitempty"` // human time, e.g. 0s
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis,omitempty"`
+ Size string `json:"size,omitempty"` // human size, e.g. 119.3mb
+ SizeInBytes int64 `json:"size_in_bytes,omitempty"`
}
type IndexStatsIndexing struct {
- IndexTotal int64 `json:"index_total,omitempty"`
- IndexTime string `json:"index_time,omitempty"`
- IndexTimeInMillis int64 `json:"index_time_in_millis,omitempty"`
- IndexCurrent int64 `json:"index_current,omitempty"`
- DeleteTotal int64 `json:"delete_total,omitempty"`
- DeleteTime string `json:"delete_time,omitempty"`
- DeleteTimeInMillis int64 `json:"delete_time_in_millis,omitempty"`
- DeleteCurrent int64 `json:"delete_current,omitempty"`
- NoopUpdateTotal int64 `json:"noop_update_total,omitempty"`
- IsThrottled bool `json:"is_throttled,omitempty"`
- ThrottleTime string `json:"throttle_time,omitempty"`
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis,omitempty"`
+ IndexTotal int64 `json:"index_total,omitempty"`
+ IndexTime string `json:"index_time,omitempty"`
+ IndexTimeInMillis int64 `json:"index_time_in_millis,omitempty"`
+ IndexCurrent int64 `json:"index_current,omitempty"`
+ DeleteTotal int64 `json:"delete_total,omitempty"`
+ DeleteTime string `json:"delete_time,omitempty"`
+ DeleteTimeInMillis int64 `json:"delete_time_in_millis,omitempty"`
+ DeleteCurrent int64 `json:"delete_current,omitempty"`
+ NoopUpdateTotal int64 `json:"noop_update_total,omitempty"`
}
type IndexStatsGet struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ingest_delete_pipeline.go b/vendor/gopkg.in/olivere/elastic.v5/ingest_delete_pipeline.go
index 1e33d9707..78b6d04f2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ingest_delete_pipeline.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ingest_delete_pipeline.go
@@ -10,11 +10,11 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IngestDeletePipelineService deletes pipelines by ID.
-// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/delete-pipeline-api.html.
+// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/delete-pipeline-api.html.
type IngestDeletePipelineService struct {
client *Client
pretty bool
@@ -67,7 +67,7 @@ func (s *IngestDeletePipelineService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -104,7 +104,11 @@ func (s *IngestDeletePipelineService) Do(ctx context.Context) (*IngestDeletePipe
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -119,5 +123,7 @@ func (s *IngestDeletePipelineService) Do(ctx context.Context) (*IngestDeletePipe
// IngestDeletePipelineResponse is the response of IngestDeletePipelineService.Do.
type IngestDeletePipelineResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline.go b/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline.go
index 9a3357d7f..16a683261 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IngestGetPipelineService returns pipelines based on ID.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/get-pipeline-api.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/get-pipeline-api.html
// for documentation.
type IngestGetPipelineService struct {
client *Client
@@ -68,7 +68,7 @@ func (s *IngestGetPipelineService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -95,7 +95,11 @@ func (s *IngestGetPipelineService) Do(ctx context.Context) (IngestGetPipelineRes
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ingest_put_pipeline.go b/vendor/gopkg.in/olivere/elastic.v5/ingest_put_pipeline.go
index 315453e9d..5781e7072 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ingest_put_pipeline.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ingest_put_pipeline.go
@@ -10,13 +10,13 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IngestPutPipelineService adds pipelines and updates existing pipelines in
// the cluster.
//
-// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/put-pipeline-api.html.
+// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/put-pipeline-api.html.
type IngestPutPipelineService struct {
client *Client
pretty bool
@@ -84,7 +84,7 @@ func (s *IngestPutPipelineService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -132,7 +132,12 @@ func (s *IngestPutPipelineService) Do(ctx context.Context) (*IngestPutPipelineRe
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -147,5 +152,7 @@ func (s *IngestPutPipelineService) Do(ctx context.Context) (*IngestPutPipelineRe
// IngestPutPipelineResponse is the response of IngestPutPipelineService.Do.
type IngestPutPipelineResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ingest_simulate_pipeline.go b/vendor/gopkg.in/olivere/elastic.v5/ingest_simulate_pipeline.go
index 04015b459..213f97bbb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ingest_simulate_pipeline.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ingest_simulate_pipeline.go
@@ -10,14 +10,14 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// IngestSimulatePipelineService executes a specific pipeline against the set of
// documents provided in the body of the request.
//
// The API is documented at
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/simulate-pipeline-api.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/simulate-pipeline-api.html.
type IngestSimulatePipelineService struct {
client *Client
pretty bool
@@ -85,7 +85,7 @@ func (s *IngestSimulatePipelineService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.verbose != nil {
params.Set("verbose", fmt.Sprintf("%v", *s.verbose))
@@ -127,7 +127,12 @@ func (s *IngestSimulatePipelineService) Do(ctx context.Context) (*IngestSimulate
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/mget.go b/vendor/gopkg.in/olivere/elastic.v5/mget.go
index 0f2894854..5202a9603 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/mget.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/mget.go
@@ -16,7 +16,7 @@ import (
// a docs array with all the fetched documents, each element similar
// in structure to a document provided by the Get API.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-multi-get.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-multi-get.html
// for details.
type MgetService struct {
client *Client
@@ -124,7 +124,12 @@ func (s *MgetService) Do(ctx context.Context) (*MgetResponse, error) {
}
// Get response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -194,8 +199,8 @@ func (item *MultiGetItem) Version(version int64) *MultiGetItem {
return item
}
-// VersionType can be "internal", "external", "external_gt", "external_gte",
-// or "force". See org.elasticsearch.index.VersionType in Elasticsearch source.
+// VersionType can be "internal", "external", "external_gt", or "external_gte".
+// See org.elasticsearch.index.VersionType in Elasticsearch source.
// It is "internal" by default.
func (item *MultiGetItem) VersionType(versionType string) *MultiGetItem {
item.versionType = versionType
diff --git a/vendor/gopkg.in/olivere/elastic.v5/mget_test.go b/vendor/gopkg.in/olivere/elastic.v5/mget_test.go
index 4d6bfa0c5..6b3ecd9f6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/mget_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/mget_test.go
@@ -18,17 +18,17 @@ func TestMultiGet(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add some documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -49,8 +49,8 @@ func TestMultiGet(t *testing.T) {
// Get documents 1 and 3
res, err := client.MultiGet().
- Add(NewMultiGetItem().Index(testIndexName).Type("tweet").Id("1")).
- Add(NewMultiGetItem().Index(testIndexName).Type("tweet").Id("3")).
+ Add(NewMultiGetItem().Index(testIndexName).Type("doc").Id("1")).
+ Add(NewMultiGetItem().Index(testIndexName).Type("doc").Id("3")).
Do(context.TODO())
if err != nil {
t.Fatal(err)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/msearch.go b/vendor/gopkg.in/olivere/elastic.v5/msearch.go
index 5d0949d9c..ed54d3c2f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/msearch.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/msearch.go
@@ -78,7 +78,12 @@ func (s *MultiSearchService) Do(ctx context.Context) (*MultiSearchResult, error)
body := strings.Join(lines, "\n") + "\n" // Don't forget trailing \n
// Get response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/msearch_test.go b/vendor/gopkg.in/olivere/elastic.v5/msearch_test.go
index 0d3670da6..79f2047e6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/msearch_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/msearch_test.go
@@ -31,17 +31,17 @@ func TestMultiSearch(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -57,7 +57,7 @@ func TestMultiSearch(t *testing.T) {
sreq1 := NewSearchRequest().Index(testIndexName, testIndexName2).
Source(NewSearchSource().Query(q1).Size(10))
- sreq2 := NewSearchRequest().Index(testIndexName).Type("tweet").
+ sreq2 := NewSearchRequest().Index(testIndexName).Type("doc").
Source(NewSearchSource().Query(q2))
searchResult, err := client.MultiSearch().
@@ -136,17 +136,17 @@ func TestMultiSearchWithOneRequest(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/mtermvectors.go b/vendor/gopkg.in/olivere/elastic.v5/mtermvectors.go
index da0ca70c5..755718e67 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/mtermvectors.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/mtermvectors.go
@@ -11,14 +11,14 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// MultiTermvectorService returns information and statistics on terms in the
// fields of a particular document. The document could be stored in the
// index or artificially provided by the user.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-multi-termvectors.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-multi-termvectors.html
// for documentation.
type MultiTermvectorService struct {
client *Client
@@ -198,7 +198,7 @@ func (s *MultiTermvectorService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.fieldStatistics != nil {
params.Set("field_statistics", fmt.Sprintf("%v", *s.fieldStatistics))
@@ -278,7 +278,12 @@ func (s *MultiTermvectorService) Do(ctx context.Context) (*MultiTermvectorRespon
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/mtermvectors_test.go b/vendor/gopkg.in/olivere/elastic.v5/mtermvectors_test.go
index fe543cf29..5f90cd5e2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/mtermvectors_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/mtermvectors_test.go
@@ -35,15 +35,15 @@ func TestMultiTermVectorsValidateAndBuildURL(t *testing.T) {
// #2: Type without index
{
"",
- "tweet",
+ "doc",
"",
true,
},
// #3: Both index and type
{
"twitter",
- "tweet",
- "/twitter/tweet/_mtermvectors",
+ "doc",
+ "/twitter/doc/_mtermvectors",
false,
},
}
@@ -82,17 +82,17 @@ func TestMultiTermVectorsWithIds(t *testing.T) {
tweet2 := tweet{User: "olivere", Message: "Another unrelated topic."}
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -115,9 +115,9 @@ func TestMultiTermVectorsWithIds(t *testing.T) {
field := "Message"
res, err := client.MultiTermVectors().
Index(testIndexName).
- Type("tweet").
- Add(NewMultiTermvectorItem().Index(testIndexName).Type("tweet").Id("1").Fields(field)).
- Add(NewMultiTermvectorItem().Index(testIndexName).Type("tweet").Id("3").Fields(field)).
+ Type("doc").
+ Add(NewMultiTermvectorItem().Index(testIndexName).Type("doc").Id("1").Fields(field)).
+ Add(NewMultiTermvectorItem().Index(testIndexName).Type("doc").Id("3").Fields(field)).
Do(context.TODO())
if err != nil {
t.Fatal(err)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/nodes_info.go b/vendor/gopkg.in/olivere/elastic.v5/nodes_info.go
index b3687d689..9f1422a69 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/nodes_info.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/nodes_info.go
@@ -11,12 +11,12 @@ import (
"strings"
"time"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// NodesInfoService allows to retrieve one or more or all of the
// cluster nodes information.
-// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-nodes-info.html.
+// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/cluster-nodes-info.html.
type NodesInfoService struct {
client *Client
pretty bool
@@ -89,7 +89,7 @@ func (s *NodesInfoService) buildURL() (string, url.Values, error) {
params.Set("human", fmt.Sprintf("%v", *s.human))
}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
return path, params, nil
}
@@ -113,7 +113,11 @@ func (s *NodesInfoService) Do(ctx context.Context) (*NodesInfoResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go b/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
index a955bb426..7c5f0c9d6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
@@ -11,7 +11,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// NodesStatsService returns node statistics.
@@ -165,7 +165,7 @@ func (s *NodesStatsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.completionFields) > 0 {
params.Set("completion_fields", strings.Join(s.completionFields, ","))
@@ -213,7 +213,11 @@ func (s *NodesStatsService) Do(ctx context.Context) (*NodesStatsResponse, error)
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -316,26 +320,21 @@ type NodesStatsDocsStats struct {
}
type NodesStatsStoreStats struct {
- Size string `json:"size"`
- SizeInBytes int64 `json:"size_in_bytes"`
- ThrottleTime string `json:"throttle_time"`
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis"`
+ Size string `json:"size"`
+ SizeInBytes int64 `json:"size_in_bytes"`
}
type NodesStatsIndexingStats struct {
- IndexTotal int64 `json:"index_total"`
- IndexTime string `json:"index_time"`
- IndexTimeInMillis int64 `json:"index_time_in_millis"`
- IndexCurrent int64 `json:"index_current"`
- IndexFailed int64 `json:"index_failed"`
- DeleteTotal int64 `json:"delete_total"`
- DeleteTime string `json:"delete_time"`
- DeleteTimeInMillis int64 `json:"delete_time_in_millis"`
- DeleteCurrent int64 `json:"delete_current"`
- NoopUpdateTotal int64 `json:"noop_update_total"`
- IsThrottled bool `json:"is_throttled"`
- ThrottleTime string `json:"throttle_time"`
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis"`
+ IndexTotal int64 `json:"index_total"`
+ IndexTime string `json:"index_time"`
+ IndexTimeInMillis int64 `json:"index_time_in_millis"`
+ IndexCurrent int64 `json:"index_current"`
+ IndexFailed int64 `json:"index_failed"`
+ DeleteTotal int64 `json:"delete_total"`
+ DeleteTime string `json:"delete_time"`
+ DeleteTimeInMillis int64 `json:"delete_time_in_millis"`
+ DeleteCurrent int64 `json:"delete_current"`
+ NoopUpdateTotal int64 `json:"noop_update_total"`
Types map[string]*NodesStatsIndexingStats `json:"types"` // stats for individual types
}
@@ -495,10 +494,8 @@ type NodesStatsRequestCacheStats struct {
}
type NodesStatsRecoveryStats struct {
- CurrentAsSource int `json:"current_as_source"`
- CurrentAsTarget int `json:"current_as_target"`
- ThrottleTime string `json:"throttle_time"`
- ThrottleTimeInMillis int64 `json:"throttle_time_in_millis"`
+ CurrentAsSource int `json:"current_as_source"`
+ CurrentAsTarget int `json:"current_as_target"`
}
type NodesStatsNodeOS struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/percolate_test.go b/vendor/gopkg.in/olivere/elastic.v5/percolate_test.go
index 43354f0b1..3b3b2efb7 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/percolate_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/percolate_test.go
@@ -10,12 +10,23 @@ import (
)
func TestPercolate(t *testing.T) {
- client := setupTestClientAndCreateIndex(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
+ //client := setupTestClientAndCreateIndex(t, SetErrorLog(log.New(os.Stdout, "", 0)))
+ //client := setupTestClientAndCreateIndex(t, SetTraceLog(log.New(os.Stdout, "", 0)))
+ client := setupTestClientAndCreateIndex(t)
+
+ // Create query index
+ createQueryIndex, err := client.CreateIndex(testQueryIndex).Body(testQueryMapping).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if createQueryIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createQueryIndex)
+ }
// Add a document
- _, err := client.Index().
- Index(testIndexName).
- Type("queries").
+ _, err = client.Index().
+ Index(testQueryIndex).
+ Type("doc").
Id("1").
BodyJson(`{"query":{"match":{"message":"bonsai tree"}}}`).
Refresh("wait_for").
@@ -27,9 +38,9 @@ func TestPercolate(t *testing.T) {
// Percolate should return our registered query
pq := NewPercolatorQuery().
Field("query").
- DocumentType("doctype").
+ DocumentType("doc").
Document(doctype{Message: "A new bonsai tree in the office"})
- res, err := client.Search(testIndexName).Query(pq).Do(context.TODO())
+ res, err := client.Search(testQueryIndex).Type("doc").Query(pq).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -46,8 +57,8 @@ func TestPercolate(t *testing.T) {
t.Fatalf("expected len(SearchResult.Hits.Hits) = %d; got %d", want, got)
}
hit := res.Hits.Hits[0]
- if hit.Index != testIndexName {
- t.Fatalf("expected SearchResult.Hits.Hit.Index = %q; got %q", testIndexName, hit.Index)
+ if hit.Index != testQueryIndex {
+ t.Fatalf("expected SearchResult.Hits.Hit.Index = %q; got %q", testQueryIndex, hit.Index)
}
got := string(*hit.Source)
expected := `{"query":{"match":{"message":"bonsai tree"}}}`
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ping.go b/vendor/gopkg.in/olivere/elastic.v5/ping.go
index a97ddeceb..5c2d34f00 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ping.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ping.go
@@ -86,7 +86,7 @@ func (s *PingService) Do(ctx context.Context) (*PingResult, int, error) {
params.Set("timeout", s.timeout)
}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(params) > 0 {
url_ += "?" + params.Encode()
diff --git a/vendor/gopkg.in/olivere/elastic.v5/put_template.go b/vendor/gopkg.in/olivere/elastic.v5/put_template.go
deleted file mode 100644
index 5bd8423b5..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/put_template.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "fmt"
- "net/url"
-
- "gopkg.in/olivere/elastic.v5/uritemplates"
-)
-
-// PutTemplateService creates or updates a search template.
-// The documentation can be found at
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-template.html.
-type PutTemplateService struct {
- client *Client
- pretty bool
- id string
- opType string
- version *int
- versionType string
- bodyJson interface{}
- bodyString string
-}
-
-// NewPutTemplateService creates a new PutTemplateService.
-func NewPutTemplateService(client *Client) *PutTemplateService {
- return &PutTemplateService{
- client: client,
- }
-}
-
-// Id is the template ID.
-func (s *PutTemplateService) Id(id string) *PutTemplateService {
- s.id = id
- return s
-}
-
-// OpType is an explicit operation type.
-func (s *PutTemplateService) OpType(opType string) *PutTemplateService {
- s.opType = opType
- return s
-}
-
-// Version is an explicit version number for concurrency control.
-func (s *PutTemplateService) Version(version int) *PutTemplateService {
- s.version = &version
- return s
-}
-
-// VersionType is a specific version type.
-func (s *PutTemplateService) VersionType(versionType string) *PutTemplateService {
- s.versionType = versionType
- return s
-}
-
-// BodyJson is the document as a JSON serializable object.
-func (s *PutTemplateService) BodyJson(body interface{}) *PutTemplateService {
- s.bodyJson = body
- return s
-}
-
-// BodyString is the document as a string.
-func (s *PutTemplateService) BodyString(body string) *PutTemplateService {
- s.bodyString = body
- return s
-}
-
-// buildURL builds the URL for the operation.
-func (s *PutTemplateService) buildURL() (string, url.Values, error) {
- // Build URL
- path, err := uritemplates.Expand("/_search/template/{id}", map[string]string{
- "id": s.id,
- })
- if err != nil {
- return "", url.Values{}, err
- }
-
- // Add query string parameters
- params := url.Values{}
- if s.version != nil {
- params.Set("version", fmt.Sprintf("%d", *s.version))
- }
- if s.versionType != "" {
- params.Set("version_type", s.versionType)
- }
- if s.opType != "" {
- params.Set("op_type", s.opType)
- }
-
- return path, params, nil
-}
-
-// Validate checks if the operation is valid.
-func (s *PutTemplateService) Validate() error {
- var invalid []string
- if s.id == "" {
- invalid = append(invalid, "Id")
- }
- if s.bodyString == "" && s.bodyJson == nil {
- invalid = append(invalid, "BodyJson")
- }
- if len(invalid) > 0 {
- return fmt.Errorf("missing required fields: %v", invalid)
- }
- return nil
-}
-
-// Do executes the operation.
-func (s *PutTemplateService) Do(ctx context.Context) (*AcknowledgedResponse, error) {
- // Check pre-conditions
- if err := s.Validate(); err != nil {
- return nil, err
- }
-
- // Get URL for request
- path, params, err := s.buildURL()
- if err != nil {
- return nil, err
- }
-
- // Setup HTTP request body
- var body interface{}
- if s.bodyJson != nil {
- body = s.bodyJson
- } else {
- body = s.bodyString
- }
-
- // Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
- if err != nil {
- return nil, err
- }
-
- // Return operation response
- ret := new(AcknowledgedResponse)
- if err := s.client.decoder.Decode(res.Body, ret); err != nil {
- return nil, err
- }
- return ret, nil
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/put_template_test.go b/vendor/gopkg.in/olivere/elastic.v5/put_template_test.go
deleted file mode 100644
index 29027a185..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/put_template_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "testing"
-)
-
-func TestSearchTemplatesLifecycle(t *testing.T) {
- client := setupTestClientAndCreateIndex(t)
-
- // Template
- tmpl := `{"template":{"query":{"match":{"title":"{{query_string}}"}}}}`
-
- // Create template
- cresp, err := client.PutTemplate().Id("elastic-test").BodyString(tmpl).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
- if cresp == nil {
- t.Fatalf("expected response != nil; got: %v", cresp)
- }
- if !cresp.Acknowledged {
- t.Errorf("expected acknowledged = %v; got: %v", true, cresp.Acknowledged)
- }
-
- // Get template
- resp, err := client.GetTemplate().Id("elastic-test").Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
- if resp == nil {
- t.Fatalf("expected response != nil; got: %v", resp)
- }
- if resp.Template == "" {
- t.Errorf("expected template != %q; got: %q", "", resp.Template)
- }
-
- // Delete template
- dresp, err := client.DeleteTemplate().Id("elastic-test").Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
- if dresp == nil {
- t.Fatalf("expected response != nil; got: %v", dresp)
- }
- if !dresp.Acknowledged {
- t.Fatalf("expected acknowledged = %v; got: %v", true, dresp.Acknowledged)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/recipes/bulk_insert/bulk_insert.go b/vendor/gopkg.in/olivere/elastic.v5/recipes/bulk_insert/bulk_insert.go
index 5a7909095..5a8ab39d0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/recipes/bulk_insert/bulk_insert.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/recipes/bulk_insert/bulk_insert.go
@@ -11,7 +11,7 @@
// The number of documents after which a commit happens can be specified
// via the "bulk-size" flag.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html
// for details on the Bulk API in Elasticsearch.
//
// Example
@@ -35,7 +35,7 @@ import (
"time"
"golang.org/x/sync/errgroup"
- "gopkg.in/olivere/elastic.v5"
+ "github.com/olivere/elastic"
)
func main() {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/recipes/connect/connect.go b/vendor/gopkg.in/olivere/elastic.v5/recipes/connect/connect.go
index 156658d36..baff6c114 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/recipes/connect/connect.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/recipes/connect/connect.go
@@ -16,7 +16,7 @@ import (
"fmt"
"log"
- "gopkg.in/olivere/elastic.v5"
+ "github.com/olivere/elastic"
)
func main() {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/recipes/sliced_scroll/sliced_scroll.go b/vendor/gopkg.in/olivere/elastic.v5/recipes/sliced_scroll/sliced_scroll.go
index e59ca562d..d753a61cb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/recipes/sliced_scroll/sliced_scroll.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/recipes/sliced_scroll/sliced_scroll.go
@@ -13,7 +13,7 @@
// The speedup of sliced scrolling can be significant but is very
// dependent on the specific use case.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html#sliced-scroll
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html#sliced-scroll
// for details on sliced scrolling in Elasticsearch.
//
// Example
@@ -36,7 +36,7 @@ import (
"time"
"golang.org/x/sync/errgroup"
- "gopkg.in/olivere/elastic.v5"
+ "github.com/olivere/elastic"
)
func main() {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/reindex.go b/vendor/gopkg.in/olivere/elastic.v5/reindex.go
index 4650fb18b..35440fa80 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/reindex.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/reindex.go
@@ -11,7 +11,7 @@ import (
)
// ReindexService is a method to copy documents from one index to another.
-// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.0/docs-reindex.html.
+// It is documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html.
type ReindexService struct {
client *Client
pretty bool
@@ -168,7 +168,7 @@ func (s *ReindexService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.refresh != "" {
params.Set("refresh", s.refresh)
@@ -267,7 +267,12 @@ func (s *ReindexService) Do(ctx context.Context) (*BulkIndexByScrollResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -309,7 +314,12 @@ func (s *ReindexService) DoAsync(ctx context.Context) (*StartTaskResult, error)
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -568,7 +578,7 @@ func (ri *ReindexRemoteInfo) Source() (interface{}, error) {
// ReindexDestination is the destination of a Reindex API call.
// It is basically the meta data of a BulkIndexRequest.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-reindex.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html
// fsourcer details.
type ReindexDestination struct {
index string
@@ -627,7 +637,7 @@ func (r *ReindexDestination) Parent(parent string) *ReindexDestination {
// OpType specifies if this request should follow create-only or upsert
// behavior. This follows the OpType of the standard document index API.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-index_.html#operation-type
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html#operation-type
// for details.
func (r *ReindexDestination) OpType(opType string) *ReindexDestination {
r.opType = opType
diff --git a/vendor/gopkg.in/olivere/elastic.v5/reindex_test.go b/vendor/gopkg.in/olivere/elastic.v5/reindex_test.go
index 2ab604089..fadf4bfc7 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/reindex_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/reindex_test.go
@@ -166,7 +166,7 @@ func TestReindexSourceWithProceedOnVersionConflict(t *testing.T) {
func TestReindexSourceWithQuery(t *testing.T) {
client := setupTestClient(t)
- src := NewReindexSource().Index("twitter").Type("tweet").Query(NewTermQuery("user", "olivere"))
+ src := NewReindexSource().Index("twitter").Type("doc").Query(NewTermQuery("user", "olivere"))
dst := NewReindexDestination().Index("new_twitter")
out, err := client.Reindex().Source(src).Destination(dst).getBody()
if err != nil {
@@ -177,7 +177,7 @@ func TestReindexSourceWithQuery(t *testing.T) {
t.Fatal(err)
}
got := string(b)
- want := `{"dest":{"index":"new_twitter"},"source":{"index":"twitter","query":{"term":{"user":"olivere"}},"type":"tweet"}}`
+ want := `{"dest":{"index":"new_twitter"},"source":{"index":"twitter","query":{"term":{"user":"olivere"}},"type":"doc"}}`
if got != want {
t.Fatalf("\ngot %s\nwant %s", got, want)
}
@@ -185,7 +185,7 @@ func TestReindexSourceWithQuery(t *testing.T) {
func TestReindexSourceWithMultipleSourceIndicesAndTypes(t *testing.T) {
client := setupTestClient(t)
- src := NewReindexSource().Index("twitter", "blog").Type("tweet", "post")
+ src := NewReindexSource().Index("twitter", "blog").Type("doc", "post")
dst := NewReindexDestination().Index("all_together")
out, err := client.Reindex().Source(src).Destination(dst).getBody()
if err != nil {
@@ -196,7 +196,7 @@ func TestReindexSourceWithMultipleSourceIndicesAndTypes(t *testing.T) {
t.Fatal(err)
}
got := string(b)
- want := `{"dest":{"index":"all_together"},"source":{"index":["twitter","blog"],"type":["tweet","post"]}}`
+ want := `{"dest":{"index":"all_together"},"source":{"index":["twitter","blog"],"type":["doc","post"]}}`
if got != want {
t.Fatalf("\ngot %s\nwant %s", got, want)
}
@@ -235,7 +235,7 @@ func TestReindexSourceWithScript(t *testing.T) {
t.Fatal(err)
}
got := string(b)
- want := `{"dest":{"index":"new_twitter","version_type":"external"},"script":{"inline":"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}"},"source":{"index":"twitter"}}`
+ want := `{"dest":{"index":"new_twitter","version_type":"external"},"script":{"source":"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}"},"source":{"index":"twitter"}}`
if got != want {
t.Fatalf("\ngot %s\nwant %s", got, want)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/request.go b/vendor/gopkg.in/olivere/elastic.v5/request.go
index da5a7216e..87d191965 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/request.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/request.go
@@ -6,7 +6,6 @@ package elastic
import (
"bytes"
- "compress/gzip"
"encoding/json"
"io"
"io/ioutil"
@@ -35,21 +34,13 @@ func (r *Request) SetBasicAuth(username, password string) {
((*http.Request)(r)).SetBasicAuth(username, password)
}
-// SetBody encodes the body in the request. Optionally, it performs GZIP compression.
-func (r *Request) SetBody(body interface{}, gzipCompress bool) error {
+// SetBody encodes the body in the request.
+func (r *Request) SetBody(body interface{}) error {
switch b := body.(type) {
case string:
- if gzipCompress {
- return r.setBodyGzip(b)
- } else {
- return r.setBodyString(b)
- }
+ return r.setBodyString(b)
default:
- if gzipCompress {
- return r.setBodyGzip(body)
- } else {
- return r.setBodyJson(body)
- }
+ return r.setBodyJson(body)
}
}
@@ -69,42 +60,6 @@ func (r *Request) setBodyString(body string) error {
return r.setBodyReader(strings.NewReader(body))
}
-// setBodyGzip gzip's the body. It accepts both strings and structs as body.
-// The latter will be encoded via json.Marshal.
-func (r *Request) setBodyGzip(body interface{}) error {
- switch b := body.(type) {
- case string:
- buf := new(bytes.Buffer)
- w := gzip.NewWriter(buf)
- if _, err := w.Write([]byte(b)); err != nil {
- return err
- }
- if err := w.Close(); err != nil {
- return err
- }
- r.Header.Add("Content-Encoding", "gzip")
- r.Header.Add("Vary", "Accept-Encoding")
- return r.setBodyReader(bytes.NewReader(buf.Bytes()))
- default:
- data, err := json.Marshal(b)
- if err != nil {
- return err
- }
- buf := new(bytes.Buffer)
- w := gzip.NewWriter(buf)
- if _, err := w.Write(data); err != nil {
- return err
- }
- if err := w.Close(); err != nil {
- return err
- }
- r.Header.Add("Content-Encoding", "gzip")
- r.Header.Add("Vary", "Accept-Encoding")
- r.Header.Set("Content-Type", "application/json")
- return r.setBodyReader(bytes.NewReader(buf.Bytes()))
- }
-}
-
// setBodyReader writes the body from an io.Reader.
func (r *Request) setBodyReader(body io.Reader) error {
rc, ok := body.(io.ReadCloser)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/request_test.go b/vendor/gopkg.in/olivere/elastic.v5/request_test.go
index d5ae4f800..04fbecbab 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/request_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/request_test.go
@@ -29,22 +29,7 @@ func BenchmarkRequestSetBodyString(b *testing.B) {
}
for i := 0; i < b.N; i++ {
body := `{"query":{"match_all":{}}}`
- err = req.SetBody(body, false)
- if err != nil {
- b.Fatal(err)
- }
- }
- testReq = req
-}
-
-func BenchmarkRequestSetBodyStringGzip(b *testing.B) {
- req, err := NewRequest("GET", "/")
- if err != nil {
- b.Fatal(err)
- }
- for i := 0; i < b.N; i++ {
- body := `{"query":{"match_all":{}}}`
- err = req.SetBody(body, true)
+ err = req.SetBody(body)
if err != nil {
b.Fatal(err)
}
@@ -59,22 +44,7 @@ func BenchmarkRequestSetBodyBytes(b *testing.B) {
}
for i := 0; i < b.N; i++ {
body := []byte(`{"query":{"match_all":{}}}`)
- err = req.SetBody(body, false)
- if err != nil {
- b.Fatal(err)
- }
- }
- testReq = req
-}
-
-func BenchmarkRequestSetBodyBytesGzip(b *testing.B) {
- req, err := NewRequest("GET", "/")
- if err != nil {
- b.Fatal(err)
- }
- for i := 0; i < b.N; i++ {
- body := []byte(`{"query":{"match_all":{}}}`)
- err = req.SetBody(body, true)
+ err = req.SetBody(body)
if err != nil {
b.Fatal(err)
}
@@ -93,26 +63,7 @@ func BenchmarkRequestSetBodyMap(b *testing.B) {
"match_all": map[string]interface{}{},
},
}
- err = req.SetBody(body, false)
- if err != nil {
- b.Fatal(err)
- }
- }
- testReq = req
-}
-
-func BenchmarkRequestSetBodyMapGzip(b *testing.B) {
- req, err := NewRequest("GET", "/")
- if err != nil {
- b.Fatal(err)
- }
- for i := 0; i < b.N; i++ {
- body := map[string]interface{}{
- "query": map[string]interface{}{
- "match_all": map[string]interface{}{},
- },
- }
- err = req.SetBody(body, true)
+ err = req.SetBody(body)
if err != nil {
b.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/retrier_test.go b/vendor/gopkg.in/olivere/elastic.v5/retrier_test.go
index 100a17838..c1c5ff524 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/retrier_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/retrier_test.go
@@ -65,7 +65,10 @@ func TestRetrier(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -107,7 +110,10 @@ func TestRetrierWithError(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err != kaboom {
t.Fatalf("expected %v, got %v", kaboom, err)
}
@@ -121,3 +127,48 @@ func TestRetrierWithError(t *testing.T) {
t.Errorf("expected %d Retrier calls; got: %d", 1, retrier.N)
}
}
+
+func TestRetrierOnPerformRequest(t *testing.T) {
+ var numFailedReqs int
+ fail := func(r *http.Request) (*http.Response, error) {
+ numFailedReqs += 1
+ //return &http.Response{Request: r, StatusCode: 400}, nil
+ return nil, errors.New("request failed")
+ }
+
+ tr := &failingTransport{path: "/fail", fail: fail}
+ httpClient := &http.Client{Transport: tr}
+
+ defaultRetrier := &testRetrier{
+ Retrier: NewStopRetrier(),
+ }
+ requestRetrier := &testRetrier{
+ Retrier: NewStopRetrier(),
+ }
+
+ client, err := NewClient(
+ SetHttpClient(httpClient),
+ SetHealthcheck(false),
+ SetRetrier(defaultRetrier))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ Retrier: requestRetrier,
+ })
+ if err == nil {
+ t.Fatal("expected error")
+ }
+ if res != nil {
+ t.Fatal("expected no response")
+ }
+ if want, have := int64(0), defaultRetrier.N; want != have {
+ t.Errorf("defaultRetrier: expected %d calls; got: %d", want, have)
+ }
+ if want, have := int64(1), requestRetrier.N; want != have {
+ t.Errorf("requestRetrier: expected %d calls; got: %d", want, have)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.0.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.0.sh
deleted file mode 100755
index e160e3a9b..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.0.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.0.0 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.1.sh
deleted file mode 100755
index 0baf08bfe..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.0.1.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.0.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.1.sh
deleted file mode 100755
index 707d8b769..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.1.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.1.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.2.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.2.sh
deleted file mode 100755
index 94b4a8b25..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.1.2.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.1.2 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.0.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.0.sh
deleted file mode 100755
index a5eae02aa..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.0.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.2.0 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.1.sh
deleted file mode 100755
index c8b390daf..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.1.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.2.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.2.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.2.sh
deleted file mode 100755
index d56b52769..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.2.2.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.2.2 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.3.0.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.3.0.sh
deleted file mode 100755
index ce392a163..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.3.0.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.3.0 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.0.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.0.sh
deleted file mode 100755
index 5b3eb0b5e..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.0.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.4.0 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh
deleted file mode 100755
index 21737cbc5..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.4.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.0.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.0.sh
deleted file mode 100755
index 41749a9ba..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.0.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.5.0 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.1.sh
deleted file mode 100755
index 343a605ba..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.5.1.sh
+++ /dev/null
@@ -1 +0,0 @@
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.5.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.6.3.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.6.3.sh
deleted file mode 100755
index 6a9864668..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.6.3.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-VERSION=5.6.3
-docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/etc:/usr/share/elasticsearch/config" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:$VERSION elasticsearch -Expack.security.enabled=false -Escript.inline=true -Escript.stored=true -Escript.file=true
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es.sh
new file mode 100755
index 000000000..1f4a851d4
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/run-es.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+VERSION=${VERSION:=6.1.2}
+docker run --rm -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:$VERSION elasticsearch -Expack.security.enabled=false -Enetwork.host=_local_,_site_ -Enetwork.publish_host=_local_
diff --git a/vendor/gopkg.in/olivere/elastic.v5/script.go b/vendor/gopkg.in/olivere/elastic.v5/script.go
index b771c0547..273473950 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/script.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/script.go
@@ -9,7 +9,7 @@ import "errors"
// Script holds all the paramaters necessary to compile or find in cache
// and then execute a script.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html
// for details of scripting.
type Script struct {
script string
@@ -22,26 +22,21 @@ type Script struct {
func NewScript(script string) *Script {
return &Script{
script: script,
- typ: "", // default type is "inline"
+ typ: "inline",
params: make(map[string]interface{}),
}
}
-// NewScriptInline creates and initializes a new Script of type "inline".
+// NewScriptInline creates and initializes a new inline script, i.e. code.
func NewScriptInline(script string) *Script {
return NewScript(script).Type("inline")
}
-// NewScriptId creates and initializes a new Script of type "id".
-func NewScriptId(script string) *Script {
+// NewScriptStored creates and initializes a new stored script.
+func NewScriptStored(script string) *Script {
return NewScript(script).Type("id")
}
-// NewScriptFile creates and initializes a new Script of type "file".
-func NewScriptFile(script string) *Script {
- return NewScript(script).Type("file")
-}
-
// Script is either the cache key of the script to be compiled/executed
// or the actual script source code for inline scripts. For indexed
// scripts this is the id used in the request. For file scripts this is
@@ -51,7 +46,7 @@ func (s *Script) Script(script string) *Script {
return s
}
-// Type sets the type of script: "inline", "id", or "file".
+// Type sets the type of script: "inline" or "id".
func (s *Script) Type(typ string) *Script {
s.typ = typ
return s
@@ -60,7 +55,7 @@ func (s *Script) Type(typ string) *Script {
// Lang sets the language of the script. Permitted values are "groovy",
// "expression", "mustache", "mvel" (default), "javascript", "python".
// To use certain languages, you need to configure your server and/or
-// add plugins. See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html
+// add plugins. See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html
// for details.
func (s *Script) Lang(lang string) *Script {
s.lang = lang
@@ -88,10 +83,11 @@ func (s *Script) Source() (interface{}, error) {
return s.script, nil
}
source := make(map[string]interface{})
- if s.typ == "" {
- source["inline"] = s.script
+ // Beginning with 6.0, the type can only be "source" or "id"
+ if s.typ == "" || s.typ == "inline" {
+ source["source"] = s.script
} else {
- source[s.typ] = s.script
+ source["id"] = s.script
}
if s.lang != "" {
source["lang"] = s.lang
diff --git a/vendor/gopkg.in/olivere/elastic.v5/script_test.go b/vendor/gopkg.in/olivere/elastic.v5/script_test.go
index 355e13a06..aa475d7eb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/script_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/script_test.go
@@ -20,7 +20,7 @@ func TestScriptingDefault(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `"doc['field'].value * 2"`
+ expected := `{"source":"doc['field'].value * 2"}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -37,14 +37,14 @@ func TestScriptingInline(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"inline":"doc['field'].value * factor","params":{"factor":2}}`
+ expected := `{"params":{"factor":2},"source":"doc['field'].value * factor"}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
}
-func TestScriptingId(t *testing.T) {
- builder := NewScriptId("script-with-id").Param("factor", 2.0)
+func TestScriptingStored(t *testing.T) {
+ builder := NewScriptStored("script-with-id").Param("factor", 2.0)
src, err := builder.Source()
if err != nil {
t.Fatal(err)
@@ -59,20 +59,3 @@ func TestScriptingId(t *testing.T) {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
}
-
-func TestScriptingFile(t *testing.T) {
- builder := NewScriptFile("script-file").Param("factor", 2.0).Lang("groovy")
- src, err := builder.Source()
- if err != nil {
- t.Fatal(err)
- }
- data, err := json.Marshal(src)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"file":"script-file","lang":"groovy","params":{"factor":2}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/scroll.go b/vendor/gopkg.in/olivere/elastic.v5/scroll.go
index a075ea61f..ac51a8c00 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/scroll.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/scroll.go
@@ -12,7 +12,7 @@ import (
"strings"
"sync"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
const (
@@ -23,6 +23,7 @@ const (
// ScrollService iterates over pages of search results from Elasticsearch.
type ScrollService struct {
client *Client
+ retrier Retrier
indices []string
types []string
keepAlive string
@@ -50,6 +51,13 @@ func NewScrollService(client *Client) *ScrollService {
return builder
}
+// Retrier allows to set specific retry logic for this ScrollService.
+// If not specified, it will use the client's default retrier.
+func (s *ScrollService) Retrier(retrier Retrier) *ScrollService {
+ s.retrier = retrier
+ return s
+}
+
// Index sets the name of one or more indices to iterate over.
func (s *ScrollService) Index(indices ...string) *ScrollService {
if s.indices == nil {
@@ -117,7 +125,7 @@ func (s *ScrollService) Query(query Query) *ScrollService {
// PostFilter is executed as the last filter. It only affects the
// search hits but not facets. See
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-post-filter.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-post-filter.html
// for details.
func (s *ScrollService) PostFilter(postFilter Query) *ScrollService {
s.ss = s.ss.PostFilter(postFilter)
@@ -126,7 +134,7 @@ func (s *ScrollService) PostFilter(postFilter Query) *ScrollService {
// Slice allows slicing the scroll request into several batches.
// This is supported in Elasticsearch 5.0 or later.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html#sliced-scroll
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html#sliced-scroll
// for details.
func (s *ScrollService) Slice(sliceQuery Query) *ScrollService {
s.ss = s.ss.Slice(sliceQuery)
@@ -147,7 +155,7 @@ func (s *ScrollService) FetchSourceContext(fetchSourceContext *FetchSourceContex
}
// Version can be set to true to return a version for each search hit.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-version.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-version.html.
func (s *ScrollService) Version(version bool) *ScrollService {
s.ss = s.ss.Version(version)
return s
@@ -258,7 +266,13 @@ func (s *ScrollService) Clear(ctx context.Context) error {
ScrollId: []string{scrollId},
}
- _, err := s.client.PerformRequest(ctx, "DELETE", path, params, body)
+ _, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ Body: body,
+ Retrier: s.retrier,
+ })
if err != nil {
return err
}
@@ -283,7 +297,13 @@ func (s *ScrollService) first(ctx context.Context) (*SearchResult, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ Retrier: s.retrier,
+ })
if err != nil {
return nil, err
}
@@ -330,7 +350,7 @@ func (s *ScrollService) buildFirstURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.size != nil && *s.size > 0 {
params.Set("size", fmt.Sprintf("%d", *s.size))
@@ -397,7 +417,13 @@ func (s *ScrollService) next(ctx context.Context) (*SearchResult, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ Retrier: s.retrier,
+ })
if err != nil {
return nil, err
}
@@ -423,7 +449,7 @@ func (s *ScrollService) buildNextURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
return path, params, nil
diff --git a/vendor/gopkg.in/olivere/elastic.v5/scroll_test.go b/vendor/gopkg.in/olivere/elastic.v5/scroll_test.go
index 9c9037beb..c94e5f92f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/scroll_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/scroll_test.go
@@ -20,17 +20,17 @@ func TestScroll(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -113,17 +113,17 @@ func TestScrollWithQueryAndSort(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -200,17 +200,17 @@ func TestScrollWithBody(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun.", Retweets: 3}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search.go b/vendor/gopkg.in/olivere/elastic.v5/search.go
index 7121d5545..12d51bf1f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search.go
@@ -12,7 +12,7 @@ import (
"reflect"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// Search for documents in Elasticsearch.
@@ -60,7 +60,7 @@ func (s *SearchService) Source(source interface{}) *SearchService {
// FilterPath allows reducing the response, a mechanism known as
// response filtering and described here:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#common-options-response-filtering.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/common-options.html#common-options-response-filtering.
func (s *SearchService) FilterPath(filterPath ...string) *SearchService {
s.filterPath = append(s.filterPath, filterPath...)
return s
@@ -113,7 +113,7 @@ func (s *SearchService) TimeoutInMillis(timeoutInMillis int) *SearchService {
// SearchType sets the search operation type. Valid values are:
// "query_then_fetch", "query_and_fetch", "dfs_query_then_fetch",
// "dfs_query_and_fetch", "count", "scan".
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-type.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-search-type.html
// for details.
func (s *SearchService) SearchType(searchType string) *SearchService {
s.searchType = searchType
@@ -268,10 +268,17 @@ func (s *SearchService) StoredFields(fields ...string) *SearchService {
return s
}
+// TrackScores is applied when sorting and controls if scores will be
+// tracked as well. Defaults to false.
+func (s *SearchService) TrackScores(trackScores bool) *SearchService {
+ s.searchSource = s.searchSource.TrackScores(trackScores)
+ return s
+}
+
// SearchAfter allows a different form of pagination by using a live cursor,
// using the results of the previous page to help the retrieval of the next.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-after.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-search-after.html
func (s *SearchService) SearchAfter(sortValues ...interface{}) *SearchService {
s.searchSource = s.searchSource.SearchAfter(sortValues...)
return s
@@ -385,7 +392,12 @@ func (s *SearchService) Do(ctx context.Context) (*SearchResult, error) {
}
body = src
}
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -422,7 +434,8 @@ func (r *SearchResult) TotalHits() int64 {
// Each is a utility function to iterate over all hits. It saves you from
// checking for nil values. Notice that Each will ignore errors in
-// serializing JSON.
+// serializing JSON and hits with empty/nil _source will get an empty
+// value
func (r *SearchResult) Each(typ reflect.Type) []interface{} {
if r.Hits == nil || r.Hits.Hits == nil || len(r.Hits.Hits) == 0 {
return nil
@@ -430,6 +443,10 @@ func (r *SearchResult) Each(typ reflect.Type) []interface{} {
var slice []interface{}
for _, hit := range r.Hits.Hits {
v := reflect.New(typ).Elem()
+ if hit.Source == nil {
+ slice = append(slice, v.Interface())
+ continue
+ }
if err := json.Unmarshal(*hit.Source, v.Addr().Interface()); err == nil {
slice = append(slice, v.Interface())
}
@@ -473,7 +490,7 @@ type SearchHitInnerHits struct {
}
// SearchExplanation explains how the score for a hit was computed.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-explain.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-explain.html.
type SearchExplanation struct {
Value float64 `json:"value"` // e.g. 1.0
Description string `json:"description"` // e.g. "boost" or "ConstantScore(*:*), product of:"
@@ -483,11 +500,11 @@ type SearchExplanation struct {
// Suggest
// SearchSuggest is a map of suggestions.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-suggesters.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters.html.
type SearchSuggest map[string][]SearchSuggestion
// SearchSuggestion is a single search suggestion.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-suggesters.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters.html.
type SearchSuggestion struct {
Text string `json:"text"`
Offset int `json:"offset"`
@@ -496,7 +513,7 @@ type SearchSuggestion struct {
}
// SearchSuggestionOption is an option of a SearchSuggestion.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-suggesters.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters.html.
type SearchSuggestionOption struct {
Text string `json:"text"`
Index string `json:"_index"`
@@ -559,6 +576,6 @@ type ProfileResult struct {
// Highlighting
// SearchHitHighlight is the highlight information of a search hit.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-highlighting.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-highlighting.html
// for a general discussion of highlighting.
type SearchHitHighlight map[string][]string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
index a43f8ddcc..c5082b2b1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
@@ -13,7 +13,7 @@ import (
// analytic information over a set of documents. It is
// (in many senses) the follow-up of facets in Elasticsearch.
// For more details about aggregations, visit:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations.html
type Aggregation interface {
// Source returns a JSON-serializable aggregation that is a fragment
// of the request sent to Elasticsearch.
@@ -24,7 +24,7 @@ type Aggregation interface {
type Aggregations map[string]*json.RawMessage
// Min returns min aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-min-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-min-aggregation.html
func (a Aggregations) Min(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -39,7 +39,7 @@ func (a Aggregations) Min(name string) (*AggregationValueMetric, bool) {
}
// Max returns max aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-max-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-max-aggregation.html
func (a Aggregations) Max(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -54,7 +54,7 @@ func (a Aggregations) Max(name string) (*AggregationValueMetric, bool) {
}
// Sum returns sum aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-sum-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-sum-aggregation.html
func (a Aggregations) Sum(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -69,7 +69,7 @@ func (a Aggregations) Sum(name string) (*AggregationValueMetric, bool) {
}
// Avg returns average aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-avg-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-avg-aggregation.html
func (a Aggregations) Avg(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -84,7 +84,7 @@ func (a Aggregations) Avg(name string) (*AggregationValueMetric, bool) {
}
// ValueCount returns value-count aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-valuecount-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-valuecount-aggregation.html
func (a Aggregations) ValueCount(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -99,7 +99,7 @@ func (a Aggregations) ValueCount(name string) (*AggregationValueMetric, bool) {
}
// Cardinality returns cardinality aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-cardinality-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-cardinality-aggregation.html
func (a Aggregations) Cardinality(name string) (*AggregationValueMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationValueMetric)
@@ -114,7 +114,7 @@ func (a Aggregations) Cardinality(name string) (*AggregationValueMetric, bool) {
}
// Stats returns stats aggregation results.
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-stats-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-stats-aggregation.html
func (a Aggregations) Stats(name string) (*AggregationStatsMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationStatsMetric)
@@ -129,7 +129,7 @@ func (a Aggregations) Stats(name string) (*AggregationStatsMetric, bool) {
}
// ExtendedStats returns extended stats aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-extendedstats-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-extendedstats-aggregation.html
func (a Aggregations) ExtendedStats(name string) (*AggregationExtendedStatsMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationExtendedStatsMetric)
@@ -144,7 +144,7 @@ func (a Aggregations) ExtendedStats(name string) (*AggregationExtendedStatsMetri
}
// MatrixStats returns matrix stats aggregation results.
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-matrix-stats-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-matrix-stats-aggregation.html
func (a Aggregations) MatrixStats(name string) (*AggregationMatrixStats, bool) {
if raw, found := a[name]; found {
agg := new(AggregationMatrixStats)
@@ -159,7 +159,7 @@ func (a Aggregations) MatrixStats(name string) (*AggregationMatrixStats, bool) {
}
// Percentiles returns percentiles results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-percentile-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-percentile-aggregation.html
func (a Aggregations) Percentiles(name string) (*AggregationPercentilesMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPercentilesMetric)
@@ -174,7 +174,7 @@ func (a Aggregations) Percentiles(name string) (*AggregationPercentilesMetric, b
}
// PercentileRanks returns percentile ranks results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-percentile-rank-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-percentile-rank-aggregation.html
func (a Aggregations) PercentileRanks(name string) (*AggregationPercentilesMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPercentilesMetric)
@@ -189,7 +189,7 @@ func (a Aggregations) PercentileRanks(name string) (*AggregationPercentilesMetri
}
// TopHits returns top-hits aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-top-hits-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-top-hits-aggregation.html
func (a Aggregations) TopHits(name string) (*AggregationTopHitsMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationTopHitsMetric)
@@ -204,7 +204,7 @@ func (a Aggregations) TopHits(name string) (*AggregationTopHitsMetric, bool) {
}
// Global returns global results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-global-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-global-aggregation.html
func (a Aggregations) Global(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -219,7 +219,7 @@ func (a Aggregations) Global(name string) (*AggregationSingleBucket, bool) {
}
// Filter returns filter results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filter-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-filter-aggregation.html
func (a Aggregations) Filter(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -234,7 +234,7 @@ func (a Aggregations) Filter(name string) (*AggregationSingleBucket, bool) {
}
// Filters returns filters results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filters-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-filters-aggregation.html
func (a Aggregations) Filters(name string) (*AggregationBucketFilters, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketFilters)
@@ -249,7 +249,7 @@ func (a Aggregations) Filters(name string) (*AggregationBucketFilters, bool) {
}
// Missing returns missing results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-missing-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-missing-aggregation.html
func (a Aggregations) Missing(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -264,7 +264,7 @@ func (a Aggregations) Missing(name string) (*AggregationSingleBucket, bool) {
}
// Nested returns nested results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-nested-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-nested-aggregation.html
func (a Aggregations) Nested(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -279,7 +279,7 @@ func (a Aggregations) Nested(name string) (*AggregationSingleBucket, bool) {
}
// ReverseNested returns reverse-nested results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-reverse-nested-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-reverse-nested-aggregation.html
func (a Aggregations) ReverseNested(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -294,7 +294,7 @@ func (a Aggregations) ReverseNested(name string) (*AggregationSingleBucket, bool
}
// Children returns children results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-children-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-children-aggregation.html
func (a Aggregations) Children(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -309,7 +309,7 @@ func (a Aggregations) Children(name string) (*AggregationSingleBucket, bool) {
}
// Terms returns terms aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-terms-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-terms-aggregation.html
func (a Aggregations) Terms(name string) (*AggregationBucketKeyItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketKeyItems)
@@ -324,7 +324,7 @@ func (a Aggregations) Terms(name string) (*AggregationBucketKeyItems, bool) {
}
// SignificantTerms returns significant terms aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html
func (a Aggregations) SignificantTerms(name string) (*AggregationBucketSignificantTerms, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketSignificantTerms)
@@ -339,7 +339,7 @@ func (a Aggregations) SignificantTerms(name string) (*AggregationBucketSignifica
}
// Sampler returns sampler aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-sampler-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-sampler-aggregation.html
func (a Aggregations) Sampler(name string) (*AggregationSingleBucket, bool) {
if raw, found := a[name]; found {
agg := new(AggregationSingleBucket)
@@ -354,7 +354,7 @@ func (a Aggregations) Sampler(name string) (*AggregationSingleBucket, bool) {
}
// Range returns range aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-range-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-range-aggregation.html
func (a Aggregations) Range(name string) (*AggregationBucketRangeItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketRangeItems)
@@ -369,7 +369,7 @@ func (a Aggregations) Range(name string) (*AggregationBucketRangeItems, bool) {
}
// KeyedRange returns keyed range aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-range-aggregation.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-range-aggregation.html.
func (a Aggregations) KeyedRange(name string) (*AggregationBucketKeyedRangeItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketKeyedRangeItems)
@@ -384,7 +384,7 @@ func (a Aggregations) KeyedRange(name string) (*AggregationBucketKeyedRangeItems
}
// DateRange returns date range aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-daterange-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-daterange-aggregation.html
func (a Aggregations) DateRange(name string) (*AggregationBucketRangeItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketRangeItems)
@@ -398,9 +398,9 @@ func (a Aggregations) DateRange(name string) (*AggregationBucketRangeItems, bool
return nil, false
}
-// IPv4Range returns IPv4 range aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-iprange-aggregation.html
-func (a Aggregations) IPv4Range(name string) (*AggregationBucketRangeItems, bool) {
+// IPRange returns IP range aggregation results.
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-iprange-aggregation.html
+func (a Aggregations) IPRange(name string) (*AggregationBucketRangeItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketRangeItems)
if raw == nil {
@@ -414,7 +414,7 @@ func (a Aggregations) IPv4Range(name string) (*AggregationBucketRangeItems, bool
}
// Histogram returns histogram aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-histogram-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-histogram-aggregation.html
func (a Aggregations) Histogram(name string) (*AggregationBucketHistogramItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketHistogramItems)
@@ -429,7 +429,7 @@ func (a Aggregations) Histogram(name string) (*AggregationBucketHistogramItems,
}
// DateHistogram returns date histogram aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-datehistogram-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-datehistogram-aggregation.html
func (a Aggregations) DateHistogram(name string) (*AggregationBucketHistogramItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketHistogramItems)
@@ -444,7 +444,7 @@ func (a Aggregations) DateHistogram(name string) (*AggregationBucketHistogramIte
}
// GeoBounds returns geo-bounds aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-geobounds-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-geobounds-aggregation.html
func (a Aggregations) GeoBounds(name string) (*AggregationGeoBoundsMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationGeoBoundsMetric)
@@ -459,7 +459,7 @@ func (a Aggregations) GeoBounds(name string) (*AggregationGeoBoundsMetric, bool)
}
// GeoHash returns geo-hash aggregation results.
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-geohashgrid-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-geohashgrid-aggregation.html
func (a Aggregations) GeoHash(name string) (*AggregationBucketKeyItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketKeyItems)
@@ -474,7 +474,7 @@ func (a Aggregations) GeoHash(name string) (*AggregationBucketKeyItems, bool) {
}
// GeoDistance returns geo distance aggregation results.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-geodistance-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-geodistance-aggregation.html
func (a Aggregations) GeoDistance(name string) (*AggregationBucketRangeItems, bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketRangeItems)
@@ -489,7 +489,7 @@ func (a Aggregations) GeoDistance(name string) (*AggregationBucketRangeItems, bo
}
// AvgBucket returns average bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-avg-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-avg-bucket-aggregation.html
func (a Aggregations) AvgBucket(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
@@ -504,7 +504,7 @@ func (a Aggregations) AvgBucket(name string) (*AggregationPipelineSimpleValue, b
}
// SumBucket returns sum bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-sum-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-sum-bucket-aggregation.html
func (a Aggregations) SumBucket(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
@@ -519,7 +519,7 @@ func (a Aggregations) SumBucket(name string) (*AggregationPipelineSimpleValue, b
}
// StatsBucket returns stats bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-stats-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-stats-bucket-aggregation.html
func (a Aggregations) StatsBucket(name string) (*AggregationPipelineStatsMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineStatsMetric)
@@ -534,7 +534,7 @@ func (a Aggregations) StatsBucket(name string) (*AggregationPipelineStatsMetric,
}
// PercentilesBucket returns stats bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-percentiles-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-percentiles-bucket-aggregation.html
func (a Aggregations) PercentilesBucket(name string) (*AggregationPipelinePercentilesMetric, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelinePercentilesMetric)
@@ -549,7 +549,7 @@ func (a Aggregations) PercentilesBucket(name string) (*AggregationPipelinePercen
}
// MaxBucket returns maximum bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-max-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-max-bucket-aggregation.html
func (a Aggregations) MaxBucket(name string) (*AggregationPipelineBucketMetricValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineBucketMetricValue)
@@ -564,7 +564,7 @@ func (a Aggregations) MaxBucket(name string) (*AggregationPipelineBucketMetricVa
}
// MinBucket returns minimum bucket pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-min-bucket-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-min-bucket-aggregation.html
func (a Aggregations) MinBucket(name string) (*AggregationPipelineBucketMetricValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineBucketMetricValue)
@@ -579,7 +579,7 @@ func (a Aggregations) MinBucket(name string) (*AggregationPipelineBucketMetricVa
}
// MovAvg returns moving average pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html
func (a Aggregations) MovAvg(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
@@ -594,7 +594,7 @@ func (a Aggregations) MovAvg(name string) (*AggregationPipelineSimpleValue, bool
}
// Derivative returns derivative pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-derivative-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-derivative-aggregation.html
func (a Aggregations) Derivative(name string) (*AggregationPipelineDerivative, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineDerivative)
@@ -609,7 +609,7 @@ func (a Aggregations) Derivative(name string) (*AggregationPipelineDerivative, b
}
// CumulativeSum returns a cumulative sum pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-cumulative-sum-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-cumulative-sum-aggregation.html
func (a Aggregations) CumulativeSum(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
@@ -624,7 +624,7 @@ func (a Aggregations) CumulativeSum(name string) (*AggregationPipelineSimpleValu
}
// BucketScript returns bucket script pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-bucket-script-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-bucket-script-aggregation.html
func (a Aggregations) BucketScript(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
@@ -639,7 +639,7 @@ func (a Aggregations) BucketScript(name string) (*AggregationPipelineSimpleValue
}
// SerialDiff returns serial differencing pipeline aggregation results.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-serialdiff-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-serialdiff-aggregation.html
func (a Aggregations) SerialDiff(name string) (*AggregationPipelineSimpleValue, bool) {
if raw, found := a[name]; found {
agg := new(AggregationPipelineSimpleValue)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_children.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_children.go
index 14d0d1ca9..08623a58e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_children.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_children.go
@@ -7,7 +7,7 @@ package elastic
// ChildrenAggregation is a special single bucket aggregation that enables
// aggregating from buckets on parent document types to buckets on child documents.
// It is available from 1.4.0.Beta1 upwards.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-children-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-children-aggregation.html
type ChildrenAggregation struct {
typ string
subAggregations map[string]Aggregation
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_count_thresholds.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_count_thresholds.go
new file mode 100644
index 000000000..53efdaf5f
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_count_thresholds.go
@@ -0,0 +1,13 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+// BucketCountThresholds is used in e.g. terms and significant text aggregations.
+type BucketCountThresholds struct {
+ MinDocCount *int64
+ ShardMinDocCount *int64
+ RequiredSize *int
+ ShardSize *int
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_histogram.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_histogram.go
index 17916b490..1e7a1246c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_histogram.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_histogram.go
@@ -6,7 +6,7 @@ package elastic
// DateHistogramAggregation is a multi-bucket aggregation similar to the
// histogram except it can only be applied on date values.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-datehistogram-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-datehistogram-aggregation.html
type DateHistogramAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_range.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_range.go
index a4c10aa88..5407dadb8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_range.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_date_range.go
@@ -15,7 +15,7 @@ import (
// date format by which the from and to response fields will be returned.
// Note that this aggregration includes the from value and excludes the to
// value for each range.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-daterange-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-daterange-aggregation.html
type DateRangeAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filter.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filter.go
index 2085f0d36..e4fbc67da 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filter.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filter.go
@@ -8,7 +8,7 @@ package elastic
// in the current document set context that match a specified filter.
// Often this will be used to narrow down the current aggregation context
// to a specific set of documents.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filter-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-filter-aggregation.html
type FilterAggregation struct {
filter Query
subAggregations map[string]Aggregation
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filters.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filters.go
index 80999eed9..0d128ca17 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filters.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_filters.go
@@ -15,7 +15,7 @@ import "errors"
// use both named and unnamed filters.
//
// For details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filters-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-filters-aggregation.html
type FiltersAggregation struct {
unnamedFilters []Query
namedFilters map[string]Query
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_geo_distance.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_geo_distance.go
index 2ae7b63dc..c082fb3f2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_geo_distance.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_geo_distance.go
@@ -11,7 +11,7 @@ package elastic
// the origin point and determines the buckets it belongs to based on
// the ranges (a document belongs to a bucket if the distance between the
// document and the origin falls within the distance range of the bucket).
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-geodistance-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-geodistance-aggregation.html
type GeoDistanceAggregation struct {
field string
unit string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_global.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_global.go
index fbd14a45f..4bf2a63f8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_global.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_global.go
@@ -8,7 +8,7 @@ package elastic
// the search execution context. This context is defined by the indices
// and the document types you’re searching on, but is not influenced
// by the search query itself.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-global-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-global-aggregation.html
type GlobalAggregation struct {
subAggregations map[string]Aggregation
meta map[string]interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_histogram.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_histogram.go
index 30528c164..8b698cff5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_histogram.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_histogram.go
@@ -8,7 +8,7 @@ package elastic
// that can be applied on numeric values extracted from the documents.
// It dynamically builds fixed size (a.k.a. interval) buckets over the
// values.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-histogram-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-histogram-aggregation.html
type HistogramAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range.go
new file mode 100644
index 000000000..3615e29c3
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range.go
@@ -0,0 +1,195 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+// IPRangeAggregation is a range aggregation that is dedicated for
+// IP addresses.
+//
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-iprange-aggregation.html
+type IPRangeAggregation struct {
+ field string
+ subAggregations map[string]Aggregation
+ meta map[string]interface{}
+ keyed *bool
+ entries []IPRangeAggregationEntry
+}
+
+type IPRangeAggregationEntry struct {
+ Key string
+ Mask string
+ From string
+ To string
+}
+
+func NewIPRangeAggregation() *IPRangeAggregation {
+ return &IPRangeAggregation{
+ subAggregations: make(map[string]Aggregation),
+ entries: make([]IPRangeAggregationEntry, 0),
+ }
+}
+
+func (a *IPRangeAggregation) Field(field string) *IPRangeAggregation {
+ a.field = field
+ return a
+}
+
+func (a *IPRangeAggregation) SubAggregation(name string, subAggregation Aggregation) *IPRangeAggregation {
+ a.subAggregations[name] = subAggregation
+ return a
+}
+
+// Meta sets the meta data to be included in the aggregation response.
+func (a *IPRangeAggregation) Meta(metaData map[string]interface{}) *IPRangeAggregation {
+ a.meta = metaData
+ return a
+}
+
+func (a *IPRangeAggregation) Keyed(keyed bool) *IPRangeAggregation {
+ a.keyed = &keyed
+ return a
+}
+
+func (a *IPRangeAggregation) AddMaskRange(mask string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Mask: mask})
+ return a
+}
+
+func (a *IPRangeAggregation) AddMaskRangeWithKey(key, mask string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, Mask: mask})
+ return a
+}
+
+func (a *IPRangeAggregation) AddRange(from, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: from, To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) AddRangeWithKey(key, from, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: from, To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) AddUnboundedTo(from string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: from, To: ""})
+ return a
+}
+
+func (a *IPRangeAggregation) AddUnboundedToWithKey(key, from string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: from, To: ""})
+ return a
+}
+
+func (a *IPRangeAggregation) AddUnboundedFrom(to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: "", To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) AddUnboundedFromWithKey(key, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: "", To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) Lt(to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: "", To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) LtWithKey(key, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: "", To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) Between(from, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: from, To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) BetweenWithKey(key, from, to string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: from, To: to})
+ return a
+}
+
+func (a *IPRangeAggregation) Gt(from string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{From: from, To: ""})
+ return a
+}
+
+func (a *IPRangeAggregation) GtWithKey(key, from string) *IPRangeAggregation {
+ a.entries = append(a.entries, IPRangeAggregationEntry{Key: key, From: from, To: ""})
+ return a
+}
+
+func (a *IPRangeAggregation) Source() (interface{}, error) {
+ // Example:
+ // {
+ // "aggs" : {
+ // "range" : {
+ // "ip_range": {
+ // "field": "ip",
+ // "ranges": [
+ // { "to": "10.0.0.5" },
+ // { "from": "10.0.0.5" }
+ // ]
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // This method returns only the { "ip_range" : { ... } } part.
+
+ source := make(map[string]interface{})
+ opts := make(map[string]interface{})
+ source["ip_range"] = opts
+
+ // ValuesSourceAggregationBuilder
+ if a.field != "" {
+ opts["field"] = a.field
+ }
+
+ if a.keyed != nil {
+ opts["keyed"] = *a.keyed
+ }
+
+ var ranges []interface{}
+ for _, ent := range a.entries {
+ r := make(map[string]interface{})
+ if ent.Key != "" {
+ r["key"] = ent.Key
+ }
+ if ent.Mask != "" {
+ r["mask"] = ent.Mask
+ } else {
+ if ent.From != "" {
+ r["from"] = ent.From
+ }
+ if ent.To != "" {
+ r["to"] = ent.To
+ }
+ }
+ ranges = append(ranges, r)
+ }
+ opts["ranges"] = ranges
+
+ // AggregationBuilder (SubAggregations)
+ if len(a.subAggregations) > 0 {
+ aggsMap := make(map[string]interface{})
+ source["aggregations"] = aggsMap
+ for name, aggregate := range a.subAggregations {
+ src, err := aggregate.Source()
+ if err != nil {
+ return nil, err
+ }
+ aggsMap[name] = src
+ }
+ }
+
+ // Add Meta data if available
+ if len(a.meta) > 0 {
+ source["meta"] = a.meta
+ }
+
+ return source, nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range_test.go
new file mode 100644
index 000000000..7a2b49f4c
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_ip_range_test.go
@@ -0,0 +1,90 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestIPRangeAggregation(t *testing.T) {
+ agg := NewIPRangeAggregation().Field("remote_ip")
+ agg = agg.AddRange("", "10.0.0.0")
+ agg = agg.AddRange("10.1.0.0", "10.1.255.255")
+ agg = agg.AddRange("10.2.0.0", "")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"ip_range":{"field":"remote_ip","ranges":[{"to":"10.0.0.0"},{"from":"10.1.0.0","to":"10.1.255.255"},{"from":"10.2.0.0"}]}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestIPRangeAggregationMask(t *testing.T) {
+ agg := NewIPRangeAggregation().Field("remote_ip")
+ agg = agg.AddMaskRange("10.0.0.0/25")
+ agg = agg.AddMaskRange("10.0.0.127/25")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"ip_range":{"field":"remote_ip","ranges":[{"mask":"10.0.0.0/25"},{"mask":"10.0.0.127/25"}]}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestIPRangeAggregationWithKeyedFlag(t *testing.T) {
+ agg := NewIPRangeAggregation().Field("remote_ip")
+ agg = agg.Keyed(true)
+ agg = agg.AddRange("", "10.0.0.0")
+ agg = agg.AddRange("10.1.0.0", "10.1.255.255")
+ agg = agg.AddRange("10.2.0.0", "")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"ip_range":{"field":"remote_ip","keyed":true,"ranges":[{"to":"10.0.0.0"},{"from":"10.1.0.0","to":"10.1.255.255"},{"from":"10.2.0.0"}]}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestIPRangeAggregationWithKeys(t *testing.T) {
+ agg := NewIPRangeAggregation().Field("remote_ip")
+ agg = agg.Keyed(true)
+ agg = agg.LtWithKey("infinity", "10.0.0.5")
+ agg = agg.GtWithKey("and-beyond", "10.0.0.5")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"ip_range":{"field":"remote_ip","keyed":true,"ranges":[{"key":"infinity","to":"10.0.0.5"},{"from":"10.0.0.5","key":"and-beyond"}]}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_missing.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_missing.go
index 3ca3fd693..7ba3cb636 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_missing.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_missing.go
@@ -11,7 +11,7 @@ package elastic
// conjunction with other field data bucket aggregators (such as ranges)
// to return information for all the documents that could not be placed
// in any of the other buckets due to missing field data values.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-missing-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-missing-aggregation.html
type MissingAggregation struct {
field string
subAggregations map[string]Aggregation
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_nested.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_nested.go
index 62e592eb8..926d493a1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_nested.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_nested.go
@@ -6,7 +6,7 @@ package elastic
// NestedAggregation is a special single bucket aggregation that enables
// aggregating nested documents.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-nested-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-nested-aggregation.html
type NestedAggregation struct {
path string
subAggregations map[string]Aggregation
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_range.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_range.go
index 1c5204a0b..28c3df78e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_range.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_range.go
@@ -14,7 +14,7 @@ import (
// will be checked against each bucket range and "bucket" the
// relevant/matching document. Note that this aggregration includes the
// from value and excludes the to value for each range.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-range-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-range-aggregation.html
type RangeAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_reverse_nested.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_reverse_nested.go
index f307f256f..9e4680195 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_reverse_nested.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_reverse_nested.go
@@ -11,7 +11,7 @@ package elastic
// which allows nesting other aggregations that aren’t part of
// the nested object in a nested aggregation.
//
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-reverse-nested-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-reverse-nested-aggregation.html
type ReverseNestedAggregation struct {
path string
subAggregations map[string]Aggregation
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_sampler.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_sampler.go
index c1a1ab4f7..0fd729dfd 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_sampler.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_sampler.go
@@ -9,7 +9,7 @@ package elastic
// Optionally, diversity settings can be used to limit the number of matches
// that share a common value such as an "author".
//
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-sampler-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-sampler-aggregation.html
type SamplerAggregation struct {
subAggregations map[string]Aggregation
meta map[string]interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms.go
index e03801f1e..571a91217 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms.go
@@ -4,9 +4,9 @@
package elastic
-// SignificantSignificantTermsAggregation is an aggregation that returns interesting
+// SignificantTermsAggregation is an aggregation that returns interesting
// or unusual occurrences of terms in a set.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html
type SignificantTermsAggregation struct {
field string
subAggregations map[string]Aggregation
@@ -166,7 +166,7 @@ type SignificanceHeuristic interface {
// ChiSquareSignificanceHeuristic implements Chi square as described
// in "Information Retrieval", Manning et al., Chapter 13.5.2.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_chi_square
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_chi_square
// for details.
type ChiSquareSignificanceHeuristic struct {
backgroundIsSuperset *bool
@@ -216,7 +216,7 @@ func (sh *ChiSquareSignificanceHeuristic) Source() (interface{}, error) {
// as described in "The Google Similarity Distance", Cilibrasi and Vitanyi,
// 2007.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_google_normalized_distance
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_google_normalized_distance
// for details.
type GNDSignificanceHeuristic struct {
backgroundIsSuperset *bool
@@ -252,7 +252,7 @@ func (sh *GNDSignificanceHeuristic) Source() (interface{}, error) {
// -- JLH Score --
// JLHScoreSignificanceHeuristic implements the JLH score as described in
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_jlh_score.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_jlh_score.
type JLHScoreSignificanceHeuristic struct{}
// NewJLHScoreSignificanceHeuristic initializes a new JLHScoreSignificanceHeuristic.
@@ -276,7 +276,7 @@ func (sh *JLHScoreSignificanceHeuristic) Source() (interface{}, error) {
// MutualInformationSignificanceHeuristic implements Mutual information
// as described in "Information Retrieval", Manning et al., Chapter 13.5.1.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_mutual_information
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_mutual_information
// for details.
type MutualInformationSignificanceHeuristic struct {
backgroundIsSuperset *bool
@@ -324,7 +324,7 @@ func (sh *MutualInformationSignificanceHeuristic) Source() (interface{}, error)
// -- Percentage Score --
// PercentageScoreSignificanceHeuristic implements the algorithm described
-// in https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_percentage.
+// in https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_percentage.
type PercentageScoreSignificanceHeuristic struct{}
// NewPercentageScoreSignificanceHeuristic initializes a new instance of
@@ -347,7 +347,7 @@ func (sh *PercentageScoreSignificanceHeuristic) Source() (interface{}, error) {
// -- Script --
// ScriptSignificanceHeuristic implements a scripted significance heuristic.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_scripted
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_scripted
// for details.
type ScriptSignificanceHeuristic struct {
script *Script
@@ -368,7 +368,7 @@ func (sh *ScriptSignificanceHeuristic) Name() string {
// parameters are available in the script: `_subset_freq`, `_superset_freq`,
// `_subset_size`, and `_superset_size`.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-significantterms-aggregation.html#_scripted
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significantterms-aggregation.html#_scripted
// for details.
func (sh *ScriptSignificanceHeuristic) Script(script *Script) *ScriptSignificanceHeuristic {
sh.script = script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms_test.go
index 2f87373d7..a5b269671 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_terms_test.go
@@ -204,7 +204,7 @@ func TestSignificantTermsAggregationWithScript(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"significant_terms":{"field":"crime_type","script_heuristic":{"script":"_subset_freq/(_superset_freq - _subset_freq + 1)"}}}`
+ expected := `{"significant_terms":{"field":"crime_type","script_heuristic":{"script":{"source":"_subset_freq/(_superset_freq - _subset_freq + 1)"}}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text.go
new file mode 100644
index 000000000..de761613c
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text.go
@@ -0,0 +1,245 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+// SignificantTextAggregation returns interesting or unusual occurrences
+// of free-text terms in a set.
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-bucket-significanttext-aggregation.html
+type SignificantTextAggregation struct {
+ field string
+ subAggregations map[string]Aggregation
+ meta map[string]interface{}
+
+ sourceFieldNames []string
+ filterDuplicateText *bool
+ includeExclude *TermsAggregationIncludeExclude
+ filter Query
+ bucketCountThresholds *BucketCountThresholds
+ significanceHeuristic SignificanceHeuristic
+}
+
+func NewSignificantTextAggregation() *SignificantTextAggregation {
+ return &SignificantTextAggregation{
+ subAggregations: make(map[string]Aggregation, 0),
+ }
+}
+
+func (a *SignificantTextAggregation) Field(field string) *SignificantTextAggregation {
+ a.field = field
+ return a
+}
+
+func (a *SignificantTextAggregation) SubAggregation(name string, subAggregation Aggregation) *SignificantTextAggregation {
+ a.subAggregations[name] = subAggregation
+ return a
+}
+
+// Meta sets the meta data to be included in the aggregation response.
+func (a *SignificantTextAggregation) Meta(metaData map[string]interface{}) *SignificantTextAggregation {
+ a.meta = metaData
+ return a
+}
+
+func (a *SignificantTextAggregation) SourceFieldNames(names ...string) *SignificantTextAggregation {
+ a.sourceFieldNames = names
+ return a
+}
+
+func (a *SignificantTextAggregation) FilterDuplicateText(filter bool) *SignificantTextAggregation {
+ a.filterDuplicateText = &filter
+ return a
+}
+
+func (a *SignificantTextAggregation) MinDocCount(minDocCount int64) *SignificantTextAggregation {
+ if a.bucketCountThresholds == nil {
+ a.bucketCountThresholds = &BucketCountThresholds{}
+ }
+ a.bucketCountThresholds.MinDocCount = &minDocCount
+ return a
+}
+
+func (a *SignificantTextAggregation) ShardMinDocCount(shardMinDocCount int64) *SignificantTextAggregation {
+ if a.bucketCountThresholds == nil {
+ a.bucketCountThresholds = &BucketCountThresholds{}
+ }
+ a.bucketCountThresholds.ShardMinDocCount = &shardMinDocCount
+ return a
+}
+
+func (a *SignificantTextAggregation) Size(size int) *SignificantTextAggregation {
+ if a.bucketCountThresholds == nil {
+ a.bucketCountThresholds = &BucketCountThresholds{}
+ }
+ a.bucketCountThresholds.RequiredSize = &size
+ return a
+}
+
+func (a *SignificantTextAggregation) ShardSize(shardSize int) *SignificantTextAggregation {
+ if a.bucketCountThresholds == nil {
+ a.bucketCountThresholds = &BucketCountThresholds{}
+ }
+ a.bucketCountThresholds.ShardSize = &shardSize
+ return a
+}
+
+func (a *SignificantTextAggregation) BackgroundFilter(filter Query) *SignificantTextAggregation {
+ a.filter = filter
+ return a
+}
+
+func (a *SignificantTextAggregation) SignificanceHeuristic(heuristic SignificanceHeuristic) *SignificantTextAggregation {
+ a.significanceHeuristic = heuristic
+ return a
+}
+
+func (a *SignificantTextAggregation) Include(regexp string) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.Include = regexp
+ return a
+}
+
+func (a *SignificantTextAggregation) IncludeValues(values ...interface{}) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.IncludeValues = append(a.includeExclude.IncludeValues, values...)
+ return a
+}
+
+func (a *SignificantTextAggregation) Exclude(regexp string) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.Exclude = regexp
+ return a
+}
+
+func (a *SignificantTextAggregation) ExcludeValues(values ...interface{}) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.ExcludeValues = append(a.includeExclude.ExcludeValues, values...)
+ return a
+}
+
+func (a *SignificantTextAggregation) Partition(p int) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.Partition = p
+ return a
+}
+
+func (a *SignificantTextAggregation) NumPartitions(n int) *SignificantTextAggregation {
+ if a.includeExclude == nil {
+ a.includeExclude = &TermsAggregationIncludeExclude{}
+ }
+ a.includeExclude.NumPartitions = n
+ return a
+}
+
+func (a *SignificantTextAggregation) Source() (interface{}, error) {
+ // Example:
+ // {
+ // "query" : {
+ // "match" : {"content" : "Bird flu"}
+ // },
+ // "aggregations" : {
+ // "my_sample" : {
+ // "sampler": {
+ // "shard_size" : 100
+ // },
+ // "aggregations": {
+ // "keywords" : {
+ // "significant_text" : { "field" : "content" }
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // This method returns only the
+ // { "significant_text" : { "field" : "content" }
+ // part.
+
+ source := make(map[string]interface{})
+ opts := make(map[string]interface{})
+ source["significant_text"] = opts
+
+ if a.field != "" {
+ opts["field"] = a.field
+ }
+ if a.bucketCountThresholds != nil {
+ if a.bucketCountThresholds.RequiredSize != nil {
+ opts["size"] = (*a.bucketCountThresholds).RequiredSize
+ }
+ if a.bucketCountThresholds.ShardSize != nil {
+ opts["shard_size"] = (*a.bucketCountThresholds).ShardSize
+ }
+ if a.bucketCountThresholds.MinDocCount != nil {
+ opts["min_doc_count"] = (*a.bucketCountThresholds).MinDocCount
+ }
+ if a.bucketCountThresholds.ShardMinDocCount != nil {
+ opts["shard_min_doc_count"] = (*a.bucketCountThresholds).ShardMinDocCount
+ }
+ }
+ if a.filter != nil {
+ src, err := a.filter.Source()
+ if err != nil {
+ return nil, err
+ }
+ opts["background_filter"] = src
+ }
+ if a.significanceHeuristic != nil {
+ name := a.significanceHeuristic.Name()
+ src, err := a.significanceHeuristic.Source()
+ if err != nil {
+ return nil, err
+ }
+ opts[name] = src
+ }
+ // Include/Exclude
+ if ie := a.includeExclude; ie != nil {
+ // Include
+ if ie.Include != "" {
+ opts["include"] = ie.Include
+ } else if len(ie.IncludeValues) > 0 {
+ opts["include"] = ie.IncludeValues
+ } else if ie.NumPartitions > 0 {
+ inc := make(map[string]interface{})
+ inc["partition"] = ie.Partition
+ inc["num_partitions"] = ie.NumPartitions
+ opts["include"] = inc
+ }
+ // Exclude
+ if ie.Exclude != "" {
+ opts["exclude"] = ie.Exclude
+ } else if len(ie.ExcludeValues) > 0 {
+ opts["exclude"] = ie.ExcludeValues
+ }
+ }
+
+ // AggregationBuilder (SubAggregations)
+ if len(a.subAggregations) > 0 {
+ aggsMap := make(map[string]interface{})
+ source["aggregations"] = aggsMap
+ for name, aggregate := range a.subAggregations {
+ src, err := aggregate.Source()
+ if err != nil {
+ return nil, err
+ }
+ aggsMap[name] = src
+ }
+ }
+
+ // Add Meta data if available
+ if len(a.meta) > 0 {
+ source["meta"] = a.meta
+ }
+
+ return source, nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text_test.go
new file mode 100644
index 000000000..53ac4461d
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_bucket_significant_text_test.go
@@ -0,0 +1,66 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestSignificantTextAggregation(t *testing.T) {
+ agg := NewSignificantTextAggregation().Field("content")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"significant_text":{"field":"content"}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestSignificantTextAggregationWithArgs(t *testing.T) {
+ agg := NewSignificantTextAggregation().
+ Field("content").
+ ShardSize(5).
+ MinDocCount(10).
+ BackgroundFilter(NewTermQuery("city", "London"))
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"significant_text":{"background_filter":{"term":{"city":"London"}},"field":"content","min_doc_count":10,"shard_size":5}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestSignificantTextAggregationWithMetaData(t *testing.T) {
+ agg := NewSignificantTextAggregation().Field("content")
+ agg = agg.Meta(map[string]interface{}{"name": "Oliver"})
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"meta":{"name":"Oliver"},"significant_text":{"field":"content"}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_matrix_stats.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_matrix_stats.go
index 875da0718..785f392b6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_matrix_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_matrix_stats.go
@@ -5,7 +5,7 @@
package elastic
// MatrixMatrixStatsAggregation ...
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-aggregations-metrics-stats-aggregation.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-stats-aggregation.html
// for details.
type MatrixStatsAggregation struct {
fields []string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_avg.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_avg.go
index ff337a8cd..2b764e065 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_avg.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_avg.go
@@ -9,7 +9,7 @@ package elastic
// aggregated documents. These values can be extracted either from
// specific numeric fields in the documents, or be generated by
// a provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-avg-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-avg-aggregation.html
type AvgAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_cardinality.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_cardinality.go
index 8f6f447c4..3b999c849 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_cardinality.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_cardinality.go
@@ -8,7 +8,7 @@ package elastic
// calculates an approximate count of distinct values.
// Values can be extracted either from specific fields in the document
// or generated by a script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-cardinality-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-cardinality-aggregation.html
type CardinalityAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_extended_stats.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_extended_stats.go
index 95b312686..4e0bbe65a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_extended_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_extended_stats.go
@@ -8,7 +8,7 @@ package elastic
// computes stats over numeric values extracted from the aggregated documents.
// These values can be extracted either from specific numeric fields
// in the documents, or be generated by a provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-extendedstats-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-extendedstats-aggregation.html
type ExtendedStatsAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_geo_bounds.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_geo_bounds.go
index c263a76b4..406f2d000 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_geo_bounds.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_geo_bounds.go
@@ -6,7 +6,7 @@ package elastic
// GeoBoundsAggregation is a metric aggregation that computes the
// bounding box containing all geo_point values for a field.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-geobounds-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-geobounds-aggregation.html
type GeoBoundsAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_max.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_max.go
index b62130676..acdfa14a8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_max.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_max.go
@@ -9,7 +9,7 @@ package elastic
// the aggregated documents. These values can be extracted either from
// specific numeric fields in the documents, or be generated by
// a provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-max-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-max-aggregation.html
type MaxAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_min.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_min.go
index c1ca6922b..af63585da 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_min.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_min.go
@@ -9,7 +9,7 @@ package elastic
// aggregated documents. These values can be extracted either from
// specific numeric fields in the documents, or be generated by a
// provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-min-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-min-aggregation.html
type MinAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentile_ranks.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentile_ranks.go
index 3e0595e88..674fc41f9 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentile_ranks.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentile_ranks.go
@@ -5,7 +5,7 @@
package elastic
// PercentileRanksAggregation
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-percentile-rank-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-percentile-rank-aggregation.html
type PercentileRanksAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentiles.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentiles.go
index 411f9c50f..a1d78c8f2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentiles.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_percentiles.go
@@ -5,7 +5,7 @@
package elastic
// PercentilesAggregation
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-percentile-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-percentile-aggregation.html
type PercentilesAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_stats.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_stats.go
index 400b79b00..b9bbe7cff 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_stats.go
@@ -8,7 +8,7 @@ package elastic
// over numeric values extracted from the aggregated documents.
// These values can be extracted either from specific numeric fields
// in the documents, or be generated by a provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-stats-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-stats-aggregation.html
type StatsAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_sum.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_sum.go
index f959a3e54..e1c07c9c1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_sum.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_sum.go
@@ -8,7 +8,7 @@ package elastic
// numeric values that are extracted from the aggregated documents.
// These values can be extracted either from specific numeric fields
// in the documents, or be generated by a provided script.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-sum-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-sum-aggregation.html
type SumAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_top_hits.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_top_hits.go
index 43dd36cdb..2b181895e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_top_hits.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_top_hits.go
@@ -13,7 +13,7 @@ package elastic
// a bucket aggregator. One or more bucket aggregators determines by
// which properties a result set get sliced into.
//
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-top-hits-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-top-hits-aggregation.html
type TopHitsAggregation struct {
searchSource *SearchSource
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_value_count.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_value_count.go
index 4e7281d62..d56f1f873 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_value_count.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_metrics_value_count.go
@@ -11,7 +11,7 @@ package elastic
// used in conjunction with other single-value aggregations.
// For example, when computing the avg one might be interested in the
// number of values the average is computed over.
-// See: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-metrics-valuecount-aggregation.html
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-metrics-valuecount-aggregation.html
type ValueCountAggregation struct {
field string
script *Script
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_avg_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_avg_bucket.go
index 7eea9310d..f37a9bdb8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_avg_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_avg_bucket.go
@@ -10,7 +10,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-avg-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-avg-bucket-aggregation.html
type AvgBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script.go
index 13cad638f..34e356964 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script.go
@@ -10,7 +10,7 @@ package elastic
// numeric and the script must return a numeric value.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-bucket-script-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-bucket-script-aggregation.html
type BucketScriptAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script_test.go
index b4e6bf1c0..3c101c706 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_script_test.go
@@ -23,7 +23,7 @@ func TestBucketScriptAggregation(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"bucket_script":{"buckets_path":{"tShirtSales":"t-shirts\u003esales","totalSales":"total_sales"},"script":"tShirtSales / totalSales * 100"}}`
+ expected := `{"bucket_script":{"buckets_path":{"tShirtSales":"t-shirts\u003esales","totalSales":"total_sales"},"script":{"source":"tShirtSales / totalSales * 100"}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector.go
index f3c938519..233414d70 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector.go
@@ -12,7 +12,7 @@ package elastic
// will be evaluated as false and all other values will evaluate to true.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-bucket-selector-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-bucket-selector-aggregation.html
type BucketSelectorAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector_test.go
index dd276a867..e378c2832 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_bucket_selector_test.go
@@ -22,7 +22,7 @@ func TestBucketSelectorAggregation(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"bucket_selector":{"buckets_path":{"totalSales":"total_sales"},"script":"totalSales \u003e= 1000"}}`
+ expected := `{"bucket_selector":{"buckets_path":{"totalSales":"total_sales"},"script":{"source":"totalSales \u003e= 1000"}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_cumulative_sum.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_cumulative_sum.go
index 95546f1cb..80a1db42d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_cumulative_sum.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_cumulative_sum.go
@@ -10,7 +10,7 @@ package elastic
// histogram must have min_doc_count set to 0 (default for histogram aggregations).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-cumulative-sum-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-cumulative-sum-aggregation.html
type CumulativeSumAggregation struct {
format string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_derivative.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_derivative.go
index 2c3c7e03a..ee7114e25 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_derivative.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_derivative.go
@@ -10,7 +10,7 @@ package elastic
// histogram must have min_doc_count set to 0 (default for histogram aggregations).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-derivative-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-derivative-aggregation.html
type DerivativeAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_max_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_max_bucket.go
index 5a10b0e45..5da049561 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_max_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_max_bucket.go
@@ -11,7 +11,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-max-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-max-bucket-aggregation.html
type MaxBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_min_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_min_bucket.go
index 96982250c..463bb919e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_min_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_min_bucket.go
@@ -11,7 +11,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-min-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-min-bucket-aggregation.html
type MinBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_mov_avg.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_mov_avg.go
index cf94342f7..821d73842 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_mov_avg.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_mov_avg.go
@@ -8,7 +8,7 @@ package elastic
// across the data and emit the average value of that window.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html
type MovAvgAggregation struct {
format string
gapPolicy string
@@ -162,7 +162,7 @@ func (a *MovAvgAggregation) Source() (interface{}, error) {
}
// -- Models for moving averages --
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_models
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_models
// MovAvgModel specifies the model to use with the MovAvgAggregation.
type MovAvgModel interface {
@@ -175,7 +175,7 @@ type MovAvgModel interface {
// EWMAMovAvgModel calculates an exponentially weighted moving average.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_ewma_exponentially_weighted
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_ewma_exponentially_weighted
type EWMAMovAvgModel struct {
alpha *float64
}
@@ -213,7 +213,7 @@ func (m *EWMAMovAvgModel) Settings() map[string]interface{} {
// HoltLinearMovAvgModel calculates a doubly exponential weighted moving average.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_holt_linear
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_holt_linear
type HoltLinearMovAvgModel struct {
alpha *float64
beta *float64
@@ -262,7 +262,7 @@ func (m *HoltLinearMovAvgModel) Settings() map[string]interface{} {
// HoltWintersMovAvgModel calculates a triple exponential weighted moving average.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_holt_winters
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_holt_winters
type HoltWintersMovAvgModel struct {
alpha *float64
beta *float64
@@ -349,7 +349,7 @@ func (m *HoltWintersMovAvgModel) Settings() map[string]interface{} {
// by position in collection.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_linear
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_linear
type LinearMovAvgModel struct {
}
@@ -373,7 +373,7 @@ func (m *LinearMovAvgModel) Settings() map[string]interface{} {
// SimpleMovAvgModel calculates a simple unweighted (arithmetic) moving average.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-movavg-aggregation.html#_simple
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-movavg-aggregation.html#_simple
type SimpleMovAvgModel struct {
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go
index 4caca7432..9a3556269 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go
@@ -10,7 +10,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-percentiles-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-percentiles-bucket-aggregation.html
type PercentilesBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_serial_diff.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_serial_diff.go
index 84ae43004..e13b94ea9 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_serial_diff.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_serial_diff.go
@@ -9,7 +9,7 @@ package elastic
// subtracted from itself at different time lags or periods.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-serialdiff-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-serialdiff-aggregation.html
type SerialDiffAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_stats_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_stats_bucket.go
index fb0a94afc..e68a420f2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_stats_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_stats_bucket.go
@@ -10,7 +10,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-stats-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-stats-bucket-aggregation.html
type StatsBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_sum_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_sum_bucket.go
index 1f78efa56..c22ae8f50 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_sum_bucket.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_sum_bucket.go
@@ -10,7 +10,7 @@ package elastic
// be a multi-bucket aggregation.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-sum-bucket-aggregation.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-aggregations-pipeline-sum-bucket-aggregation.html
type SumBucketAggregation struct {
format string
gapPolicy string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_test.go
index 058257774..24dd4eb0f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_test.go
@@ -13,20 +13,10 @@ func TestAggsIntegrationAvgBucket(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -66,20 +56,10 @@ func TestAggsIntegrationDerivative(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -207,20 +187,10 @@ func TestAggsIntegrationMaxBucket(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -266,20 +236,10 @@ func TestAggsIntegrationMinBucket(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -325,20 +285,10 @@ func TestAggsIntegrationSumBucket(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -378,20 +328,10 @@ func TestAggsIntegrationMovAvg(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -500,20 +440,10 @@ func TestAggsIntegrationCumulativeSum(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -650,22 +580,13 @@ func TestAggsIntegrationCumulativeSum(t *testing.T) {
}
func TestAggsIntegrationBucketScript(t *testing.T) {
- client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
-
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
+ // client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
+ client := setupTestClientAndCreateIndexAndAddDocs(t)
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -810,20 +731,10 @@ func TestAggsIntegrationBucketSelector(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
@@ -870,20 +781,10 @@ func TestAggsIntegrationSerialDiff(t *testing.T) {
//client := setupTestClientAndCreateIndexAndAddDocs(t, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
client := setupTestClientAndCreateIndexAndAddDocs(t)
- esversion, err := client.ElasticsearchVersion(DefaultURL)
- if err != nil {
- t.Fatal(err)
- }
-
- if esversion < "2.0" {
- t.Skipf("Elasticsearch %s does not have pipeline aggregations.", esversion)
- return
- }
-
// Match all should return all documents
builder := client.Search().
- Index(testIndexName).
- Type("order").
+ Index(testOrderIndex).
+ Type("doc").
Query(NewMatchAllQuery()).
Pretty(true)
h := NewDateHistogramAggregation().Field("time").Interval("month")
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
index c730e3b43..9d6fa8d27 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
@@ -48,17 +48,17 @@ func TestAggs(t *testing.T) {
}
// Add all documents
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -1000,7 +1000,7 @@ func TestAggsMarshal(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -2420,7 +2420,7 @@ func TestAggsBucketDateRange(t *testing.T) {
}
}
-func TestAggsBucketIPv4Range(t *testing.T) {
+func TestAggsBucketIPRange(t *testing.T) {
s := `{
"ip_ranges": {
"buckets" : [
@@ -2444,7 +2444,7 @@ func TestAggsBucketIPv4Range(t *testing.T) {
t.Fatalf("expected no error decoding; got: %v", err)
}
- agg, found := aggs.IPv4Range("ip_ranges")
+ agg, found := aggs.IPRange("ip_ranges")
if !found {
t.Fatalf("expected aggregation to be found; got: %v", found)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_collapse_builder.go b/vendor/gopkg.in/olivere/elastic.v5/search_collapse_builder.go
index 48ed17acb..b3c628ba3 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_collapse_builder.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_collapse_builder.go
@@ -5,7 +5,7 @@
package elastic
// CollapseBuilder enables field collapsing on a search request.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-request-collapse.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-collapse.html
// for details.
type CollapseBuilder struct {
field string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool.go
index 8ae223834..a1ff17596 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool.go
@@ -9,7 +9,7 @@ import "fmt"
// A bool query matches documents matching boolean
// combinations of other queries.
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-bool-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-bool-query.html
type BoolQuery struct {
Query
mustClauses []Query
@@ -17,7 +17,6 @@ type BoolQuery struct {
filterClauses []Query
shouldClauses []Query
boost *float64
- disableCoord *bool
minimumShouldMatch string
adjustPureNegative *bool
queryName string
@@ -58,11 +57,6 @@ func (q *BoolQuery) Boost(boost float64) *BoolQuery {
return q
}
-func (q *BoolQuery) DisableCoord(disableCoord bool) *BoolQuery {
- q.disableCoord = &disableCoord
- return q
-}
-
func (q *BoolQuery) MinimumShouldMatch(minimumShouldMatch string) *BoolQuery {
q.minimumShouldMatch = minimumShouldMatch
return q
@@ -106,7 +100,7 @@ func (q *BoolQuery) Source() (interface{}, error) {
// "term" : { "tag" : "elasticsearch" }
// }
// ],
- // "minimum_number_should_match" : 1,
+ // "minimum_should_match" : 1,
// "boost" : 1.0
// }
// }
@@ -195,9 +189,6 @@ func (q *BoolQuery) Source() (interface{}, error) {
if q.boost != nil {
boolClause["boost"] = *q.boost
}
- if q.disableCoord != nil {
- boolClause["disable_coord"] = *q.disableCoord
- }
if q.minimumShouldMatch != "" {
boolClause["minimum_should_match"] = q.minimumShouldMatch
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool_test.go
index 1eb2038fd..cdcc38de1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_bool_test.go
@@ -16,7 +16,6 @@ func TestBoolQuery(t *testing.T) {
q = q.Filter(NewTermQuery("account", "1"))
q = q.Should(NewTermQuery("tag", "sometag"), NewTermQuery("tag", "sometagtag"))
q = q.Boost(10)
- q = q.DisableCoord(true)
q = q.QueryName("Test")
src, err := q.Source()
if err != nil {
@@ -27,7 +26,7 @@ func TestBoolQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"bool":{"_name":"Test","boost":10,"disable_coord":true,"filter":{"term":{"account":"1"}},"must":{"term":{"tag":"wow"}},"must_not":{"range":{"age":{"from":10,"include_lower":true,"include_upper":true,"to":20}}},"should":[{"term":{"tag":"sometag"}},{"term":{"tag":"sometagtag"}}]}}`
+ expected := `{"bool":{"_name":"Test","boost":10,"filter":{"term":{"account":"1"}},"must":{"term":{"tag":"wow"}},"must_not":{"range":{"age":{"from":10,"include_lower":true,"include_upper":true,"to":20}}},"should":[{"term":{"tag":"sometag"}},{"term":{"tag":"sometagtag"}}]}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_boosting.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_boosting.go
index 3a31237c9..0060a30a8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_boosting.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_boosting.go
@@ -7,7 +7,7 @@ package elastic
// A boosting query can be used to effectively
// demote results that match a given query.
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-boosting-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-boosting-query.html
type BoostingQuery struct {
Query
positiveClause Query
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms.go
index a1a37b37c..93a03de54 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms.go
@@ -8,7 +8,7 @@ package elastic
// which improves the precision and recall of search results
// (by taking stopwords into account), without sacrificing performance.
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-common-terms-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-common-terms-query.html
type CommonTermsQuery struct {
Query
name string
@@ -22,7 +22,6 @@ type CommonTermsQuery struct {
lowFreqMinimumShouldMatch string
analyzer string
boost *float64
- disableCoord *bool
queryName string
}
@@ -76,11 +75,6 @@ func (q *CommonTermsQuery) Boost(boost float64) *CommonTermsQuery {
return q
}
-func (q *CommonTermsQuery) DisableCoord(disableCoord bool) *CommonTermsQuery {
- q.disableCoord = &disableCoord
- return q
-}
-
func (q *CommonTermsQuery) QueryName(queryName string) *CommonTermsQuery {
q.queryName = queryName
return q
@@ -132,9 +126,6 @@ func (q *CommonTermsQuery) Source() (interface{}, error) {
if q.analyzer != "" {
query["analyzer"] = q.analyzer
}
- if q.disableCoord != nil {
- query["disable_coord"] = *q.disableCoord
- }
if q.boost != nil {
query["boost"] = *q.boost
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms_test.go
index be5a381c7..e841e7731 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_common_terms_test.go
@@ -36,17 +36,17 @@ func TestSearchQueriesCommonTermsQuery(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_constant_score.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_constant_score.go
index 3ba879958..285d91817 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_constant_score.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_constant_score.go
@@ -8,7 +8,7 @@ package elastic
// a constant score equal to the query boost for every document in the filter.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-constant-score-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-constant-score-query.html
type ConstantScoreQuery struct {
filter Query
boost *float64
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_dis_max.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_dis_max.go
index af9a40d37..7a4f53a97 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_dis_max.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_dis_max.go
@@ -10,7 +10,7 @@ package elastic
// increment for any additional matching subqueries.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-dis-max-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-dis-max-query.html
type DisMaxQuery struct {
queries []Query
boost *float64
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_exists.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_exists.go
index 6c2ebd369..ac7378bad 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_exists.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_exists.go
@@ -8,7 +8,7 @@ package elastic
// has a value in them.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-exists-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-exists-query.html
type ExistsQuery struct {
name string
queryName string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq.go
index ec34302f8..4cabd9bd9 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq.go
@@ -10,7 +10,7 @@ package elastic
// to compute the score on a filtered set of documents.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html
type FunctionScoreQuery struct {
query Query
filter Query
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_score_funcs.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_score_funcs.go
index 622b645bb..84cc52de9 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_score_funcs.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_score_funcs.go
@@ -18,7 +18,7 @@ type ScoreFunction interface {
// -- Exponential Decay --
// ExponentialDecayFunction builds an exponential decay score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html
// for details.
type ExponentialDecayFunction struct {
fieldName string
@@ -75,7 +75,7 @@ func (fn *ExponentialDecayFunction) Offset(offset interface{}) *ExponentialDecay
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *ExponentialDecayFunction) Weight(weight float64) *ExponentialDecayFunction {
fn.weight = &weight
@@ -120,7 +120,7 @@ func (fn *ExponentialDecayFunction) Source() (interface{}, error) {
// -- Gauss Decay --
// GaussDecayFunction builds a gauss decay score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html
// for details.
type GaussDecayFunction struct {
fieldName string
@@ -177,7 +177,7 @@ func (fn *GaussDecayFunction) Offset(offset interface{}) *GaussDecayFunction {
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *GaussDecayFunction) Weight(weight float64) *GaussDecayFunction {
fn.weight = &weight
@@ -223,7 +223,7 @@ func (fn *GaussDecayFunction) Source() (interface{}, error) {
// -- Linear Decay --
// LinearDecayFunction builds a linear decay score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html
// for details.
type LinearDecayFunction struct {
fieldName string
@@ -280,7 +280,7 @@ func (fn *LinearDecayFunction) Offset(offset interface{}) *LinearDecayFunction {
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *LinearDecayFunction) Weight(weight float64) *LinearDecayFunction {
fn.weight = &weight
@@ -336,7 +336,7 @@ func (fn *LinearDecayFunction) Source() (interface{}, error) {
// compute or influence the score of documents that match with the inner
// query or filter.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_script_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_script_score
// for details.
type ScriptFunction struct {
script *Script
@@ -363,7 +363,7 @@ func (fn *ScriptFunction) Script(script *Script) *ScriptFunction {
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *ScriptFunction) Weight(weight float64) *ScriptFunction {
fn.weight = &weight
@@ -394,7 +394,7 @@ func (fn *ScriptFunction) Source() (interface{}, error) {
// FieldValueFactorFunction is a function score function that allows you
// to use a field from a document to influence the score.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_field_value_factor.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_field_value_factor.
type FieldValueFactorFunction struct {
field string
factor *float64
@@ -435,7 +435,7 @@ func (fn *FieldValueFactorFunction) Modifier(modifier string) *FieldValueFactorF
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *FieldValueFactorFunction) Weight(weight float64) *FieldValueFactorFunction {
fn.weight = &weight
@@ -477,7 +477,7 @@ func (fn *FieldValueFactorFunction) Source() (interface{}, error) {
// WeightFactorFunction builds a weight factor function that multiplies
// the weight to the score.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_weight
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_weight
// for details.
type WeightFactorFunction struct {
weight float64
@@ -495,7 +495,7 @@ func (fn *WeightFactorFunction) Name() string {
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *WeightFactorFunction) Weight(weight float64) *WeightFactorFunction {
fn.weight = weight
@@ -517,7 +517,7 @@ func (fn *WeightFactorFunction) Source() (interface{}, error) {
// -- Random --
// RandomFunction builds a random score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_random
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_random
// for details.
type RandomFunction struct {
seed interface{}
@@ -543,7 +543,7 @@ func (fn *RandomFunction) Seed(seed interface{}) *RandomFunction {
}
// Weight adjusts the score of the score function.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-function-score-query.html#_using_function_score
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-function-score-query.html#_using_function_score
// for details.
func (fn *RandomFunction) Weight(weight float64) *RandomFunction {
fn.weight = &weight
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_test.go
index a8e7430ce..256752d18 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fsq_test.go
@@ -121,7 +121,7 @@ func TestFieldValueFactorWithMultipleScoreFuncsAndWeights(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"function_score":{"boost":2,"boost_mode":"multiply","functions":[{"field_value_factor":{"factor":2,"field":"income","modifier":"sqrt"},"weight":2.5},{"script_score":{"script":"_score * doc['my_numeric_field'].value"},"weight":1.25},{"weight":0.5}],"max_boost":12,"query":{"term":{"name.last":"banon"}},"score_mode":"max"}}`
+ expected := `{"function_score":{"boost":2,"boost_mode":"multiply","functions":[{"field_value_factor":{"factor":2,"field":"income","modifier":"sqrt"},"weight":2.5},{"script_score":{"script":{"source":"_score * doc['my_numeric_field'].value"}},"weight":1.25},{"weight":0.5}],"max_boost":12,"query":{"term":{"name.last":"banon"}},"score_mode":"max"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fuzzy.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fuzzy.go
index b98f9c7f0..02b6c52c2 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_fuzzy.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_fuzzy.go
@@ -8,7 +8,7 @@ package elastic
// string fields, and a +/- margin on numeric and date fields.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-fuzzy-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-fuzzy-query.html
type FuzzyQuery struct {
name string
value interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_bounding_box.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_bounding_box.go
index e53340e64..0418620d8 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_bounding_box.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_bounding_box.go
@@ -10,7 +10,7 @@ import "errors"
// a bounding box.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-geo-bounding-box-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-geo-bounding-box-query.html
type GeoBoundingBoxQuery struct {
name string
top *float64
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance.go
index a10bd5e3c..00e62725f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance.go
@@ -8,7 +8,7 @@ package elastic
// within a specific distance from a geo point.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-geo-distance-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-geo-distance-query.html
type GeoDistanceQuery struct {
name string
distance string
@@ -16,7 +16,6 @@ type GeoDistanceQuery struct {
lon float64
geohash string
distanceType string
- optimizeBbox string
queryName string
}
@@ -62,11 +61,6 @@ func (q *GeoDistanceQuery) DistanceType(distanceType string) *GeoDistanceQuery {
return q
}
-func (q *GeoDistanceQuery) OptimizeBbox(optimizeBbox string) *GeoDistanceQuery {
- q.optimizeBbox = optimizeBbox
- return q
-}
-
func (q *GeoDistanceQuery) QueryName(queryName string) *GeoDistanceQuery {
q.queryName = queryName
return q
@@ -103,9 +97,6 @@ func (q *GeoDistanceQuery) Source() (interface{}, error) {
if q.distanceType != "" {
params["distance_type"] = q.distanceType
}
- if q.optimizeBbox != "" {
- params["optimize_bbox"] = q.optimizeBbox
- }
if q.queryName != "" {
params["_name"] = q.queryName
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance_test.go
index 7b91d94e8..dd169575a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_distance_test.go
@@ -15,7 +15,6 @@ func TestGeoDistanceQuery(t *testing.T) {
q = q.Lon(-70)
q = q.Distance("200km")
q = q.DistanceType("plane")
- q = q.OptimizeBbox("memory")
src, err := q.Source()
if err != nil {
t.Fatal(err)
@@ -25,7 +24,7 @@ func TestGeoDistanceQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"geo_distance":{"distance":"200km","distance_type":"plane","optimize_bbox":"memory","pin.location":{"lat":40,"lon":-70}}}`
+ expected := `{"geo_distance":{"distance":"200km","distance_type":"plane","pin.location":{"lat":40,"lon":-70}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_polygon.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_polygon.go
index 1faaf24e0..7678c3f3b 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_polygon.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_geo_polygon.go
@@ -7,7 +7,7 @@ package elastic
// GeoPolygonQuery allows to include hits that only fall within a polygon of points.
//
// For more details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-geo-polygon-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-geo-polygon-query.html
type GeoPolygonQuery struct {
name string
points []*GeoPoint
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_child.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_child.go
index 27cea7ad6..41e7429c4 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_child.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_child.go
@@ -8,7 +8,7 @@ package elastic
// in parent documents that have child docs matching the query.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-has-child-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-has-child-query.html
type HasChildQuery struct {
query Query
childType string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_parent.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_parent.go
index 7df110cd2..5e1b650af 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_parent.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_has_parent.go
@@ -11,7 +11,7 @@ package elastic
// same manner as has_child query.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-has-parent-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-has-parent-query.html
type HasParentQuery struct {
query Query
parentType string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_ids.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_ids.go
index 42cc65672..e067aebbe 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_ids.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_ids.go
@@ -8,7 +8,7 @@ package elastic
// Note, this query uses the _uid field.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-ids-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-ids-query.html
type IdsQuery struct {
types []string
values []string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices.go
deleted file mode 100644
index ed5ec9d84..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-// IndicesQuery can be used when executed across multiple indices, allowing
-// to have a query that executes only when executed on an index that matches
-// a specific list of indices, and another query that executes when it is
-// executed on an index that does not match the listed indices.
-//
-// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-indices-query.html
-type IndicesQuery struct {
- query Query
- indices []string
- noMatchQueryType string
- noMatchQuery Query
- queryName string
-}
-
-// NewIndicesQuery creates and initializes a new indices query.
-func NewIndicesQuery(query Query, indices ...string) *IndicesQuery {
- return &IndicesQuery{
- query: query,
- indices: indices,
- }
-}
-
-// NoMatchQuery sets the query to use when it executes on an index that
-// does not match the indices provided.
-func (q *IndicesQuery) NoMatchQuery(query Query) *IndicesQuery {
- q.noMatchQuery = query
- return q
-}
-
-// NoMatchQueryType sets the no match query which can be either all or none.
-func (q *IndicesQuery) NoMatchQueryType(typ string) *IndicesQuery {
- q.noMatchQueryType = typ
- return q
-}
-
-// QueryName sets the query name for the filter.
-func (q *IndicesQuery) QueryName(queryName string) *IndicesQuery {
- q.queryName = queryName
- return q
-}
-
-// Source returns JSON for the function score query.
-func (q *IndicesQuery) Source() (interface{}, error) {
- // {
- // "indices" : {
- // "indices" : ["index1", "index2"],
- // "query" : {
- // "term" : { "tag" : "wow" }
- // },
- // "no_match_query" : {
- // "term" : { "tag" : "kow" }
- // }
- // }
- // }
-
- source := make(map[string]interface{})
- params := make(map[string]interface{})
- source["indices"] = params
-
- params["indices"] = q.indices
-
- src, err := q.query.Source()
- if err != nil {
- return nil, err
- }
- params["query"] = src
-
- if q.noMatchQuery != nil {
- src, err := q.noMatchQuery.Source()
- if err != nil {
- return nil, err
- }
- params["no_match_query"] = src
- } else if q.noMatchQueryType != "" {
- params["no_match_query"] = q.noMatchQueryType
- }
- if q.queryName != "" {
- params["_name"] = q.queryName
- }
-
- return source, nil
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices_test.go
deleted file mode 100644
index 0c04499d1..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_indices_test.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "encoding/json"
- "testing"
-)
-
-func TestIndicesQuery(t *testing.T) {
- q := NewIndicesQuery(NewTermQuery("tag", "wow"), "index1", "index2")
- q = q.NoMatchQuery(NewTermQuery("tag", "kow"))
- src, err := q.Source()
- if err != nil {
- t.Fatal(err)
- }
- data, err := json.Marshal(src)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"indices":{"indices":["index1","index2"],"no_match_query":{"term":{"tag":"kow"}},"query":{"term":{"tag":"wow"}}}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
-
-func TestIndicesQueryWithNoMatchQueryType(t *testing.T) {
- q := NewIndicesQuery(NewTermQuery("tag", "wow"), "index1", "index2")
- q = q.NoMatchQueryType("all")
- src, err := q.Source()
- if err != nil {
- t.Fatal(err)
- }
- data, err := json.Marshal(src)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"indices":{"indices":["index1","index2"],"no_match_query":"all","query":{"term":{"tag":"wow"}}}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match.go
index 1f2f16f69..b38b12452 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match.go
@@ -12,7 +12,7 @@ package elastic
// or use one of the shortcuts e.g. NewMatchPhraseQuery(...).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-match-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-match-query.html
type MatchQuery struct {
name string
text interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_all.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_all.go
index 5551eea30..3829c8af0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_all.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_all.go
@@ -8,7 +8,7 @@ package elastic
// giving them all a _score of 1.0.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-match-all-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-match-all-query.html
type MatchAllQuery struct {
boost *float64
queryName string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_none.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_none.go
index 06d036e71..9afe16716 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_none.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_none.go
@@ -8,7 +8,7 @@ package elastic
// MatchAllQuery.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-match-all-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-match-all-query.html
type MatchNoneQuery struct {
queryName string
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase.go
index fdded2e76..0e4c6327e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase.go
@@ -8,7 +8,7 @@ package elastic
// the analyzed text.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-match-query-phrase.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-match-query-phrase.html
type MatchPhraseQuery struct {
name string
value interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase_prefix.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase_prefix.go
index 1eeba8af5..10a88668d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase_prefix.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_match_phrase_prefix.go
@@ -8,7 +8,7 @@ package elastic
// prefix matches on the last term in the text.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-match-query-phrase-prefix.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-match-query-phrase-prefix.html
type MatchPhrasePrefixQuery struct {
name string
value interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this.go
index 40c2d575d..5c71e291f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this.go
@@ -13,7 +13,7 @@ import "errors"
// how the terms should be selected and how the query is formed.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-mlt-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-mlt-query.html
type MoreLikeThisQuery struct {
fields []string
docs []*MoreLikeThisQueryItem
@@ -25,8 +25,8 @@ type MoreLikeThisQuery struct {
stopWords []string
minDocFreq *int
maxDocFreq *int
- minWordLen *int
- maxWordLen *int
+ minWordLength *int
+ maxWordLength *int
boostTerms *float64
boost *float64
analyzer string
@@ -147,15 +147,15 @@ func (q *MoreLikeThisQuery) MaxDocFreq(maxDocFreq int) *MoreLikeThisQuery {
// MinWordLength sets the minimum word length below which words will be
// ignored. It defaults to 0.
-func (q *MoreLikeThisQuery) MinWordLen(minWordLen int) *MoreLikeThisQuery {
- q.minWordLen = &minWordLen
+func (q *MoreLikeThisQuery) MinWordLength(minWordLength int) *MoreLikeThisQuery {
+ q.minWordLength = &minWordLength
return q
}
-// MaxWordLen sets the maximum word length above which words will be ignored.
+// MaxWordLength sets the maximum word length above which words will be ignored.
// Defaults to unbounded (0).
-func (q *MoreLikeThisQuery) MaxWordLen(maxWordLen int) *MoreLikeThisQuery {
- q.maxWordLen = &maxWordLen
+func (q *MoreLikeThisQuery) MaxWordLength(maxWordLength int) *MoreLikeThisQuery {
+ q.maxWordLength = &maxWordLength
return q
}
@@ -254,11 +254,11 @@ func (q *MoreLikeThisQuery) Source() (interface{}, error) {
if q.maxDocFreq != nil {
params["max_doc_freq"] = *q.maxDocFreq
}
- if q.minWordLen != nil {
- params["min_word_len"] = *q.minWordLen
+ if q.minWordLength != nil {
+ params["min_word_length"] = *q.minWordLength
}
- if q.maxWordLen != nil {
- params["max_word_len"] = *q.maxWordLen
+ if q.maxWordLength != nil {
+ params["max_word_length"] = *q.maxWordLength
}
if q.boostTerms != nil {
params["boost_terms"] = *q.boostTerms
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this_test.go
index 6fc5b1c72..dcbbe74d1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_more_like_this_test.go
@@ -57,17 +57,17 @@ func TestMoreLikeThisQuery(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_multi_match.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_multi_match.go
index 9a149fed5..b6ff2107e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_multi_match.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_multi_match.go
@@ -12,7 +12,7 @@ import (
// MultiMatchQuery builds on the MatchQuery to allow multi-field queries.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-multi-match-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-multi-match-query.html
type MultiMatchQuery struct {
text interface{}
fields []string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_nested.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_nested.go
index a95cc2b80..d0a342283 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_nested.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_nested.go
@@ -10,7 +10,7 @@ package elastic
// root parent doc (or parent nested mapping).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-nested-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-nested-query.html
type NestedQuery struct {
query Query
path string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_parent_id.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_parent_id.go
index bd11cc291..c0b610f12 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_parent_id.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_parent_id.go
@@ -8,7 +8,7 @@ package elastic
// particular parent. Given the following mapping definition.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-parent-id-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-parent-id-query.html
type ParentIdQuery struct {
typ string
id string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator.go
index 16f7611ed..a7605655b 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator.go
@@ -9,10 +9,10 @@ import "errors"
// PercolatorQuery can be used to match queries stored in an index.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl-percolate-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-percolate-query.html
type PercolatorQuery struct {
field string
- documentType string
+ documentType string // deprecated
document interface{}
indexedDocumentIndex string
indexedDocumentType string
@@ -32,6 +32,7 @@ func (q *PercolatorQuery) Field(field string) *PercolatorQuery {
return q
}
+// Deprecated: DocumentType is deprecated as of 6.0.
func (q *PercolatorQuery) DocumentType(typ string) *PercolatorQuery {
q.documentType = typ
return q
@@ -77,9 +78,6 @@ func (q *PercolatorQuery) Source() (interface{}, error) {
if len(q.field) == 0 {
return nil, errors.New("elastic: Field is required in PercolatorQuery")
}
- if len(q.documentType) == 0 {
- return nil, errors.New("elastic: DocumentType is required in PercolatorQuery")
- }
if q.document == nil {
return nil, errors.New("elastic: Document is required in PercolatorQuery")
}
@@ -91,7 +89,9 @@ func (q *PercolatorQuery) Source() (interface{}, error) {
params := make(map[string]interface{})
source["percolate"] = params
params["field"] = q.field
- params["document_type"] = q.documentType
+ if q.documentType != "" {
+ params["document_type"] = q.documentType
+ }
params["document"] = q.document
if len(q.indexedDocumentIndex) > 0 {
params["index"] = q.indexedDocumentIndex
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator_test.go
index 8a22d4614..edc7be626 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_percolator_test.go
@@ -12,7 +12,6 @@ import (
func TestPercolatorQuery(t *testing.T) {
q := NewPercolatorQuery().
Field("query").
- DocumentType("doctype").
Document(map[string]interface{}{
"message": "Some message",
})
@@ -25,7 +24,7 @@ func TestPercolatorQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"percolate":{"document":{"message":"Some message"},"document_type":"doctype","field":"query"}}`
+ expected := `{"percolate":{"document":{"message":"Some message"},"field":"query"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -34,12 +33,10 @@ func TestPercolatorQuery(t *testing.T) {
func TestPercolatorQueryWithDetails(t *testing.T) {
q := NewPercolatorQuery().
Field("query").
- DocumentType("doctype").
Document(map[string]interface{}{
"message": "Some message",
}).
IndexedDocumentIndex("index").
- IndexedDocumentType("type").
IndexedDocumentId("1").
IndexedDocumentRouting("route").
IndexedDocumentPreference("one").
@@ -53,7 +50,7 @@ func TestPercolatorQueryWithDetails(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"percolate":{"document":{"message":"Some message"},"document_type":"doctype","field":"query","id":"1","index":"index","preference":"one","routing":"route","type":"type","version":1}}`
+ expected := `{"percolate":{"document":{"message":"Some message"},"field":"query","id":"1","index":"index","preference":"one","routing":"route","version":1}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix.go
index 0d5077553..075bcc7ba 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix.go
@@ -8,7 +8,7 @@ package elastic
// with a specified prefix (not analyzed).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-prefix-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-prefix-query.html
type PrefixQuery struct {
name string
prefix string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix_example_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix_example_test.go
index 1a421784e..73950f1f3 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix_example_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_prefix_example_test.go
@@ -7,7 +7,7 @@ package elastic_test
import (
"context"
- "gopkg.in/olivere/elastic.v5"
+ "github.com/olivere/elastic"
)
func ExamplePrefixQuery() {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_query_string.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_query_string.go
index 427e54c5b..a52c8b1a5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_query_string.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_query_string.go
@@ -11,37 +11,36 @@ import (
// QueryStringQuery uses the query parser in order to parse its content.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-query-string-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-query-string-query.html
type QueryStringQuery struct {
- queryString string
- defaultField string
- defaultOperator string
- analyzer string
- quoteAnalyzer string
- quoteFieldSuffix string
- autoGeneratePhraseQueries *bool
- allowLeadingWildcard *bool
- lowercaseExpandedTerms *bool
- enablePositionIncrements *bool
- analyzeWildcard *bool
- locale string
- boost *float64
- fuzziness string
- fuzzyPrefixLength *int
- fuzzyMaxExpansions *int
- fuzzyRewrite string
- phraseSlop *int
- fields []string
- fieldBoosts map[string]*float64
- useDisMax *bool
- tieBreaker *float64
- rewrite string
- minimumShouldMatch string
- lenient *bool
- queryName string
- timeZone string
- maxDeterminizedStates *int
- escape *bool
+ queryString string
+ defaultField string
+ defaultOperator string
+ analyzer string
+ quoteAnalyzer string
+ quoteFieldSuffix string
+ allowLeadingWildcard *bool
+ lowercaseExpandedTerms *bool // Deprecated: Decision is now made by the analyzer
+ enablePositionIncrements *bool
+ analyzeWildcard *bool
+ locale string // Deprecated: Decision is now made by the analyzer
+ boost *float64
+ fuzziness string
+ fuzzyPrefixLength *int
+ fuzzyMaxExpansions *int
+ fuzzyRewrite string
+ phraseSlop *int
+ fields []string
+ fieldBoosts map[string]*float64
+ tieBreaker *float64
+ rewrite string
+ minimumShouldMatch string
+ lenient *bool
+ queryName string
+ timeZone string
+ maxDeterminizedStates *int
+ escape *bool
+ typ string
}
// NewQueryStringQuery creates and initializes a new QueryStringQuery.
@@ -67,6 +66,13 @@ func (q *QueryStringQuery) Field(field string) *QueryStringQuery {
return q
}
+// Type sets how multiple fields should be combined to build textual part queries,
+// e.g. "best_fields".
+func (q *QueryStringQuery) Type(typ string) *QueryStringQuery {
+ q.typ = typ
+ return q
+}
+
// FieldWithBoost adds a field to run the query string against with a specific boost.
func (q *QueryStringQuery) FieldWithBoost(field string, boost float64) *QueryStringQuery {
q.fields = append(q.fields, field)
@@ -74,14 +80,6 @@ func (q *QueryStringQuery) FieldWithBoost(field string, boost float64) *QueryStr
return q
}
-// UseDisMax specifies whether to combine queries using dis max or boolean
-// query when more zhan one field is used with the query string. Defaults
-// to dismax (true).
-func (q *QueryStringQuery) UseDisMax(useDisMax bool) *QueryStringQuery {
- q.useDisMax = &useDisMax
- return q
-}
-
// TieBreaker is used when more than one field is used with the query string,
// and combined queries are using dismax.
func (q *QueryStringQuery) TieBreaker(tieBreaker float64) *QueryStringQuery {
@@ -119,15 +117,6 @@ func (q *QueryStringQuery) QuoteAnalyzer(quoteAnalyzer string) *QueryStringQuery
return q
}
-// AutoGeneratePhraseQueries indicates whether or not phrase queries will
-// be automatically generated when the analyzer returns more then one term
-// from whitespace delimited text. Set to false if phrase queries should only
-// be generated when surrounded by double quotes.
-func (q *QueryStringQuery) AutoGeneratePhraseQueries(autoGeneratePhraseQueries bool) *QueryStringQuery {
- q.autoGeneratePhraseQueries = &autoGeneratePhraseQueries
- return q
-}
-
// MaxDeterminizedState protects against too-difficult regular expression queries.
func (q *QueryStringQuery) MaxDeterminizedState(maxDeterminizedStates int) *QueryStringQuery {
q.maxDeterminizedStates = &maxDeterminizedStates
@@ -143,6 +132,8 @@ func (q *QueryStringQuery) AllowLeadingWildcard(allowLeadingWildcard bool) *Quer
// LowercaseExpandedTerms indicates whether terms of wildcard, prefix, fuzzy
// and range queries are automatically lower-cased or not. Default is true.
+//
+// Deprecated: Decision is now made by the analyzer.
func (q *QueryStringQuery) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *QueryStringQuery {
q.lowercaseExpandedTerms = &lowercaseExpandedTerms
return q
@@ -233,6 +224,9 @@ func (q *QueryStringQuery) QueryName(queryName string) *QueryStringQuery {
return q
}
+// Locale specifies the locale to be used for string conversions.
+//
+// Deprecated: Decision is now made by the analyzer.
func (q *QueryStringQuery) Locale(locale string) *QueryStringQuery {
q.locale = locale
return q
@@ -282,9 +276,6 @@ func (q *QueryStringQuery) Source() (interface{}, error) {
if q.tieBreaker != nil {
query["tie_breaker"] = *q.tieBreaker
}
- if q.useDisMax != nil {
- query["use_dis_max"] = *q.useDisMax
- }
if q.defaultOperator != "" {
query["default_operator"] = q.defaultOperator
}
@@ -294,9 +285,6 @@ func (q *QueryStringQuery) Source() (interface{}, error) {
if q.quoteAnalyzer != "" {
query["quote_analyzer"] = q.quoteAnalyzer
}
- if q.autoGeneratePhraseQueries != nil {
- query["auto_generate_phrase_queries"] = *q.autoGeneratePhraseQueries
- }
if q.maxDeterminizedStates != nil {
query["max_determinized_states"] = *q.maxDeterminizedStates
}
@@ -354,6 +342,9 @@ func (q *QueryStringQuery) Source() (interface{}, error) {
if q.escape != nil {
query["escape"] = *q.escape
}
+ if q.typ != "" {
+ query["type"] = q.typ
+ }
return source, nil
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_range.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_range.go
index 54303fb4a..1b92dee23 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_range.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_range.go
@@ -7,7 +7,7 @@ package elastic
// RangeQuery matches documents with fields that have terms within a certain range.
//
// For details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-range-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-range-query.html
type RangeQuery struct {
name string
from interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_regexp.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_regexp.go
index 636e4baf9..a08b533cb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_regexp.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_regexp.go
@@ -7,7 +7,7 @@ package elastic
// RegexpQuery allows you to use regular expression term queries.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-regexp-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-regexp-query.html
type RegexpQuery struct {
name string
regexp string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_script.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_script.go
index 664555b3e..d430f4c8f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_script.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_script.go
@@ -9,7 +9,7 @@ import "errors"
// ScriptQuery allows to define scripts as filters.
//
// For details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-script-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-script-query.html
type ScriptQuery struct {
script *Script
queryName string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_script_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_script_test.go
index 8bf9f8a11..66ec106d5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_script_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_script_test.go
@@ -20,7 +20,7 @@ func TestScriptQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"script":{"script":"doc['num1'.value \u003e 1"}}`
+ expected := `{"script":{"script":{"source":"doc['num1'.value \u003e 1"}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -38,7 +38,7 @@ func TestScriptQueryWithParams(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"script":{"_name":"MyQueryName","script":"doc['num1'.value \u003e 1"}}`
+ expected := `{"script":{"_name":"MyQueryName","script":{"source":"doc['num1'.value \u003e 1"}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string.go
index 764fa0a20..462ea5533 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string.go
@@ -15,7 +15,7 @@ import (
// and discards invalid parts of the query.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-simple-query-string-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-simple-query-string-query.html
type SimpleQueryStringQuery struct {
queryText string
analyzer string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string_test.go
index cef7c5f51..ea4a341ec 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_simple_query_string_test.go
@@ -36,17 +36,17 @@ func TestSimpleQueryStringQueryExec(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_slice.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_slice.go
index 0ebf88009..e1b1db928 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_slice.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_slice.go
@@ -6,7 +6,7 @@ package elastic
// SliceQuery allows to partition the documents into several slices.
// It is used e.g. to slice scroll operations in Elasticsearch 5.0 or later.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html#sliced-scroll
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html#sliced-scroll
// for details.
type SliceQuery struct {
field string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_term.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_term.go
index 051f6dee3..9a445e0ec 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_term.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_term.go
@@ -8,7 +8,7 @@ package elastic
// in the inverted index.
//
// For details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-term-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-term-query.html
type TermQuery struct {
name string
value interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_terms.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_terms.go
index 794c1f31c..3649576dc 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_terms.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_terms.go
@@ -8,7 +8,7 @@ package elastic
// of the provided terms (not analyzed).
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-terms-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-terms-query.html
type TermsQuery struct {
name string
values []interface{}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_type.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_type.go
index 70ace4541..e7aef30df 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_type.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_type.go
@@ -7,7 +7,7 @@ package elastic
// TypeQuery filters documents matching the provided document / mapping type.
//
// For details, see:
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-type-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-type-query.html
type TypeQuery struct {
typ string
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard.go
index 35f481542..ea8a0901c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard.go
@@ -13,7 +13,7 @@ package elastic
// The wildcard query maps to Lucene WildcardQuery.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-wildcard-query.html
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-wildcard-query.html
type WildcardQuery struct {
name string
wildcard string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard_test.go
index 658c513cc..b41c8ab7b 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_queries_wildcard_test.go
@@ -9,7 +9,7 @@ import (
"encoding/json"
"testing"
- "gopkg.in/olivere/elastic.v5"
+ "github.com/olivere/elastic"
)
func ExampleWildcardQuery() {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_request.go b/vendor/gopkg.in/olivere/elastic.v5/search_request.go
index 03513085f..6f40ff028 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_request.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_request.go
@@ -146,7 +146,7 @@ func (r *SearchRequest) Source(source interface{}) *SearchRequest {
// header is used e.g. by MultiSearch to get information about the search header
// of one SearchRequest.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-multi-search.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-multi-search.html
func (r *SearchRequest) header() interface{} {
h := make(map[string]interface{})
if r.searchType != "" {
@@ -199,7 +199,7 @@ func (r *SearchRequest) header() interface{} {
//
// Body is used e.g. by MultiSearch to get information about the search body
// of one SearchRequest.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-multi-search.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-multi-search.html
func (r *SearchRequest) Body() interface{} {
return r.source
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_source.go b/vendor/gopkg.in/olivere/elastic.v5/search_source.go
index 6a8efd229..77b1c5093 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_source.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_source.go
@@ -77,7 +77,7 @@ func (s *SearchSource) PostFilter(postFilter Query) *SearchSource {
// Slice allows partitioning the documents in multiple slices.
// It is e.g. used to slice a scroll operation, supported in
// Elasticsearch 5.0 or later.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html#sliced-scroll
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html#sliced-scroll
// for details.
func (s *SearchSource) Slice(sliceQuery Query) *SearchSource {
s.sliceQuery = sliceQuery
@@ -168,7 +168,7 @@ func (s *SearchSource) TrackScores(trackScores bool) *SearchSource {
// SearchAfter allows a different form of pagination by using a live cursor,
// using the results of the previous page to help the retrieval of the next.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-search-after.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-search-after.html
func (s *SearchSource) SearchAfter(sortValues ...interface{}) *SearchSource {
s.searchAfterSortValues = append(s.searchAfterSortValues, sortValues...)
return s
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_source_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_source_test.go
index 49e52f660..a78991bf0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_source_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_source_test.go
@@ -132,7 +132,7 @@ func TestSearchSourceScriptFields(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"query":{"match_all":{}},"script_fields":{"test1":{"script":"doc['my_field_name'].value * 2"},"test2":{"script":{"inline":"doc['my_field_name'].value * factor","params":{"factor":3.1415927}}}}}`
+ expected := `{"query":{"match_all":{}},"script_fields":{"test1":{"script":{"source":"doc['my_field_name'].value * 2"}},"test2":{"script":{"params":{"factor":3.1415927},"source":"doc['my_field_name'].value * factor"}}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -232,7 +232,7 @@ func TestSearchSourceMixDifferentSorters(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"query":{"match_all":{}},"sort":[{"a":{"order":"desc"}},{"b":{"order":"asc"}},{"_script":{"order":"asc","script":{"inline":"doc['field_name'].value * factor","params":{"factor":1.1}},"type":"number"}}]}`
+ expected := `{"query":{"match_all":{}},"sort":[{"a":{"order":"desc"}},{"b":{"order":"asc"}},{"_script":{"order":"asc","script":{"params":{"factor":1.1},"source":"doc['field_name'].value * factor"},"type":"number"}}]}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_suggester_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_suggester_test.go
index a555e3462..33bdc9275 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_suggester_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_suggester_test.go
@@ -17,17 +17,17 @@ func TestTermSuggester(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -92,17 +92,17 @@ func TestPhraseSuggester(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -150,6 +150,15 @@ func TestPhraseSuggester(t *testing.T) {
if mySuggestion.Length != 7 {
t.Errorf("expected Length = %d; got %d", 7, mySuggestion.Length)
}
+ if want, have := 1, len(mySuggestion.Options); want != have {
+ t.Errorf("expected len(options) = %d; got %d", want, have)
+ }
+ if want, have := "golang", mySuggestion.Options[0].Text; want != have {
+ t.Errorf("expected options[0].Text = %q; got %q", want, have)
+ }
+ if score := mySuggestion.Options[0].Score; score <= 0.0 {
+ t.Errorf("expected options[0].Score > 0.0; got %v", score)
+ }
}
func TestCompletionSuggester(t *testing.T) {
@@ -172,17 +181,17 @@ func TestCompletionSuggester(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -278,12 +287,12 @@ func TestContextSuggester(t *testing.T) {
`
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyString(tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyString(tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyString(tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyString(tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_terms_lookup.go b/vendor/gopkg.in/olivere/elastic.v5/search_terms_lookup.go
index e59e15c12..9a2456bdd 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_terms_lookup.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_terms_lookup.go
@@ -7,7 +7,7 @@ package elastic
// TermsLookup encapsulates the parameters needed to fetch terms.
//
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-terms-query.html#query-dsl-terms-lookup.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-terms-query.html#query-dsl-terms-lookup.
type TermsLookup struct {
index string
typ string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_test.go
index 96346b8b0..097c26525 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_test.go
@@ -29,10 +29,10 @@ func TestSearchMatchAll(t *testing.T) {
if searchResult.Hits == nil {
t.Errorf("expected SearchResult.Hits != nil; got nil")
}
- if got, want := searchResult.Hits.TotalHits, int64(12); got != want {
+ if got, want := searchResult.Hits.TotalHits, int64(3); got != want {
t.Errorf("expected SearchResult.Hits.TotalHits = %d; got %d", want, got)
}
- if got, want := len(searchResult.Hits.Hits), 12; got != want {
+ if got, want := len(searchResult.Hits.Hits), 3; got != want {
t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", want, got)
}
@@ -66,10 +66,10 @@ func TestSearchMatchAllWithRequestCacheDisabled(t *testing.T) {
if searchResult.Hits == nil {
t.Errorf("expected SearchResult.Hits != nil; got nil")
}
- if got, want := searchResult.Hits.TotalHits, int64(12); got != want {
+ if got, want := searchResult.Hits.TotalHits, int64(3); got != want {
t.Errorf("expected SearchResult.Hits.TotalHits = %d; got %d", want, got)
}
- if got, want := len(searchResult.Hits.Hits), 12; got != want {
+ if got, want := len(searchResult.Hits.Hits), 3; got != want {
t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", want, got)
}
}
@@ -195,6 +195,51 @@ func TestSearchResultEach(t *testing.T) {
}
}
+func TestSearchResultEachNoSource(t *testing.T) {
+ client := setupTestClientAndCreateIndexAndAddDocsNoSource(t)
+
+ all := NewMatchAllQuery()
+ searchResult, err := client.Search().Index(testNoSourceIndexName).Query(all).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // Iterate over non-ptr type
+ var aTweet tweet
+ count := 0
+ for _, item := range searchResult.Each(reflect.TypeOf(aTweet)) {
+ count++
+ tw, ok := item.(tweet)
+ if !ok {
+ t.Fatalf("expected hit to be serialized as tweet; got: %v", reflect.ValueOf(item))
+ }
+
+ if tw.User != "" {
+ t.Fatalf("expected no _source hit to be empty tweet; got: %v", reflect.ValueOf(item))
+ }
+ }
+ if count != 2 {
+ t.Errorf("expected to find 2 hits; got: %d", count)
+ }
+
+ // Iterate over ptr-type
+ count = 0
+ var aTweetPtr *tweet
+ for _, item := range searchResult.Each(reflect.TypeOf(aTweetPtr)) {
+ count++
+ tw, ok := item.(*tweet)
+ if !ok {
+ t.Fatalf("expected hit to be serialized as tweet; got: %v", reflect.ValueOf(item))
+ }
+ if tw != nil {
+ t.Fatal("expected hit to be nil")
+ }
+ }
+ if count != 2 {
+ t.Errorf("expected to find 2 hits; got: %d", count)
+ }
+}
+
func TestSearchSorting(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
@@ -215,17 +260,17 @@ func TestSearchSorting(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -288,17 +333,17 @@ func TestSearchSortingBySorters(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -350,17 +395,17 @@ func TestSearchSpecificFields(t *testing.T) {
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -442,17 +487,17 @@ func TestSearchExplain(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -520,17 +565,17 @@ func TestSearchSource(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -583,17 +628,17 @@ func TestSearchRawString(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -639,17 +684,17 @@ func TestSearchSearchSource(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -684,299 +729,249 @@ func TestSearchSearchSource(t *testing.T) {
}
func TestSearchInnerHitsOnHasChild(t *testing.T) {
+ // client := setupTestClientAndCreateIndex(t, SetTraceLog(log.New(os.Stdout, "", 0)))
client := setupTestClientAndCreateIndex(t)
- // Check for valid ES version
- esversion, err := client.ElasticsearchVersion(DefaultURL)
+ ctx := context.Background()
+
+ // Create join index
+ createIndex, err := client.CreateIndex(testJoinIndex).Body(testJoinMapping).Do(ctx)
if err != nil {
t.Fatal(err)
}
- if esversion < "1.5.0" {
- t.Skip("InnerHits feature is only available for Elasticsearch 1.5+")
- return
+ if createIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createIndex)
}
- tweet1 := tweet{
- User: "olivere", Retweets: 108,
- Message: "Welcome to Golang and Elasticsearch.",
- Created: time.Date(2012, 12, 12, 17, 38, 34, 0, time.UTC),
- }
- tweet2 := tweet{
- User: "olivere", Retweets: 0,
- Message: "Another unrelated topic.",
- Created: time.Date(2012, 10, 10, 8, 12, 03, 0, time.UTC),
- }
- comment2a := comment{User: "sandrae", Comment: "What does that even mean?"}
- tweet3 := tweet{
- User: "sandrae", Retweets: 12,
- Message: "Cycling is fun.",
- Created: time.Date(2011, 11, 11, 10, 58, 12, 0, time.UTC),
+ // Add documents
+ // See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/parent-join.html for example code.
+ doc1 := joinDoc{
+ Message: "This is a question",
+ JoinField: &joinField{Name: "question"},
}
- comment3a := comment{User: "nico", Comment: "You bet."}
- comment3b := comment{User: "olivere", Comment: "It sure is."}
-
- // Add all documents
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t1").BodyJson(&tweet1).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("1").BodyJson(&doc1).Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t2").BodyJson(&tweet2).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
+ doc2 := joinDoc{
+ Message: "This is another question",
+ JoinField: "question",
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c2a").Parent("t2").BodyJson(&comment2a).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("2").BodyJson(&doc2).Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t3").BodyJson(&tweet3).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
+ doc3 := joinDoc{
+ Message: "This is an answer",
+ JoinField: &joinField{
+ Name: "answer",
+ Parent: "1",
+ },
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c3a").Parent("t3").BodyJson(&comment3a).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("3").BodyJson(&doc3).Routing("1").Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c3b").Parent("t3").BodyJson(&comment3b).Do(context.TODO())
+ doc4 := joinDoc{
+ Message: "This is another answer",
+ JoinField: &joinField{
+ Name: "answer",
+ Parent: "1",
+ },
+ }
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("4").BodyJson(&doc4).Routing("1").Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Flush().Index(testIndexName).Do(context.TODO())
+ _, err = client.Flush().Index(testJoinIndex).Do(ctx)
if err != nil {
t.Fatal(err)
}
+ // Search for all documents that have an answer, and return those answers as inner hits
bq := NewBoolQuery()
bq = bq.Must(NewMatchAllQuery())
- bq = bq.Filter(NewHasChildQuery("comment", NewMatchAllQuery()).
- InnerHit(NewInnerHit().Name("comments")))
+ bq = bq.Filter(NewHasChildQuery("answer", NewMatchAllQuery()).
+ InnerHit(NewInnerHit().Name("answers")))
searchResult, err := client.Search().
- Index(testIndexName).
+ Index(testJoinIndex).
Query(bq).
Pretty(true).
- Do(context.TODO())
+ Do(ctx)
if err != nil {
t.Fatal(err)
}
if searchResult.Hits == nil {
t.Errorf("expected SearchResult.Hits != nil; got nil")
}
- if searchResult.Hits.TotalHits != 2 {
+ if searchResult.Hits.TotalHits != 1 {
t.Errorf("expected SearchResult.Hits.TotalHits = %d; got %d", 2, searchResult.Hits.TotalHits)
}
- if len(searchResult.Hits.Hits) != 2 {
+ if len(searchResult.Hits.Hits) != 1 {
t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", 2, len(searchResult.Hits.Hits))
}
hit := searchResult.Hits.Hits[0]
- if hit.Id != "t2" {
- t.Fatalf("expected tweet %q; got: %q", "t2", hit.Id)
- }
- if hit.InnerHits == nil {
- t.Fatalf("expected inner hits; got: %v", hit.InnerHits)
- }
- if len(hit.InnerHits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(hit.InnerHits))
- }
- innerHits, found := hit.InnerHits["comments"]
- if !found {
- t.Fatalf("expected inner hits for name %q", "comments")
- }
- if innerHits == nil || innerHits.Hits == nil {
- t.Fatal("expected inner hits != nil")
- }
- if len(innerHits.Hits.Hits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(innerHits.Hits.Hits))
- }
- if innerHits.Hits.Hits[0].Id != "c2a" {
- t.Fatalf("expected inner hit with id %q; got: %q", "c2a", innerHits.Hits.Hits[0].Id)
- }
-
- hit = searchResult.Hits.Hits[1]
- if hit.Id != "t3" {
- t.Fatalf("expected tweet %q; got: %q", "t3", hit.Id)
+ if want, have := "1", hit.Id; want != have {
+ t.Fatalf("expected tweet %q; got: %q", want, have)
}
if hit.InnerHits == nil {
t.Fatalf("expected inner hits; got: %v", hit.InnerHits)
}
- if len(hit.InnerHits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(hit.InnerHits))
+ if want, have := 1, len(hit.InnerHits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- innerHits, found = hit.InnerHits["comments"]
+ innerHits, found := hit.InnerHits["answers"]
if !found {
- t.Fatalf("expected inner hits for name %q", "comments")
+ t.Fatalf("expected inner hits for name %q", "answers")
}
if innerHits == nil || innerHits.Hits == nil {
t.Fatal("expected inner hits != nil")
}
- if len(innerHits.Hits.Hits) != 2 {
- t.Fatalf("expected %d inner hits; got: %d", 2, len(innerHits.Hits.Hits))
+ if want, have := 2, len(innerHits.Hits.Hits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- if innerHits.Hits.Hits[0].Id != "c3a" {
- t.Fatalf("expected inner hit with id %q; got: %q", "c3a", innerHits.Hits.Hits[0].Id)
+ if want, have := "3", innerHits.Hits.Hits[0].Id; want != have {
+ t.Fatalf("expected inner hit with id %q; got: %q", want, have)
}
- if innerHits.Hits.Hits[1].Id != "c3b" {
- t.Fatalf("expected inner hit with id %q; got: %q", "c3b", innerHits.Hits.Hits[1].Id)
+ if want, have := "4", innerHits.Hits.Hits[1].Id; want != have {
+ t.Fatalf("expected inner hit with id %q; got: %q", want, have)
}
}
func TestSearchInnerHitsOnHasParent(t *testing.T) {
+ // client := setupTestClientAndCreateIndex(t, SetTraceLog(log.New(os.Stdout, "", 0)))
client := setupTestClientAndCreateIndex(t)
- // Check for valid ES version
- esversion, err := client.ElasticsearchVersion(DefaultURL)
+ ctx := context.Background()
+
+ // Create join index
+ createIndex, err := client.CreateIndex(testJoinIndex).Body(testJoinMapping).Do(ctx)
if err != nil {
t.Fatal(err)
}
- if esversion < "1.5.0" {
- t.Skip("InnerHits feature is only available for Elasticsearch 1.5+")
- return
+ if createIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createIndex)
}
- tweet1 := tweet{
- User: "olivere", Retweets: 108,
- Message: "Welcome to Golang and Elasticsearch.",
- Created: time.Date(2012, 12, 12, 17, 38, 34, 0, time.UTC),
- }
- tweet2 := tweet{
- User: "olivere", Retweets: 0,
- Message: "Another unrelated topic.",
- Created: time.Date(2012, 10, 10, 8, 12, 03, 0, time.UTC),
- }
- comment2a := comment{User: "sandrae", Comment: "What does that even mean?"}
- tweet3 := tweet{
- User: "sandrae", Retweets: 12,
- Message: "Cycling is fun.",
- Created: time.Date(2011, 11, 11, 10, 58, 12, 0, time.UTC),
+ // Add documents
+ // See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/parent-join.html for example code.
+ doc1 := joinDoc{
+ Message: "This is a question",
+ JoinField: &joinField{Name: "question"},
}
- comment3a := comment{User: "nico", Comment: "You bet."}
- comment3b := comment{User: "olivere", Comment: "It sure is."}
-
- // Add all documents
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t1").BodyJson(&tweet1).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("1").BodyJson(&doc1).Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t2").BodyJson(&tweet2).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
+ doc2 := joinDoc{
+ Message: "This is another question",
+ JoinField: "question",
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c2a").Parent("t2").BodyJson(&comment2a).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("2").BodyJson(&doc2).Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("t3").BodyJson(&tweet3).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
+ doc3 := joinDoc{
+ Message: "This is an answer",
+ JoinField: &joinField{
+ Name: "answer",
+ Parent: "1",
+ },
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c3a").Parent("t3").BodyJson(&comment3a).Do(context.TODO())
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("3").BodyJson(&doc3).Routing("1").Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("comment").Id("c3b").Parent("t3").BodyJson(&comment3b).Do(context.TODO())
+ doc4 := joinDoc{
+ Message: "This is another answer",
+ JoinField: &joinField{
+ Name: "answer",
+ Parent: "1",
+ },
+ }
+ _, err = client.Index().Index(testJoinIndex).Type("doc").Id("4").BodyJson(&doc4).Routing("1").Refresh("true").Do(ctx)
if err != nil {
t.Fatal(err)
}
- _, err = client.Flush().Index(testIndexName).Do(context.TODO())
+ _, err = client.Flush().Index(testJoinIndex).Do(ctx)
if err != nil {
t.Fatal(err)
}
+ // Search for all documents that have an answer, and return those answers as inner hits
bq := NewBoolQuery()
bq = bq.Must(NewMatchAllQuery())
- bq = bq.Filter(NewHasParentQuery("tweet", NewMatchAllQuery()).
- InnerHit(NewInnerHit().Name("tweets")))
+ bq = bq.Filter(NewHasParentQuery("question", NewMatchAllQuery()).
+ InnerHit(NewInnerHit().Name("answers")))
searchResult, err := client.Search().
- Index(testIndexName).
+ Index(testJoinIndex).
Query(bq).
Pretty(true).
- Do(context.TODO())
+ Do(ctx)
if err != nil {
t.Fatal(err)
}
if searchResult.Hits == nil {
t.Errorf("expected SearchResult.Hits != nil; got nil")
}
- if searchResult.Hits.TotalHits != 3 {
- t.Errorf("expected SearchResult.Hits.TotalHits = %d; got %d", 3, searchResult.Hits.TotalHits)
+ if want, have := int64(2), searchResult.Hits.TotalHits; want != have {
+ t.Errorf("expected SearchResult.Hits.TotalHits = %d; got %d", want, have)
}
- if len(searchResult.Hits.Hits) != 3 {
- t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", 3, len(searchResult.Hits.Hits))
+ if want, have := 2, len(searchResult.Hits.Hits); want != have {
+ t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", want, have)
}
hit := searchResult.Hits.Hits[0]
- if hit.Id != "c2a" {
- t.Fatalf("expected tweet %q; got: %q", "c2a", hit.Id)
+ if want, have := "3", hit.Id; want != have {
+ t.Fatalf("expected tweet %q; got: %q", want, have)
}
if hit.InnerHits == nil {
t.Fatalf("expected inner hits; got: %v", hit.InnerHits)
}
- if len(hit.InnerHits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(hit.InnerHits))
+ if want, have := 1, len(hit.InnerHits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- innerHits, found := hit.InnerHits["tweets"]
+ innerHits, found := hit.InnerHits["answers"]
if !found {
t.Fatalf("expected inner hits for name %q", "tweets")
}
if innerHits == nil || innerHits.Hits == nil {
t.Fatal("expected inner hits != nil")
}
- if len(innerHits.Hits.Hits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(innerHits.Hits.Hits))
+ if want, have := 1, len(innerHits.Hits.Hits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- if innerHits.Hits.Hits[0].Id != "t2" {
- t.Fatalf("expected inner hit with id %q; got: %q", "t2", innerHits.Hits.Hits[0].Id)
+ if want, have := "1", innerHits.Hits.Hits[0].Id; want != have {
+ t.Fatalf("expected inner hit with id %q; got: %q", want, have)
}
hit = searchResult.Hits.Hits[1]
- if hit.Id != "c3a" {
- t.Fatalf("expected tweet %q; got: %q", "c3a", hit.Id)
- }
- if hit.InnerHits == nil {
- t.Fatalf("expected inner hits; got: %v", hit.InnerHits)
- }
- if len(hit.InnerHits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(hit.InnerHits))
- }
- innerHits, found = hit.InnerHits["tweets"]
- if !found {
- t.Fatalf("expected inner hits for name %q", "tweets")
- }
- if innerHits == nil || innerHits.Hits == nil {
- t.Fatal("expected inner hits != nil")
- }
- if len(innerHits.Hits.Hits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(innerHits.Hits.Hits))
- }
- if innerHits.Hits.Hits[0].Id != "t3" {
- t.Fatalf("expected inner hit with id %q; got: %q", "t3", innerHits.Hits.Hits[0].Id)
- }
-
- hit = searchResult.Hits.Hits[2]
- if hit.Id != "c3b" {
- t.Fatalf("expected tweet %q; got: %q", "c3b", hit.Id)
+ if want, have := "4", hit.Id; want != have {
+ t.Fatalf("expected tweet %q; got: %q", want, have)
}
if hit.InnerHits == nil {
t.Fatalf("expected inner hits; got: %v", hit.InnerHits)
}
- if len(hit.InnerHits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(hit.InnerHits))
+ if want, have := 1, len(hit.InnerHits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- innerHits, found = hit.InnerHits["tweets"]
+ innerHits, found = hit.InnerHits["answers"]
if !found {
t.Fatalf("expected inner hits for name %q", "tweets")
}
if innerHits == nil || innerHits.Hits == nil {
t.Fatal("expected inner hits != nil")
}
- if len(innerHits.Hits.Hits) != 1 {
- t.Fatalf("expected %d inner hits; got: %d", 1, len(innerHits.Hits.Hits))
+ if want, have := 1, len(innerHits.Hits.Hits); want != have {
+ t.Fatalf("expected %d inner hits; got: %d", want, have)
}
- if innerHits.Hits.Hits[0].Id != "t3" {
- t.Fatalf("expected inner hit with id %q; got: %q", "t3", innerHits.Hits.Hits[0].Id)
+ if want, have := "1", innerHits.Hits.Hits[0].Id; want != have {
+ t.Fatalf("expected inner hit with id %q; got: %q", want, have)
}
}
@@ -1045,7 +1040,7 @@ func TestSearchFilterPath(t *testing.T) {
all := NewMatchAllQuery()
searchResult, err := client.Search().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Query(all).
FilterPath(
"took",
@@ -1119,17 +1114,17 @@ func TestSearchAfter(t *testing.T) {
}
// Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
@@ -1168,7 +1163,7 @@ func TestSearchResultWithFieldCollapsing(t *testing.T) {
searchResult, err := client.Search().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Query(NewMatchAllQuery()).
Collapse(NewCollapseBuilder("user")).
Pretty(true).
@@ -1215,7 +1210,7 @@ func TestSearchResultWithFieldCollapsingAndInnerHits(t *testing.T) {
searchResult, err := client.Search().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Query(NewMatchAllQuery()).
Collapse(
NewCollapseBuilder("user").
diff --git a/vendor/gopkg.in/olivere/elastic.v5/setup_test.go b/vendor/gopkg.in/olivere/elastic.v5/setup_test.go
index df2206a14..480ae5d20 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/setup_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/setup_test.go
@@ -16,6 +16,7 @@ import (
const (
testIndexName = "elastic-test"
testIndexName2 = "elastic-test2"
+ testIndexName3 = "elastic-test3"
testMapping = `
{
"settings":{
@@ -23,12 +24,49 @@ const (
"number_of_replicas":0
},
"mappings":{
- "_default_": {
- "_all": {
- "enabled": true
+ "doc":{
+ "properties":{
+ "user":{
+ "type":"keyword"
+ },
+ "message":{
+ "type":"text",
+ "store": true,
+ "fielddata": true
+ },
+ "tags":{
+ "type":"keyword"
+ },
+ "location":{
+ "type":"geo_point"
+ },
+ "suggest_field":{
+ "type":"completion",
+ "contexts":[
+ {
+ "name":"user_name",
+ "type":"category"
+ }
+ ]
+ }
}
- },
- "tweet":{
+ }
+ }
+}
+`
+
+ testNoSourceIndexName = "elastic-nosource-test"
+ testNoSourceMapping = `
+{
+ "settings":{
+ "number_of_shards":1,
+ "number_of_replicas":0
+ },
+ "mappings":{
+ "doc":{
+ "_source": {
+ "enabled": false
+ },
"properties":{
"user":{
"type":"keyword"
@@ -48,19 +86,51 @@ const (
"type":"completion",
"contexts":[
{
- "name": "user_name",
- "type": "category"
+ "name":"user_name",
+ "type":"category"
}
]
}
}
+ }
+ }
+}
+`
+
+ testJoinIndex = "elastic-joins"
+ testJoinMapping = `
+ {
+ "settings":{
+ "number_of_shards":1,
+ "number_of_replicas":0
},
- "comment":{
- "_parent": {
- "type": "tweet"
+ "mappings":{
+ "doc":{
+ "properties":{
+ "message":{
+ "type":"text"
+ },
+ "my_join_field": {
+ "type": "join",
+ "relations": {
+ "question": "answer"
+ }
+ }
+ }
}
- },
- "order":{
+ }
+ }
+`
+
+ testOrderIndex = "elastic-orders"
+ testOrderMapping = `
+{
+ "settings":{
+ "number_of_shards":1,
+ "number_of_replicas":0
+ },
+ "mappings":{
+ "doc":{
"properties":{
"article":{
"type":"text"
@@ -76,18 +146,49 @@ const (
"format": "YYYY-MM-dd"
}
}
- },
- "doctype":{
+ }
+ }
+}
+`
+
+ /*
+ testDoctypeIndex = "elastic-doctypes"
+ testDoctypeMapping = `
+ {
+ "settings":{
+ "number_of_shards":1,
+ "number_of_replicas":0
+ },
+ "mappings":{
+ "doc":{
+ "properties":{
+ "message":{
+ "type":"text",
+ "store": true,
+ "fielddata": true
+ }
+ }
+ }
+ }
+ }
+ `
+ */
+
+ testQueryIndex = "elastic-queries"
+ testQueryMapping = `
+{
+ "settings":{
+ "number_of_shards":1,
+ "number_of_replicas":0
+ },
+ "mappings":{
+ "doc":{
"properties":{
"message":{
"type":"text",
"store": true,
"fielddata": true
- }
- }
- },
- "queries":{
- "properties": {
+ },
"query": {
"type": "percolator"
}
@@ -123,6 +224,16 @@ func (c comment) String() string {
return fmt.Sprintf("comment{User:%q,Comment:%q}", c.User, c.Comment)
}
+type joinDoc struct {
+ Message string `json:"message"`
+ JoinField interface{} `json:"my_join_field,omitempty"`
+}
+
+type joinField struct {
+ Name string `json:"name"`
+ Parent string `json:"parent,omitempty"`
+}
+
type order struct {
Article string `json:"article"`
Manufacturer string `json:"manufacturer"`
@@ -173,6 +284,12 @@ func setupTestClient(t logger, options ...ClientOptionFunc) (client *Client) {
client.DeleteIndex(testIndexName).Do(context.TODO())
client.DeleteIndex(testIndexName2).Do(context.TODO())
+ client.DeleteIndex(testIndexName3).Do(context.TODO())
+ client.DeleteIndex(testOrderIndex).Do(context.TODO())
+ client.DeleteIndex(testNoSourceIndexName).Do(context.TODO())
+ //client.DeleteIndex(testDoctypeIndex).Do(context.TODO())
+ client.DeleteIndex(testQueryIndex).Do(context.TODO())
+ client.DeleteIndex(testJoinIndex).Do(context.TODO())
return client
}
@@ -198,6 +315,24 @@ func setupTestClientAndCreateIndex(t logger, options ...ClientOptionFunc) *Clien
t.Errorf("expected result to be != nil; got: %v", createIndex2)
}
+ // Create no source index
+ createNoSourceIndex, err := client.CreateIndex(testNoSourceIndexName).Body(testNoSourceMapping).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if createNoSourceIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createNoSourceIndex)
+ }
+
+ // Create order index
+ createOrderIndex, err := client.CreateIndex(testOrderIndex).Body(testOrderMapping).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if createOrderIndex == nil {
+ t.Errorf("expected result to be != nil; got: %v", createOrderIndex)
+ }
+
return client
}
@@ -212,24 +347,26 @@ func setupTestClientAndCreateIndexAndAddDocs(t logger, options ...ClientOptionFu
tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
tweet2 := tweet{User: "olivere", Message: "Another unrelated topic."}
tweet3 := tweet{User: "sandrae", Message: "Cycling is fun."}
- comment1 := comment{User: "nico", Comment: "You bet."}
+ //comment1 := comment{User: "nico", Comment: "You bet."}
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ _, err := client.Index().Index(testIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").Routing("someroutingkey").BodyJson(&tweet3).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
- _, err = client.Index().Index(testIndexName).Type("comment").Id("1").Parent("3").BodyJson(&comment1).Do(context.TODO())
+ _, err = client.Index().Index(testIndexName).Type("doc").Id("3").Routing("someroutingkey").BodyJson(&tweet3).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
+ /*
+ _, err = client.Index().Index(testIndexName).Type("comment").Id("1").Parent("3").BodyJson(&comment1).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ */
// Add orders
var orders []order
@@ -243,20 +380,44 @@ func setupTestClientAndCreateIndexAndAddDocs(t logger, options ...ClientOptionFu
orders = append(orders, order{Article: "T-Shirt", Manufacturer: "h&m", Price: 19, Time: "2015-06-18"})
for i, o := range orders {
id := fmt.Sprintf("%d", i)
- _, err = client.Index().Index(testIndexName).Type("order").Id(id).BodyJson(&o).Do(context.TODO())
+ _, err = client.Index().Index(testOrderIndex).Type("doc").Id(id).BodyJson(&o).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
}
// Flush
- _, err = client.Flush().Index(testIndexName).Do(context.TODO())
+ _, err = client.Flush().Index(testIndexName, testOrderIndex).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
return client
}
+func setupTestClientAndCreateIndexAndAddDocsNoSource(t logger, options ...ClientOptionFunc) *Client {
+ client := setupTestClientAndCreateIndex(t, options...)
+
+ // Add tweets
+ tweet1 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."}
+ tweet2 := tweet{User: "olivere", Message: "Another unrelated topic."}
+
+ _, err := client.Index().Index(testNoSourceIndexName).Type("doc").Id("1").BodyJson(&tweet1).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = client.Index().Index(testNoSourceIndexName).Type("doc").Id("2").BodyJson(&tweet2).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Flush
+ _, err = client.Flush().Index(testNoSourceIndexName).Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ return client
+}
+
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func randomString(n int) string {
@@ -266,3 +427,19 @@ func randomString(n int) string {
}
return string(b)
}
+
+type lexicographically struct {
+ strings []string
+}
+
+func (l lexicographically) Len() int {
+ return len(l.strings)
+}
+
+func (l lexicographically) Less(i, j int) bool {
+ return l.strings[i] < l.strings[j]
+}
+
+func (l lexicographically) Swap(i, j int) {
+ l.strings[i], l.strings[j] = l.strings[j], l.strings[i]
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go
index 245fdbff8..1bbd2762e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go
@@ -11,10 +11,10 @@ import (
"net/url"
"time"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
-// SnapshotCreateService is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html.
+// SnapshotCreateService is documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-snapshots.html.
type SnapshotCreateService struct {
client *Client
pretty bool
@@ -89,7 +89,7 @@ func (s *SnapshotCreateService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -137,7 +137,12 @@ func (s *SnapshotCreateService) Do(ctx context.Context) (*SnapshotCreateResponse
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_repository.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_repository.go
index 9fc0a32a6..e7f6d5336 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_repository.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_repository.go
@@ -10,11 +10,11 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// SnapshotCreateRepositoryService creates a snapshot repository.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/modules-snapshots.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-snapshots.html
// for details.
type SnapshotCreateRepositoryService struct {
client *Client
@@ -112,7 +112,7 @@ func (s *SnapshotCreateRepositoryService) buildURL() (string, url.Values, error)
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -179,7 +179,12 @@ func (s *SnapshotCreateRepositoryService) Do(ctx context.Context) (*SnapshotCrea
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -194,5 +199,7 @@ func (s *SnapshotCreateRepositoryService) Do(ctx context.Context) (*SnapshotCrea
// SnapshotCreateRepositoryResponse is the response of SnapshotCreateRepositoryService.Do.
type SnapshotCreateRepositoryResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go
index d3fafc50d..74b009cfe 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go
@@ -37,7 +37,7 @@ func TestSnapshotPutURL(t *testing.T) {
WaitForCompletion: true,
ExpectedPath: "/_snapshot/repo/snapshot_of_sunday",
ExpectedParams: url.Values{
- "pretty": []string{"1"},
+ "pretty": []string{"true"},
"master_timeout": []string{"60s"},
"wait_for_completion": []string{"true"},
},
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_delete_repository.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_delete_repository.go
index 1f402fba5..ad3e49b0e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_delete_repository.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_delete_repository.go
@@ -11,11 +11,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// SnapshotDeleteRepositoryService deletes a snapshot repository.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/modules-snapshots.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-snapshots.html
// for details.
type SnapshotDeleteRepositoryService struct {
client *Client
@@ -70,7 +70,7 @@ func (s *SnapshotDeleteRepositoryService) buildURL() (string, url.Values, error)
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -107,7 +107,11 @@ func (s *SnapshotDeleteRepositoryService) Do(ctx context.Context) (*SnapshotDele
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "DELETE",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -122,5 +126,7 @@ func (s *SnapshotDeleteRepositoryService) Do(ctx context.Context) (*SnapshotDele
// SnapshotDeleteRepositoryResponse is the response of SnapshotDeleteRepositoryService.Do.
type SnapshotDeleteRepositoryResponse struct {
- Acknowledged bool `json:"acknowledged"`
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_get_repository.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_get_repository.go
index 10b2d0b9c..2d24c5e4c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_get_repository.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_get_repository.go
@@ -11,11 +11,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// SnapshotGetRepositoryService reads a snapshot repository.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/modules-snapshots.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-snapshots.html
// for details.
type SnapshotGetRepositoryService struct {
client *Client
@@ -76,7 +76,7 @@ func (s *SnapshotGetRepositoryService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.local != nil {
params.Set("local", fmt.Sprintf("%v", *s.local))
@@ -106,7 +106,11 @@ func (s *SnapshotGetRepositoryService) Do(ctx context.Context) (SnapshotGetRepos
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_verify_repository.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_verify_repository.go
index 4e8c25a24..5494ab475 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/snapshot_verify_repository.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_verify_repository.go
@@ -10,11 +10,11 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// SnapshotVerifyRepositoryService verifies a snapshop repository.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.3/modules-snapshots.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-snapshots.html
// for details.
type SnapshotVerifyRepositoryService struct {
client *Client
@@ -68,7 +68,7 @@ func (s *SnapshotVerifyRepositoryService) buildURL() (string, url.Values, error)
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
@@ -105,7 +105,11 @@ func (s *SnapshotVerifyRepositoryService) Do(ctx context.Context) (*SnapshotVeri
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/sort.go b/vendor/gopkg.in/olivere/elastic.v5/sort.go
index 122b69104..7e2b32183 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/sort.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/sort.go
@@ -9,7 +9,7 @@ import "errors"
// -- Sorter --
// Sorter is an interface for sorting strategies, e.g. ScoreSort or FieldSort.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-sort.html.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-sort.html.
type Sorter interface {
Source() (interface{}, error)
}
@@ -23,9 +23,11 @@ type SortInfo struct {
Ascending bool
Missing interface{}
IgnoreUnmapped *bool
+ UnmappedType string
SortMode string
NestedFilter Query
NestedPath string
+ NestedSort *NestedSort // available in 6.1 or later
}
func (info SortInfo) Source() (interface{}, error) {
@@ -41,6 +43,9 @@ func (info SortInfo) Source() (interface{}, error) {
if info.IgnoreUnmapped != nil {
prop["ignore_unmapped"] = *info.IgnoreUnmapped
}
+ if info.UnmappedType != "" {
+ prop["unmapped_type"] = info.UnmappedType
+ }
if info.SortMode != "" {
prop["mode"] = info.SortMode
}
@@ -54,6 +59,13 @@ func (info SortInfo) Source() (interface{}, error) {
if info.NestedPath != "" {
prop["nested_path"] = info.NestedPath
}
+ if info.NestedSort != nil {
+ src, err := info.NestedSort.Source()
+ if err != nil {
+ return nil, err
+ }
+ prop["nested"] = src
+ }
source := make(map[string]interface{})
source[info.Field] = prop
return source, nil
@@ -62,7 +74,7 @@ func (info SortInfo) Source() (interface{}, error) {
// -- SortByDoc --
// SortByDoc sorts by the "_doc" field, as described in
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-scroll.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-scroll.html.
//
// Example:
// ss := elastic.NewSearchSource()
@@ -125,14 +137,14 @@ func (s *ScoreSort) Source() (interface{}, error) {
// FieldSort sorts by a given field.
type FieldSort struct {
Sorter
- fieldName string
- ascending bool
- missing interface{}
- ignoreUnmapped *bool
- unmappedType *string
- sortMode *string
- nestedFilter Query
- nestedPath *string
+ fieldName string
+ ascending bool
+ missing interface{}
+ unmappedType *string
+ sortMode *string
+ nestedFilter Query
+ nestedPath *string
+ nestedSort *NestedSort
}
// NewFieldSort creates a new FieldSort.
@@ -175,13 +187,6 @@ func (s *FieldSort) Missing(missing interface{}) *FieldSort {
return s
}
-// IgnoreUnmapped specifies what happens if the field does not exist in
-// the index. Set it to true to ignore, or set it to false to not ignore (default).
-func (s *FieldSort) IgnoreUnmapped(ignoreUnmapped bool) *FieldSort {
- s.ignoreUnmapped = &ignoreUnmapped
- return s
-}
-
// UnmappedType sets the type to use when the current field is not mapped
// in an index.
func (s *FieldSort) UnmappedType(typ string) *FieldSort {
@@ -211,6 +216,13 @@ func (s *FieldSort) NestedPath(nestedPath string) *FieldSort {
return s
}
+// NestedSort is available starting with 6.1 and will replace NestedFilter
+// and NestedPath.
+func (s *FieldSort) NestedSort(nestedSort *NestedSort) *FieldSort {
+ s.nestedSort = nestedSort
+ return s
+}
+
// Source returns the JSON-serializable data.
func (s *FieldSort) Source() (interface{}, error) {
source := make(map[string]interface{})
@@ -224,9 +236,6 @@ func (s *FieldSort) Source() (interface{}, error) {
if s.missing != nil {
x["missing"] = s.missing
}
- if s.ignoreUnmapped != nil {
- x["ignore_unmapped"] = *s.ignoreUnmapped
- }
if s.unmappedType != nil {
x["unmapped_type"] = *s.unmappedType
}
@@ -243,24 +252,32 @@ func (s *FieldSort) Source() (interface{}, error) {
if s.nestedPath != nil {
x["nested_path"] = *s.nestedPath
}
+ if s.nestedSort != nil {
+ src, err := s.nestedSort.Source()
+ if err != nil {
+ return nil, err
+ }
+ x["nested"] = src
+ }
return source, nil
}
// -- GeoDistanceSort --
// GeoDistanceSort allows for sorting by geographic distance.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-sort.html#_geo_distance_sorting.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-sort.html#_geo_distance_sorting.
type GeoDistanceSort struct {
Sorter
fieldName string
points []*GeoPoint
geohashes []string
- geoDistance *string
+ distanceType *string
unit string
ascending bool
sortMode *string
nestedFilter Query
nestedPath *string
+ nestedSort *NestedSort
}
// NewGeoDistanceSort creates a new sorter for geo distances.
@@ -313,22 +330,27 @@ func (s *GeoDistanceSort) GeoHashes(geohashes ...string) *GeoDistanceSort {
return s
}
-// GeoDistance represents how to compute the distance.
-// It can be sloppy_arc (default), arc, or plane.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-sort.html#_geo_distance_sorting.
-func (s *GeoDistanceSort) GeoDistance(geoDistance string) *GeoDistanceSort {
- s.geoDistance = &geoDistance
- return s
-}
-
// Unit specifies the distance unit to use. It defaults to km.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/common-options.html#distance-units
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/common-options.html#distance-units
// for details.
func (s *GeoDistanceSort) Unit(unit string) *GeoDistanceSort {
s.unit = unit
return s
}
+// GeoDistance is an alias for DistanceType.
+func (s *GeoDistanceSort) GeoDistance(geoDistance string) *GeoDistanceSort {
+ return s.DistanceType(geoDistance)
+}
+
+// DistanceType describes how to compute the distance, e.g. "arc" or "plane".
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-sort.html#geo-sorting
+// for details.
+func (s *GeoDistanceSort) DistanceType(distanceType string) *GeoDistanceSort {
+ s.distanceType = &distanceType
+ return s
+}
+
// SortMode specifies what values to pick in case a document contains
// multiple values for the targeted sort field. Possible values are:
// min, max, sum, and avg.
@@ -351,6 +373,13 @@ func (s *GeoDistanceSort) NestedPath(nestedPath string) *GeoDistanceSort {
return s
}
+// NestedSort is available starting with 6.1 and will replace NestedFilter
+// and NestedPath.
+func (s *GeoDistanceSort) NestedSort(nestedSort *NestedSort) *GeoDistanceSort {
+ s.nestedSort = nestedSort
+ return s
+}
+
// Source returns the JSON-serializable data.
func (s *GeoDistanceSort) Source() (interface{}, error) {
source := make(map[string]interface{})
@@ -370,8 +399,8 @@ func (s *GeoDistanceSort) Source() (interface{}, error) {
if s.unit != "" {
x["unit"] = s.unit
}
- if s.geoDistance != nil {
- x["distance_type"] = *s.geoDistance
+ if s.distanceType != nil {
+ x["distance_type"] = *s.distanceType
}
if s.ascending {
@@ -392,13 +421,20 @@ func (s *GeoDistanceSort) Source() (interface{}, error) {
if s.nestedPath != nil {
x["nested_path"] = *s.nestedPath
}
+ if s.nestedSort != nil {
+ src, err := s.nestedSort.Source()
+ if err != nil {
+ return nil, err
+ }
+ x["nested"] = src
+ }
return source, nil
}
// -- ScriptSort --
// ScriptSort sorts by a custom script. See
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting.html#modules-scripting
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/modules-scripting.html#modules-scripting
// for details about scripting.
type ScriptSort struct {
Sorter
@@ -408,6 +444,7 @@ type ScriptSort struct {
sortMode *string
nestedFilter Query
nestedPath *string
+ nestedSort *NestedSort
}
// NewScriptSort creates and initializes a new ScriptSort.
@@ -466,6 +503,13 @@ func (s *ScriptSort) NestedPath(nestedPath string) *ScriptSort {
return s
}
+// NestedSort is available starting with 6.1 and will replace NestedFilter
+// and NestedPath.
+func (s *ScriptSort) NestedSort(nestedSort *NestedSort) *ScriptSort {
+ s.nestedSort = nestedSort
+ return s
+}
+
// Source returns the JSON-serializable data.
func (s *ScriptSort) Source() (interface{}, error) {
if s.script == nil {
@@ -501,5 +545,70 @@ func (s *ScriptSort) Source() (interface{}, error) {
if s.nestedPath != nil {
x["nested_path"] = *s.nestedPath
}
+ if s.nestedSort != nil {
+ src, err := s.nestedSort.Source()
+ if err != nil {
+ return nil, err
+ }
+ x["nested"] = src
+ }
+ return source, nil
+}
+
+// -- NestedSort --
+
+// NestedSort is used for fields that are inside a nested object.
+// It takes a "path" argument and an optional nested filter that the
+// nested objects should match with in order to be taken into account
+// for sorting.
+//
+// NestedSort is available from 6.1 and replaces nestedFilter and nestedPath
+// in the other sorters.
+type NestedSort struct {
+ Sorter
+ path string
+ filter Query
+ nestedSort *NestedSort
+}
+
+// NewNestedSort creates a new NestedSort.
+func NewNestedSort(path string) *NestedSort {
+ return &NestedSort{path: path}
+}
+
+// Filter sets the filter.
+func (s *NestedSort) Filter(filter Query) *NestedSort {
+ s.filter = filter
+ return s
+}
+
+// NestedSort embeds another level of nested sorting.
+func (s *NestedSort) NestedSort(nestedSort *NestedSort) *NestedSort {
+ s.nestedSort = nestedSort
+ return s
+}
+
+// Source returns the JSON-serializable data.
+func (s *NestedSort) Source() (interface{}, error) {
+ source := make(map[string]interface{})
+
+ if s.path != "" {
+ source["path"] = s.path
+ }
+ if s.filter != nil {
+ src, err := s.filter.Source()
+ if err != nil {
+ return nil, err
+ }
+ source["filter"] = src
+ }
+ if s.nestedSort != nil {
+ src, err := s.nestedSort.Source()
+ if err != nil {
+ return nil, err
+ }
+ source["nested"] = src
+ }
+
return source, nil
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/sort_test.go b/vendor/gopkg.in/olivere/elastic.v5/sort_test.go
index 54e6e1e5b..b54cbd98c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/sort_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/sort_test.go
@@ -166,7 +166,7 @@ func TestGeoDistanceSort(t *testing.T) {
Order(true).
Unit("km").
SortMode("min").
- GeoDistance("sloppy_arc")
+ GeoDistance("plane")
src, err := builder.Source()
if err != nil {
t.Fatal(err)
@@ -176,7 +176,7 @@ func TestGeoDistanceSort(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"_geo_distance":{"distance_type":"sloppy_arc","mode":"min","order":"asc","pin.location":[{"lat":-70,"lon":40}],"unit":"km"}}`
+ expected := `{"_geo_distance":{"distance_type":"plane","mode":"min","order":"asc","pin.location":[{"lat":-70,"lon":40}],"unit":"km"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -187,7 +187,7 @@ func TestGeoDistanceSortOrderDesc(t *testing.T) {
Point(-70, 40).
Unit("km").
SortMode("min").
- GeoDistance("sloppy_arc").
+ GeoDistance("arc").
Desc()
src, err := builder.Source()
if err != nil {
@@ -198,7 +198,7 @@ func TestGeoDistanceSortOrderDesc(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"_geo_distance":{"distance_type":"sloppy_arc","mode":"min","order":"desc","pin.location":[{"lat":-70,"lon":40}],"unit":"km"}}`
+ expected := `{"_geo_distance":{"distance_type":"arc","mode":"min","order":"desc","pin.location":[{"lat":-70,"lon":40}],"unit":"km"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -214,7 +214,7 @@ func TestScriptSort(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"_script":{"order":"asc","script":{"inline":"doc['field_name'].value * factor","params":{"factor":1.1}},"type":"number"}}`
+ expected := `{"_script":{"order":"asc","script":{"params":{"factor":1.1},"source":"doc['field_name'].value * factor"},"type":"number"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -231,7 +231,47 @@ func TestScriptSortOrderDesc(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"_script":{"order":"desc","script":{"inline":"doc['field_name'].value * factor","params":{"factor":1.1}},"type":"number"}}`
+ expected := `{"_script":{"order":"desc","script":{"params":{"factor":1.1},"source":"doc['field_name'].value * factor"},"type":"number"}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestNestedSort(t *testing.T) {
+ builder := NewNestedSort("offer").
+ Filter(NewTermQuery("offer.color", "blue"))
+ src, err := builder.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"filter":{"term":{"offer.color":"blue"}},"path":"offer"}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestFieldSortWithNestedSort(t *testing.T) {
+ builder := NewFieldSort("offer.price").
+ Asc().
+ SortMode("avg").
+ NestedSort(
+ NewNestedSort("offer").Filter(NewTermQuery("offer.color", "blue")),
+ )
+ src, err := builder.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"offer.price":{"mode":"avg","nested":{"filter":{"term":{"offer.color":"blue"}},"path":"offer"},"order":"asc"}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggest.go b/vendor/gopkg.in/olivere/elastic.v5/suggest.go
deleted file mode 100644
index 7249abd5f..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/suggest.go
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/url"
- "strings"
-
- "gopkg.in/olivere/elastic.v5/uritemplates"
-)
-
-// SuggestService returns suggestions for text.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters.html.
-type SuggestService struct {
- client *Client
- pretty bool
- routing string
- preference string
- index []string
- suggesters []Suggester
-}
-
-// NewSuggestService creates a new instance of SuggestService.
-func NewSuggestService(client *Client) *SuggestService {
- builder := &SuggestService{
- client: client,
- }
- return builder
-}
-
-// Index adds one or more indices to use for the suggestion request.
-func (s *SuggestService) Index(index ...string) *SuggestService {
- s.index = append(s.index, index...)
- return s
-}
-
-// Pretty asks Elasticsearch to return indented JSON.
-func (s *SuggestService) Pretty(pretty bool) *SuggestService {
- s.pretty = pretty
- return s
-}
-
-// Routing specifies the routing value.
-func (s *SuggestService) Routing(routing string) *SuggestService {
- s.routing = routing
- return s
-}
-
-// Preference specifies the node or shard the operation should be
-// performed on (default: random).
-func (s *SuggestService) Preference(preference string) *SuggestService {
- s.preference = preference
- return s
-}
-
-// Suggester adds a suggester to the request.
-func (s *SuggestService) Suggester(suggester Suggester) *SuggestService {
- s.suggesters = append(s.suggesters, suggester)
- return s
-}
-
-// buildURL builds the URL for the operation.
-func (s *SuggestService) buildURL() (string, url.Values, error) {
- var err error
- var path string
-
- if len(s.index) > 0 {
- path, err = uritemplates.Expand("/{index}/_suggest", map[string]string{
- "index": strings.Join(s.index, ","),
- })
- } else {
- path = "/_suggest"
- }
- if err != nil {
- return "", url.Values{}, err
- }
-
- // Add query string parameters
- params := url.Values{}
- if s.pretty {
- params.Set("pretty", fmt.Sprintf("%v", s.pretty))
- }
- if s.routing != "" {
- params.Set("routing", s.routing)
- }
- if s.preference != "" {
- params.Set("preference", s.preference)
- }
- return path, params, nil
-}
-
-// Do executes the request.
-func (s *SuggestService) Do(ctx context.Context) (SuggestResult, error) {
- path, params, err := s.buildURL()
- if err != nil {
- return nil, err
- }
-
- // Set body
- body := make(map[string]interface{})
- for _, s := range s.suggesters {
- src, err := s.Source(false)
- if err != nil {
- return nil, err
- }
- body[s.Name()] = src
- }
-
- // Get response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
- if err != nil {
- return nil, err
- }
-
- // There is a _shard object that cannot be deserialized.
- // So we use json.RawMessage instead.
- var suggestions map[string]*json.RawMessage
- if err := s.client.decoder.Decode(res.Body, &suggestions); err != nil {
- return nil, err
- }
-
- ret := make(SuggestResult)
- for name, result := range suggestions {
- if name != "_shards" {
- var sug []Suggestion
- if err := s.client.decoder.Decode(*result, &sug); err != nil {
- return nil, err
- }
- ret[name] = sug
- }
- }
-
- return ret, nil
-}
-
-// SuggestResult is the outcome of SuggestService.Do.
-type SuggestResult map[string][]Suggestion
-
-// Suggestion is a single suggester outcome.
-type Suggestion struct {
- Text string `json:"text"`
- Offset int `json:"offset"`
- Length int `json:"length"`
- Options []suggestionOption `json:"options"`
-}
-
-type suggestionOption struct {
- Text string `json:"text"`
- Score float64 `json:"score"`
- Freq int `json:"freq"`
- Payload interface{} `json:"payload"`
- CollateMatch bool `json:"collate_match"`
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggest_field.go b/vendor/gopkg.in/olivere/elastic.v5/suggest_field.go
index 8e15b4ec2..8405a6f9e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggest_field.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggest_field.go
@@ -67,7 +67,7 @@ func (f *SuggestField) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
- source["context"] = src
+ source["contexts"] = src
default:
ctxq := make(map[string]interface{})
for _, query := range f.contextQueries {
@@ -83,7 +83,7 @@ func (f *SuggestField) MarshalJSON() ([]byte, error) {
ctxq[k] = v
}
}
- source["context"] = ctxq
+ source["contexts"] = ctxq
}
return json.Marshal(source)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggest_field_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggest_field_test.go
index c2ee7fdcf..426875b2f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggest_field_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggest_field_test.go
@@ -22,7 +22,7 @@ func TestSuggestField(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"context":{"color":{"default":["red","green","blue"],"path":"color_field","type":"category"},"location":{"default":{"lat":52.516275,"lon":13.377704},"neighbors":true,"precision":["5m"],"type":"geo"}},"input":["Welcome to Golang and Elasticsearch.","Golang and Elasticsearch"],"weight":1}`
+ expected := `{"contexts":{"color":{"default":["red","green","blue"],"path":"color_field","type":"category"},"location":{"default":{"lat":52.516275,"lon":13.377704},"neighbors":true,"precision":["5m"],"type":"geo"}},"input":["Welcome to Golang and Elasticsearch.","Golang and Elasticsearch"],"weight":1}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggest_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggest_test.go
deleted file mode 100644
index bdc989dbb..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/suggest_test.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "context"
- "testing"
-)
-
-func TestSuggestBuildURL(t *testing.T) {
- client := setupTestClient(t)
-
- tests := []struct {
- Indices []string
- Expected string
- }{
- {
- []string{},
- "/_suggest",
- },
- {
- []string{"index1"},
- "/index1/_suggest",
- },
- {
- []string{"index1", "index2"},
- "/index1%2Cindex2/_suggest",
- },
- }
-
- for i, test := range tests {
- path, _, err := client.Suggest().Index(test.Indices...).buildURL()
- if err != nil {
- t.Errorf("case #%d: %v", i+1, err)
- continue
- }
- if path != test.Expected {
- t.Errorf("case #%d: expected %q; got: %q", i+1, test.Expected, path)
- }
- }
-}
-
-func TestSuggestService(t *testing.T) {
- client := setupTestClientAndCreateIndex(t)
- // client := setupTestClientAndCreateIndex(t, SetTraceLog(log.New(os.Stdout, "", 0)))
-
- tweet1 := tweet{
- User: "olivere",
- Message: "Welcome to Golang and Elasticsearch.",
- Tags: []string{"golang", "elasticsearch"},
- Location: "48.1333,11.5667", // lat,lon
- Suggest: NewSuggestField().
- Input("Welcome to Golang and Elasticsearch.", "Golang and Elasticsearch").
- Weight(0),
- }
- tweet2 := tweet{
- User: "olivere",
- Message: "Another unrelated topic.",
- Tags: []string{"golang"},
- Location: "48.1189,11.4289", // lat,lon
- Suggest: NewSuggestField().
- Input("Another unrelated topic.", "Golang topic.").
- Weight(1),
- }
- tweet3 := tweet{
- User: "sandrae",
- Message: "Cycling is fun.",
- Tags: []string{"sports", "cycling"},
- Location: "47.7167,11.7167", // lat,lon
- Suggest: NewSuggestField().
- Input("Cycling is fun."),
- }
-
- // Add all documents
- _, err := client.Index().Index(testIndexName).Type("tweet").Id("1").BodyJson(&tweet1).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
-
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("2").BodyJson(&tweet2).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
-
- _, err = client.Index().Index(testIndexName).Type("tweet").Id("3").BodyJson(&tweet3).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
-
- _, err = client.Flush().Index(testIndexName).Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
-
- // Test _suggest endpoint
- termSuggesterName := "my-term-suggester"
- termSuggester := NewTermSuggester(termSuggesterName).Text("Goolang").Field("message")
- phraseSuggesterName := "my-phrase-suggester"
- phraseSuggester := NewPhraseSuggester(phraseSuggesterName).Text("Goolang").Field("message")
- completionSuggesterName := "my-completion-suggester"
- completionSuggester := NewCompletionSuggester(completionSuggesterName).Text("Go").Field("suggest_field")
-
- result, err := client.Suggest().
- Index(testIndexName).
- Suggester(termSuggester).
- Suggester(phraseSuggester).
- Suggester(completionSuggester).
- Do(context.TODO())
- if err != nil {
- t.Fatal(err)
- }
- if result == nil {
- t.Errorf("expected result != nil; got nil")
- }
- if len(result) != 3 {
- t.Errorf("expected 3 suggester results; got %d", len(result))
- }
-
- termSuggestions, found := result[termSuggesterName]
- if !found {
- t.Errorf("expected to find Suggest[%s]; got false", termSuggesterName)
- }
- if termSuggestions == nil {
- t.Errorf("expected Suggest[%s] != nil; got nil", termSuggesterName)
- }
- if len(termSuggestions) != 1 {
- t.Errorf("expected 1 suggestion; got %d", len(termSuggestions))
- }
-
- phraseSuggestions, found := result[phraseSuggesterName]
- if !found {
- t.Errorf("expected to find Suggest[%s]; got false", phraseSuggesterName)
- }
- if phraseSuggestions == nil {
- t.Errorf("expected Suggest[%s] != nil; got nil", phraseSuggesterName)
- }
- if len(phraseSuggestions) != 1 {
- t.Errorf("expected 1 suggestion; got %d", len(phraseSuggestions))
- }
-
- completionSuggestions, found := result[completionSuggesterName]
- if !found {
- t.Errorf("expected to find Suggest[%s]; got false", completionSuggesterName)
- }
- if completionSuggestions == nil {
- t.Errorf("expected Suggest[%s] != nil; got nil", completionSuggesterName)
- }
- if len(completionSuggestions) != 1 {
- t.Errorf("expected 1 suggestion; got %d", len(completionSuggestions))
- }
- if len(completionSuggestions[0].Options) != 2 {
- t.Errorf("expected 2 suggestion options; got %d", len(completionSuggestions[0].Options))
- }
- if have, want := completionSuggestions[0].Options[0].Text, "Golang topic."; have != want {
- t.Errorf("expected Suggest[%s][0].Options[0].Text == %q; got %q", completionSuggesterName, want, have)
- }
- if have, want := completionSuggestions[0].Options[1].Text, "Golang and Elasticsearch"; have != want {
- t.Errorf("expected Suggest[%s][0].Options[1].Text == %q; got %q", completionSuggesterName, want, have)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
index 1da6063a6..d2b4a326c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
@@ -13,18 +13,24 @@ type CompletionSuggester struct {
Suggester
name string
text string
+ prefix string
+ regex string
field string
analyzer string
size *int
shardSize *int
contextQueries []SuggesterContextQuery
+ payload interface{}
+
+ fuzzyOptions *FuzzyCompletionSuggesterOptions
+ regexOptions *RegexCompletionSuggesterOptions
+ skipDuplicates *bool
}
// Creates a new completion suggester.
func NewCompletionSuggester(name string) *CompletionSuggester {
return &CompletionSuggester{
- name: name,
- contextQueries: make([]SuggesterContextQuery, 0),
+ name: name,
}
}
@@ -37,6 +43,57 @@ func (q *CompletionSuggester) Text(text string) *CompletionSuggester {
return q
}
+func (q *CompletionSuggester) Prefix(prefix string) *CompletionSuggester {
+ q.prefix = prefix
+ return q
+}
+
+func (q *CompletionSuggester) PrefixWithEditDistance(prefix string, editDistance interface{}) *CompletionSuggester {
+ q.prefix = prefix
+ q.fuzzyOptions = NewFuzzyCompletionSuggesterOptions().EditDistance(editDistance)
+ return q
+}
+
+func (q *CompletionSuggester) PrefixWithOptions(prefix string, options *FuzzyCompletionSuggesterOptions) *CompletionSuggester {
+ q.prefix = prefix
+ q.fuzzyOptions = options
+ return q
+}
+
+func (q *CompletionSuggester) FuzzyOptions(options *FuzzyCompletionSuggesterOptions) *CompletionSuggester {
+ q.fuzzyOptions = options
+ return q
+}
+
+func (q *CompletionSuggester) Fuzziness(fuzziness interface{}) *CompletionSuggester {
+ if q.fuzzyOptions == nil {
+ q.fuzzyOptions = NewFuzzyCompletionSuggesterOptions()
+ }
+ q.fuzzyOptions = q.fuzzyOptions.EditDistance(fuzziness)
+ return q
+}
+
+func (q *CompletionSuggester) Regex(regex string) *CompletionSuggester {
+ q.regex = regex
+ return q
+}
+
+func (q *CompletionSuggester) RegexWithOptions(regex string, options *RegexCompletionSuggesterOptions) *CompletionSuggester {
+ q.regex = regex
+ q.regexOptions = options
+ return q
+}
+
+func (q *CompletionSuggester) RegexOptions(options *RegexCompletionSuggesterOptions) *CompletionSuggester {
+ q.regexOptions = options
+ return q
+}
+
+func (q *CompletionSuggester) SkipDuplicates(skipDuplicates bool) *CompletionSuggester {
+ q.skipDuplicates = &skipDuplicates
+ return q
+}
+
func (q *CompletionSuggester) Field(field string) *CompletionSuggester {
q.field = field
return q
@@ -72,17 +129,25 @@ func (q *CompletionSuggester) ContextQueries(queries ...SuggesterContextQuery) *
// We got into trouble when using plain maps because the text element
// needs to go before the completion element.
type completionSuggesterRequest struct {
- Text string `json:"text"`
- Completion interface{} `json:"completion"`
+ Text string `json:"text,omitempty"`
+ Prefix string `json:"prefix,omitempty"`
+ Regex string `json:"regex,omitempty"`
+ Completion interface{} `json:"completion,omitempty"`
}
-// Creates the source for the completion suggester.
+// Source creates the JSON data for the completion suggester.
func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
cs := &completionSuggesterRequest{}
if q.text != "" {
cs.Text = q.text
}
+ if q.prefix != "" {
+ cs.Prefix = q.prefix
+ }
+ if q.regex != "" {
+ cs.Regex = q.regex
+ }
suggester := make(map[string]interface{})
cs.Completion = suggester
@@ -106,7 +171,7 @@ func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
if err != nil {
return nil, err
}
- suggester["context"] = src
+ suggester["contexts"] = src
default:
ctxq := make(map[string]interface{})
for _, query := range q.contextQueries {
@@ -126,6 +191,28 @@ func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
suggester["contexts"] = ctxq
}
+ // Fuzzy options
+ if q.fuzzyOptions != nil {
+ src, err := q.fuzzyOptions.Source()
+ if err != nil {
+ return nil, err
+ }
+ suggester["fuzzy"] = src
+ }
+
+ // Regex options
+ if q.regexOptions != nil {
+ src, err := q.regexOptions.Source()
+ if err != nil {
+ return nil, err
+ }
+ suggester["regex"] = src
+ }
+
+ if q.skipDuplicates != nil {
+ suggester["skip_duplicates"] = *q.skipDuplicates
+ }
+
// TODO(oe) Add completion-suggester specific parameters here
if !includeName {
@@ -136,3 +223,130 @@ func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
source[q.name] = cs
return source, nil
}
+
+// -- Fuzzy options --
+
+// FuzzyCompletionSuggesterOptions represents the options for fuzzy completion suggester.
+type FuzzyCompletionSuggesterOptions struct {
+ editDistance interface{}
+ transpositions *bool
+ minLength *int
+ prefixLength *int
+ unicodeAware *bool
+ maxDeterminizedStates *int
+}
+
+// NewFuzzyCompletionSuggesterOptions initializes a new FuzzyCompletionSuggesterOptions instance.
+func NewFuzzyCompletionSuggesterOptions() *FuzzyCompletionSuggesterOptions {
+ return &FuzzyCompletionSuggesterOptions{}
+}
+
+// EditDistance specifies the maximum number of edits, e.g. a number like "1" or "2"
+// or a string like "0..2" or ">5". See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#fuzziness
+// for details.
+func (o *FuzzyCompletionSuggesterOptions) EditDistance(editDistance interface{}) *FuzzyCompletionSuggesterOptions {
+ o.editDistance = editDistance
+ return o
+}
+
+// Transpositions, if set to true, are counted as one change instead of two (defaults to true).
+func (o *FuzzyCompletionSuggesterOptions) Transpositions(transpositions bool) *FuzzyCompletionSuggesterOptions {
+ o.transpositions = &transpositions
+ return o
+}
+
+// MinLength represents the minimum length of the input before fuzzy suggestions are returned (defaults to 3).
+func (o *FuzzyCompletionSuggesterOptions) MinLength(minLength int) *FuzzyCompletionSuggesterOptions {
+ o.minLength = &minLength
+ return o
+}
+
+// PrefixLength represents the minimum length of the input, which is not checked for
+// fuzzy alternatives (defaults to 1).
+func (o *FuzzyCompletionSuggesterOptions) PrefixLength(prefixLength int) *FuzzyCompletionSuggesterOptions {
+ o.prefixLength = &prefixLength
+ return o
+}
+
+// UnicodeAware, if true, all measurements (like fuzzy edit distance, transpositions, and lengths)
+// are measured in Unicode code points instead of in bytes. This is slightly slower than
+// raw bytes, so it is set to false by default.
+func (o *FuzzyCompletionSuggesterOptions) UnicodeAware(unicodeAware bool) *FuzzyCompletionSuggesterOptions {
+ o.unicodeAware = &unicodeAware
+ return o
+}
+
+// MaxDeterminizedStates is currently undocumented in Elasticsearch. It represents
+// the maximum automaton states allowed for fuzzy expansion.
+func (o *FuzzyCompletionSuggesterOptions) MaxDeterminizedStates(max int) *FuzzyCompletionSuggesterOptions {
+ o.maxDeterminizedStates = &max
+ return o
+}
+
+// Source creates the JSON data.
+func (o *FuzzyCompletionSuggesterOptions) Source() (interface{}, error) {
+ out := make(map[string]interface{})
+
+ if o.editDistance != nil {
+ out["fuzziness"] = o.editDistance
+ }
+ if o.transpositions != nil {
+ out["transpositions"] = *o.transpositions
+ }
+ if o.minLength != nil {
+ out["min_length"] = *o.minLength
+ }
+ if o.prefixLength != nil {
+ out["prefix_length"] = *o.prefixLength
+ }
+ if o.unicodeAware != nil {
+ out["unicode_aware"] = *o.unicodeAware
+ }
+ if o.maxDeterminizedStates != nil {
+ out["max_determinized_states"] = *o.maxDeterminizedStates
+ }
+
+ return out, nil
+}
+
+// -- Regex options --
+
+// RegexCompletionSuggesterOptions represents the options for regex completion suggester.
+type RegexCompletionSuggesterOptions struct {
+ flags interface{} // string or int
+ maxDeterminizedStates *int
+}
+
+// NewRegexCompletionSuggesterOptions initializes a new RegexCompletionSuggesterOptions instance.
+func NewRegexCompletionSuggesterOptions() *RegexCompletionSuggesterOptions {
+ return &RegexCompletionSuggesterOptions{}
+}
+
+// Flags represents internal regex flags. See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-suggesters-completion.html#regex
+// for details.
+func (o *RegexCompletionSuggesterOptions) Flags(flags interface{}) *RegexCompletionSuggesterOptions {
+ o.flags = flags
+ return o
+}
+
+// MaxDeterminizedStates represents the maximum automaton states allowed for regex expansion.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-suggesters-completion.html#regex
+// for details.
+func (o *RegexCompletionSuggesterOptions) MaxDeterminizedStates(max int) *RegexCompletionSuggesterOptions {
+ o.maxDeterminizedStates = &max
+ return o
+}
+
+// Source creates the JSON data.
+func (o *RegexCompletionSuggesterOptions) Source() (interface{}, error) {
+ out := make(map[string]interface{})
+
+ if o.flags != nil {
+ out["flags"] = o.flags
+ }
+ if o.maxDeterminizedStates != nil {
+ out["max_determinized_states"] = *o.maxDeterminizedStates
+ }
+
+ return out, nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy.go
deleted file mode 100644
index e2c06a25f..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy.go
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-// FuzzyFuzzyCompletionSuggester is a FuzzyCompletionSuggester that allows fuzzy
-// completion.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-completion.html
-// for details, and
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-completion.html#fuzzy
-// for details about the fuzzy completion suggester.
-type FuzzyCompletionSuggester struct {
- Suggester
- name string
- text string
- field string
- analyzer string
- size *int
- shardSize *int
- contextQueries []SuggesterContextQuery
-
- fuzziness interface{}
- fuzzyTranspositions *bool
- fuzzyMinLength *int
- fuzzyPrefixLength *int
- unicodeAware *bool
-}
-
-// Fuzziness defines the fuzziness which is used in FuzzyCompletionSuggester.
-type Fuzziness struct {
-}
-
-// Creates a new completion suggester.
-func NewFuzzyCompletionSuggester(name string) *FuzzyCompletionSuggester {
- return &FuzzyCompletionSuggester{
- name: name,
- contextQueries: make([]SuggesterContextQuery, 0),
- }
-}
-
-func (q *FuzzyCompletionSuggester) Name() string {
- return q.name
-}
-
-func (q *FuzzyCompletionSuggester) Text(text string) *FuzzyCompletionSuggester {
- q.text = text
- return q
-}
-
-func (q *FuzzyCompletionSuggester) Field(field string) *FuzzyCompletionSuggester {
- q.field = field
- return q
-}
-
-func (q *FuzzyCompletionSuggester) Analyzer(analyzer string) *FuzzyCompletionSuggester {
- q.analyzer = analyzer
- return q
-}
-
-func (q *FuzzyCompletionSuggester) Size(size int) *FuzzyCompletionSuggester {
- q.size = &size
- return q
-}
-
-func (q *FuzzyCompletionSuggester) ShardSize(shardSize int) *FuzzyCompletionSuggester {
- q.shardSize = &shardSize
- return q
-}
-
-func (q *FuzzyCompletionSuggester) ContextQuery(query SuggesterContextQuery) *FuzzyCompletionSuggester {
- q.contextQueries = append(q.contextQueries, query)
- return q
-}
-
-func (q *FuzzyCompletionSuggester) ContextQueries(queries ...SuggesterContextQuery) *FuzzyCompletionSuggester {
- q.contextQueries = append(q.contextQueries, queries...)
- return q
-}
-
-// Fuzziness defines the strategy used to describe what "fuzzy" actually
-// means for the suggester, e.g. 1, 2, "0", "1..2", ">4", or "AUTO".
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/common-options.html#fuzziness
-// for a detailed description.
-func (q *FuzzyCompletionSuggester) Fuzziness(fuzziness interface{}) *FuzzyCompletionSuggester {
- q.fuzziness = fuzziness
- return q
-}
-
-func (q *FuzzyCompletionSuggester) FuzzyTranspositions(fuzzyTranspositions bool) *FuzzyCompletionSuggester {
- q.fuzzyTranspositions = &fuzzyTranspositions
- return q
-}
-
-func (q *FuzzyCompletionSuggester) FuzzyMinLength(minLength int) *FuzzyCompletionSuggester {
- q.fuzzyMinLength = &minLength
- return q
-}
-
-func (q *FuzzyCompletionSuggester) FuzzyPrefixLength(prefixLength int) *FuzzyCompletionSuggester {
- q.fuzzyPrefixLength = &prefixLength
- return q
-}
-
-func (q *FuzzyCompletionSuggester) UnicodeAware(unicodeAware bool) *FuzzyCompletionSuggester {
- q.unicodeAware = &unicodeAware
- return q
-}
-
-// Creates the source for the completion suggester.
-func (q *FuzzyCompletionSuggester) Source(includeName bool) (interface{}, error) {
- cs := &completionSuggesterRequest{}
-
- if q.text != "" {
- cs.Text = q.text
- }
-
- suggester := make(map[string]interface{})
- cs.Completion = suggester
-
- if q.analyzer != "" {
- suggester["analyzer"] = q.analyzer
- }
- if q.field != "" {
- suggester["field"] = q.field
- }
- if q.size != nil {
- suggester["size"] = *q.size
- }
- if q.shardSize != nil {
- suggester["shard_size"] = *q.shardSize
- }
- switch len(q.contextQueries) {
- case 0:
- case 1:
- src, err := q.contextQueries[0].Source()
- if err != nil {
- return nil, err
- }
- suggester["context"] = src
- default:
- var ctxq []interface{}
- for _, query := range q.contextQueries {
- src, err := query.Source()
- if err != nil {
- return nil, err
- }
- ctxq = append(ctxq, src)
- }
- suggester["context"] = ctxq
- }
-
- // Fuzzy Completion Suggester fields
- fuzzy := make(map[string]interface{})
- suggester["fuzzy"] = fuzzy
- if q.fuzziness != nil {
- fuzzy["fuzziness"] = q.fuzziness
- }
- if q.fuzzyTranspositions != nil {
- fuzzy["transpositions"] = *q.fuzzyTranspositions
- }
- if q.fuzzyMinLength != nil {
- fuzzy["min_length"] = *q.fuzzyMinLength
- }
- if q.fuzzyPrefixLength != nil {
- fuzzy["prefix_length"] = *q.fuzzyPrefixLength
- }
- if q.unicodeAware != nil {
- fuzzy["unicode_aware"] = *q.unicodeAware
- }
-
- if !includeName {
- return cs, nil
- }
-
- source := make(map[string]interface{})
- source[q.name] = cs
- return source, nil
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy_test.go
deleted file mode 100644
index aae1db11b..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_fuzzy_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2012-present Oliver Eilhard. All rights reserved.
-// Use of this source code is governed by a MIT-license.
-// See http://olivere.mit-license.org/license.txt for details.
-
-package elastic
-
-import (
- "encoding/json"
- "testing"
-)
-
-func TestFuzzyCompletionSuggesterSource(t *testing.T) {
- s := NewFuzzyCompletionSuggester("song-suggest").
- Text("n").
- Field("suggest").
- Fuzziness(2)
- src, err := s.Source(true)
- if err != nil {
- t.Fatal(err)
- }
- data, err := json.Marshal(src)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"song-suggest":{"text":"n","completion":{"field":"suggest","fuzzy":{"fuzziness":2}}}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
-
-func TestFuzzyCompletionSuggesterWithStringFuzzinessSource(t *testing.T) {
- s := NewFuzzyCompletionSuggester("song-suggest").
- Text("n").
- Field("suggest").
- Fuzziness("1..4")
- src, err := s.Source(true)
- if err != nil {
- t.Fatal(err)
- }
- data, err := json.Marshal(src)
- if err != nil {
- t.Fatalf("marshaling to JSON failed: %v", err)
- }
- got := string(data)
- expected := `{"song-suggest":{"text":"n","completion":{"field":"suggest","fuzzy":{"fuzziness":"1..4"}}}}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
- }
-}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
index 6bffddfe7..adbf58657 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
@@ -28,6 +28,64 @@ func TestCompletionSuggesterSource(t *testing.T) {
}
}
+func TestCompletionSuggesterPrefixSource(t *testing.T) {
+ s := NewCompletionSuggester("song-suggest").
+ Prefix("nir").
+ Field("suggest")
+ src, err := s.Source(true)
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"song-suggest":{"prefix":"nir","completion":{"field":"suggest"}}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestCompletionSuggesterPrefixWithFuzzySource(t *testing.T) {
+ s := NewCompletionSuggester("song-suggest").
+ Prefix("nor").
+ Field("suggest").
+ FuzzyOptions(NewFuzzyCompletionSuggesterOptions().EditDistance(2))
+ src, err := s.Source(true)
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"song-suggest":{"prefix":"nor","completion":{"field":"suggest","fuzzy":{"fuzziness":2}}}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestCompletionSuggesterRegexSource(t *testing.T) {
+ s := NewCompletionSuggester("song-suggest").
+ Regex("n[ever|i]r").
+ Field("suggest")
+ src, err := s.Source(true)
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"song-suggest":{"regex":"n[ever|i]r","completion":{"field":"suggest"}}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
func TestCompletionSuggesterSourceWithMultipleContexts(t *testing.T) {
s := NewCompletionSuggester("song-suggest").
Text("n").
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context.go
index ade099151..12877c1a6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context.go
@@ -13,7 +13,7 @@ type SuggesterContextQuery interface {
}
// ContextSuggester is a fast suggester for e.g. type-ahead completion that supports filtering and boosting based on contexts.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/suggester-context.html
// for more details.
type ContextSuggester struct {
Suggester
@@ -94,7 +94,7 @@ func (q *ContextSuggester) Source(includeName bool) (interface{}, error) {
if err != nil {
return nil, err
}
- suggester["context"] = src
+ suggester["contexts"] = src
default:
ctxq := make(map[string]interface{})
for _, query := range q.contextQueries {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
index 2d63fe8fb..9c50651fa 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
@@ -7,7 +7,7 @@ package elastic
// -- SuggesterCategoryMapping --
// SuggesterCategoryMapping provides a mapping for a category context in a suggester.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/suggester-context.html#_category_mapping.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/suggester-context.html#_category_mapping.
type SuggesterCategoryMapping struct {
name string
fieldName string
@@ -59,7 +59,7 @@ func (q *SuggesterCategoryMapping) Source() (interface{}, error) {
// -- SuggesterCategoryQuery --
// SuggesterCategoryQuery provides querying a category context in a suggester.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/suggester-context.html#_category_query.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/suggester-context.html#_category_query.
type SuggesterCategoryQuery struct {
name string
values map[string]*int
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_geo.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_geo.go
index 6815bfe73..3fea63feb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_geo.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_geo.go
@@ -7,7 +7,7 @@ package elastic
// -- SuggesterGeoMapping --
// SuggesterGeoMapping provides a mapping for a geolocation context in a suggester.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/suggester-context.html#_geo_location_mapping.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/suggester-context.html#_geo_location_mapping.
type SuggesterGeoMapping struct {
name string
defaultLocations []*GeoPoint
@@ -80,7 +80,7 @@ func (q *SuggesterGeoMapping) Source() (interface{}, error) {
// -- SuggesterGeoQuery --
// SuggesterGeoQuery provides querying a geolocation context in a suggester.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/suggester-context.html#_geo_location_query
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/suggester-context.html#_geo_location_query
type SuggesterGeoQuery struct {
name string
location *GeoPoint
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_test.go
index cd3c5586c..045ccb2f4 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_test.go
@@ -45,9 +45,9 @@ func TestContextSuggesterSourceWithMultipleContexts(t *testing.T) {
}
got := string(data)
// Due to the randomization of dictionary key, we could actually have two different valid expected outcomes
- expected := `{"place_suggestion":{"prefix":"tim","completion":{"context":{"place_type":[{"context":"cafe"},{"context":"restaurants"}]},"field":"suggest"}}}`
+ expected := `{"place_suggestion":{"prefix":"tim","completion":{"contexts":{"place_type":[{"context":"cafe"},{"context":"restaurants"}]},"field":"suggest"}}}`
if got != expected {
- expected := `{"place_suggestion":{"prefix":"tim","completion":{"context":{"place_type":[{"context":"restaurants"},{"context":"cafe"}]},"field":"suggest"}}}`
+ expected := `{"place_suggestion":{"prefix":"tim","completion":{"contexts":{"place_type":[{"context":"restaurants"},{"context":"cafe"}]},"field":"suggest"}}}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase.go
index f75e1ddc1..2f6b6a326 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase.go
@@ -7,7 +7,7 @@ package elastic
// PhraseSuggester provides an API to access word alternatives
// on a per token basis within a certain string distance.
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-phrase.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-phrase.html.
type PhraseSuggester struct {
Suggester
name string
@@ -213,7 +213,7 @@ func (q *PhraseSuggester) Source(includeName bool) (interface{}, error) {
if err != nil {
return nil, err
}
- suggester["context"] = src
+ suggester["contexts"] = src
default:
var ctxq []interface{}
for _, query := range q.contextQueries {
@@ -223,7 +223,7 @@ func (q *PhraseSuggester) Source(includeName bool) (interface{}, error) {
}
ctxq = append(ctxq, src)
}
- suggester["context"] = ctxq
+ suggester["contexts"] = ctxq
}
// Phase-specified parameters
@@ -312,7 +312,7 @@ type SmoothingModel interface {
}
// StupidBackoffSmoothingModel implements a stupid backoff smoothing model.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-phrase.html#_smoothing_models
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-phrase.html#_smoothing_models
// for details about smoothing models.
type StupidBackoffSmoothingModel struct {
discount float64
@@ -337,7 +337,7 @@ func (sm *StupidBackoffSmoothingModel) Source() (interface{}, error) {
// --
// LaplaceSmoothingModel implements a laplace smoothing model.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-phrase.html#_smoothing_models
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-phrase.html#_smoothing_models
// for details about smoothing models.
type LaplaceSmoothingModel struct {
alpha float64
@@ -363,7 +363,7 @@ func (sm *LaplaceSmoothingModel) Source() (interface{}, error) {
// LinearInterpolationSmoothingModel implements a linear interpolation
// smoothing model.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-phrase.html#_smoothing_models
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-phrase.html#_smoothing_models
// for details about smoothing models.
type LinearInterpolationSmoothingModel struct {
trigramLamda float64
@@ -399,7 +399,7 @@ type CandidateGenerator interface {
}
// DirectCandidateGenerator implements a direct candidate generator.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-phrase.html#_smoothing_models
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-phrase.html#_smoothing_models
// for details about smoothing models.
type DirectCandidateGenerator struct {
field string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase_test.go
index fbcc676fe..63dde686e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_phrase_test.go
@@ -60,7 +60,7 @@ func TestPhraseSuggesterSourceWithContextQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"name":{"text":"Xor the Got-Jewel","phrase":{"analyzer":"body","context":{"location":{"default":{"lat":0,"lon":0},"neighbors":true,"path":"pin","precision":["1km","5m"],"type":"geo"}},"field":"bigram","gram_size":2,"highlight":{"post_tag":"\u003c/em\u003e","pre_tag":"\u003cem\u003e"},"max_errors":0.5,"real_word_error_likelihood":0.95,"size":1}}}`
+ expected := `{"name":{"text":"Xor the Got-Jewel","phrase":{"analyzer":"body","contexts":{"location":{"default":{"lat":0,"lon":0},"neighbors":true,"path":"pin","precision":["1km","5m"],"type":"geo"}},"field":"bigram","gram_size":2,"highlight":{"post_tag":"\u003c/em\u003e","pre_tag":"\u003cem\u003e"},"max_errors":0.5,"real_word_error_likelihood":0.95,"size":1}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_term.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_term.go
index 9c199f69d..69e1531f6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_term.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_term.go
@@ -6,7 +6,7 @@ package elastic
// TermSuggester suggests terms based on edit distance.
// For more details, see
-// https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-term.html.
+// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-suggesters-term.html.
type TermSuggester struct {
Suggester
name string
@@ -178,7 +178,7 @@ func (q *TermSuggester) Source(includeName bool) (interface{}, error) {
if err != nil {
return nil, err
}
- suggester["context"] = src
+ suggester["contexts"] = src
default:
ctxq := make([]interface{}, len(q.contextQueries))
for i, query := range q.contextQueries {
@@ -188,7 +188,7 @@ func (q *TermSuggester) Source(includeName bool) (interface{}, error) {
}
ctxq[i] = src
}
- suggester["context"] = ctxq
+ suggester["contexts"] = ctxq
}
// Specific to term suggester
diff --git a/vendor/gopkg.in/olivere/elastic.v5/tasks_cancel.go b/vendor/gopkg.in/olivere/elastic.v5/tasks_cancel.go
index 2c74fd87e..84f8aec35 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/tasks_cancel.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/tasks_cancel.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// TasksCancelService can cancel long-running tasks.
@@ -95,7 +95,7 @@ func (s *TasksCancelService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.actions) > 0 {
params.Set("actions", strings.Join(s.actions, ","))
@@ -131,7 +131,11 @@ func (s *TasksCancelService) Do(ctx context.Context) (*TasksListResponse, error)
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/tasks_get_task.go b/vendor/gopkg.in/olivere/elastic.v5/tasks_get_task.go
index 5368169ec..5f63726e4 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/tasks_get_task.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/tasks_get_task.go
@@ -5,7 +5,7 @@ import (
"fmt"
"net/url"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// TasksGetTaskService retrieves the state of a task in the cluster. It is part of the Task Management API
@@ -85,7 +85,11 @@ func (s *TasksGetTaskService) Do(ctx context.Context) (*TasksGetTaskResponse, er
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go b/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
index d68bc21fb..54299d961 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
@@ -10,38 +10,36 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// TasksListService retrieves the list of currently executing tasks
// on one ore more nodes in the cluster. It is part of the Task Management API
-// documented at http://www.elastic.co/guide/en/elasticsearch/reference/5.2/tasks-list.html.
+// documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/tasks.html.
//
// It is supported as of Elasticsearch 2.3.0.
type TasksListService struct {
client *Client
pretty bool
- taskId []int64
+ taskId []string
actions []string
detailed *bool
nodeId []string
parentNode string
- parentTask *int64
+ parentTaskId *string
waitForCompletion *bool
+ groupBy string
}
// NewTasksListService creates a new TasksListService.
func NewTasksListService(client *Client) *TasksListService {
return &TasksListService{
- client: client,
- taskId: make([]int64, 0),
- actions: make([]string, 0),
- nodeId: make([]string, 0),
+ client: client,
}
}
// TaskId indicates to returns the task(s) with specified id(s).
-func (s *TasksListService) TaskId(taskId ...int64) *TasksListService {
+func (s *TasksListService) TaskId(taskId ...string) *TasksListService {
s.taskId = append(s.taskId, taskId...)
return s
}
@@ -72,9 +70,9 @@ func (s *TasksListService) ParentNode(parentNode string) *TasksListService {
return s
}
-// ParentTask returns tasks with specified parent task id. Set to -1 to return all.
-func (s *TasksListService) ParentTask(parentTask int64) *TasksListService {
- s.parentTask = &parentTask
+// ParentTaskId returns tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
+func (s *TasksListService) ParentTaskId(parentTaskId string) *TasksListService {
+ s.parentTaskId = &parentTaskId
return s
}
@@ -85,6 +83,13 @@ func (s *TasksListService) WaitForCompletion(waitForCompletion bool) *TasksListS
return s
}
+// GroupBy groups tasks by nodes or parent/child relationships.
+// As of now, it can either be "nodes" (default) or "parents".
+func (s *TasksListService) GroupBy(groupBy string) *TasksListService {
+ s.groupBy = groupBy
+ return s
+}
+
// Pretty indicates that the JSON response be indented and human readable.
func (s *TasksListService) Pretty(pretty bool) *TasksListService {
s.pretty = pretty
@@ -97,12 +102,8 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
var err error
var path string
if len(s.taskId) > 0 {
- var tasks []string
- for _, taskId := range s.taskId {
- tasks = append(tasks, fmt.Sprintf("%d", taskId))
- }
path, err = uritemplates.Expand("/_tasks/{task_id}", map[string]string{
- "task_id": strings.Join(tasks, ","),
+ "task_id": strings.Join(s.taskId, ","),
})
} else {
path = "/_tasks"
@@ -114,7 +115,7 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.actions) > 0 {
params.Set("actions", strings.Join(s.actions, ","))
@@ -128,12 +129,15 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
if s.parentNode != "" {
params.Set("parent_node", s.parentNode)
}
- if s.parentTask != nil {
- params.Set("parent_task", fmt.Sprintf("%v", *s.parentTask))
+ if s.parentTaskId != nil {
+ params.Set("parent_task_id", *s.parentTaskId)
}
if s.waitForCompletion != nil {
params.Set("wait_for_completion", fmt.Sprintf("%v", *s.waitForCompletion))
}
+ if s.groupBy != "" {
+ params.Set("group_by", s.groupBy)
+ }
return path, params, nil
}
@@ -156,7 +160,11 @@ func (s *TasksListService) Do(ctx context.Context) (*TasksListResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -178,7 +186,7 @@ type TasksListResponse struct {
}
type TaskOperationFailure struct {
- TaskId int64 `json:"task_id"`
+ TaskId int64 `json:"task_id"` // this is a long in the Java source
NodeId string `json:"node_id"`
Status string `json:"status"`
Reason *ErrorDetails `json:"reason"`
@@ -194,14 +202,16 @@ type DiscoveryNode struct {
TransportAddress string `json:"transport_address"`
Host string `json:"host"`
IP string `json:"ip"`
+ Roles []string `json:"roles"` // "master", "data", or "ingest"
Attributes map[string]interface{} `json:"attributes"`
// Tasks returns the tasks by its id (as a string).
Tasks map[string]*TaskInfo `json:"tasks"`
}
+// TaskInfo represents information about a currently running task.
type TaskInfo struct {
Node string `json:"node"`
- Id int64 `json:"id"` // the task id
+ Id int64 `json:"id"` // the task id (yes, this is a long in the Java source)
Type string `json:"type"`
Action string `json:"action"`
Status interface{} `json:"status"` // has separate implementations of Task.Status in Java for reindexing, replication, and "RawTaskStatus"
diff --git a/vendor/gopkg.in/olivere/elastic.v5/tasks_list_test.go b/vendor/gopkg.in/olivere/elastic.v5/tasks_list_test.go
index e14bc6e43..9ecabcd68 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/tasks_list_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/tasks_list_test.go
@@ -13,19 +13,19 @@ func TestTasksListBuildURL(t *testing.T) {
client := setupTestClient(t)
tests := []struct {
- TaskId []int64
+ TaskId []string
Expected string
}{
{
- []int64{},
+ []string{},
"/_tasks",
},
{
- []int64{42},
+ []string{"42"},
"/_tasks/42",
},
{
- []int64{42, 37},
+ []string{"42", "37"},
"/_tasks/42%2C37",
},
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/termvectors.go b/vendor/gopkg.in/olivere/elastic.v5/termvectors.go
index 6bbcf8f3b..5943ad14f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/termvectors.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/termvectors.go
@@ -10,14 +10,14 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// TermvectorsService returns information and statistics on terms in the
// fields of a particular document. The document could be stored in the
// index or artificially provided by the user.
//
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-termvectors.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-termvectors.html
// for documentation.
type TermvectorsService struct {
client *Client
@@ -169,7 +169,7 @@ func (s *TermvectorsService) Version(version interface{}) *TermvectorsService {
return s
}
-// VersionType specifies a version type ("internal", "external", "external_gte", or "force").
+// VersionType specifies a version type ("internal", "external", or "external_gte").
func (s *TermvectorsService) VersionType(versionType string) *TermvectorsService {
s.versionType = versionType
return s
@@ -217,7 +217,7 @@ func (s *TermvectorsService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if s.dfs != nil {
params.Set("dfs", fmt.Sprintf("%v", *s.dfs))
@@ -316,7 +316,12 @@ func (s *TermvectorsService) Do(ctx context.Context) (*TermvectorsResponse, erro
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -333,7 +338,7 @@ func (s *TermvectorsService) Do(ctx context.Context) (*TermvectorsResponse, erro
// TermvectorsFilterSettings adds additional filters to a Termsvector request.
// It allows to filter terms based on their tf-idf scores.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-termvectors.html#_terms_filtering
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-termvectors.html#_terms_filtering
// for more information.
type TermvectorsFilterSettings struct {
maxNumTerms *int64
diff --git a/vendor/gopkg.in/olivere/elastic.v5/termvectors_test.go b/vendor/gopkg.in/olivere/elastic.v5/termvectors_test.go
index fb0ede146..0391f2b0a 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/termvectors_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/termvectors_test.go
@@ -21,15 +21,15 @@ func TestTermVectorsBuildURL(t *testing.T) {
}{
{
"twitter",
- "tweet",
+ "doc",
"",
- "/twitter/tweet/_termvectors",
+ "/twitter/doc/_termvectors",
},
{
"twitter",
- "tweet",
+ "doc",
"1",
- "/twitter/tweet/1/_termvectors",
+ "/twitter/doc/1/_termvectors",
},
}
@@ -56,7 +56,7 @@ func TestTermVectorsWithId(t *testing.T) {
// Add a document
indexResult, err := client.Index().
Index(testIndexName).
- Type("tweet").
+ Type("doc").
Id("1").
BodyJson(&tweet1).
Refresh("true").
@@ -70,7 +70,7 @@ func TestTermVectorsWithId(t *testing.T) {
// TermVectors by specifying ID
field := "Message"
- result, err := client.TermVectors(testIndexName, "tweet").
+ result, err := client.TermVectors(testIndexName, "doc").
Id("1").
Fields(field).
FieldStatistics(true).
@@ -104,7 +104,7 @@ func TestTermVectorsWithDoc(t *testing.T) {
"fullname": "keyword",
}
- result, err := client.TermVectors(testIndexName, "tweet").
+ result, err := client.TermVectors(testIndexName, "doc").
Doc(doc).
PerFieldAnalyzer(perFieldAnalyzer).
FieldStatistics(true).
@@ -138,7 +138,7 @@ func TestTermVectorsWithFilter(t *testing.T) {
"fullname": "keyword",
}
- result, err := client.TermVectors(testIndexName, "tweet").
+ result, err := client.TermVectors(testIndexName, "doc").
Doc(doc).
PerFieldAnalyzer(perFieldAnalyzer).
FieldStatistics(true).
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update.go b/vendor/gopkg.in/olivere/elastic.v5/update.go
index 1718bc585..5507fae4c 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/update.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/update.go
@@ -10,11 +10,11 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// UpdateService updates a document in Elasticsearch.
-// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-update.html
+// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-update.html
// for details.
type UpdateService struct {
client *Client
@@ -105,7 +105,7 @@ func (b *UpdateService) Version(version int64) *UpdateService {
return b
}
-// VersionType is one of "internal" or "force".
+// VersionType is e.g. "internal".
func (b *UpdateService) VersionType(versionType string) *UpdateService {
b.versionType = versionType
return b
@@ -293,7 +293,12 @@ func (b *UpdateService) Do(ctx context.Context) (*UpdateResponse, error) {
}
// Get response
- res, err := b.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := b.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
@@ -308,12 +313,15 @@ func (b *UpdateService) Do(ctx context.Context) (*UpdateResponse, error) {
// UpdateResponse is the result of updating a document in Elasticsearch.
type UpdateResponse struct {
- Index string `json:"_index"`
- Type string `json:"_type"`
- Id string `json:"_id"`
- Version int `json:"_version"`
- Shards *shardsInfo `json:"_shards"`
+ Index string `json:"_index,omitempty"`
+ Type string `json:"_type,omitempty"`
+ Id string `json:"_id,omitempty"`
+ Version int64 `json:"_version,omitempty"`
Result string `json:"result,omitempty"`
+ Shards *shardsInfo `json:"_shards,omitempty"`
+ SeqNo int64 `json:"_seq_no,omitempty"`
+ PrimaryTerm int64 `json:"_primary_term,omitempty"`
+ Status int `json:"status,omitempty"`
ForcedRefresh bool `json:"forced_refresh,omitempty"`
GetResult *GetResult `json:"get,omitempty"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update_by_query.go b/vendor/gopkg.in/olivere/elastic.v5/update_by_query.go
index 505e1e834..953d67388 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/update_by_query.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/update_by_query.go
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// UpdateByQueryService is documented at https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-reindex.html.
@@ -447,7 +447,7 @@ func (s *UpdateByQueryService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.xSource) > 0 {
params.Set("_source", strings.Join(s.xSource, ","))
@@ -636,7 +636,12 @@ func (s *UpdateByQueryService) Do(ctx context.Context) (*BulkIndexByScrollRespon
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "POST", path, params, body)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "POST",
+ Path: path,
+ Params: params,
+ Body: body,
+ })
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update_by_query_test.go b/vendor/gopkg.in/olivere/elastic.v5/update_by_query_test.go
index 6ff56ccf6..fde924dd5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/update_by_query_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/update_by_query_test.go
@@ -110,7 +110,7 @@ func TestUpdateByQueryBodyWithQueryAndScript(t *testing.T) {
t.Fatal(err)
}
got := string(b)
- want := `{"query":{"term":{"user":"olivere"}},"script":{"inline":"ctx._source.likes++"}}`
+ want := `{"query":{"term":{"user":"olivere"}},"script":{"source":"ctx._source.likes++"}}`
if got != want {
t.Fatalf("\ngot %s\nwant %s", got, want)
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update_integration_test.go b/vendor/gopkg.in/olivere/elastic.v5/update_integration_test.go
new file mode 100644
index 000000000..f36925298
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/update_integration_test.go
@@ -0,0 +1,58 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "encoding/json"
+ "testing"
+)
+
+func TestUpdateWithScript(t *testing.T) {
+ client := setupTestClientAndCreateIndexAndAddDocs(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
+ // Get original
+ getRes, err := client.Get().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ var original tweet
+ if err := json.Unmarshal(*getRes.Source, &original); err != nil {
+ t.Fatal(err)
+ }
+
+ // Update with script
+ updRes, err := client.Update().Index(testIndexName).Type("doc").Id("1").
+ Script(
+ NewScript(`ctx._source.message = "Updated message text."`).Lang("painless"),
+ ).
+ Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if updRes == nil {
+ t.Fatal("response is nil")
+ }
+ if want, have := "updated", updRes.Result; want != have {
+ t.Fatalf("want Result = %q, have %v", want, have)
+ }
+
+ // Get new version
+ getRes, err = client.Get().Index(testIndexName).Type("doc").Id("1").Do(context.TODO())
+ if err != nil {
+ t.Fatal(err)
+ }
+ var updated tweet
+ if err := json.Unmarshal(*getRes.Source, &updated); err != nil {
+ t.Fatal(err)
+ }
+
+ if want, have := original.User, updated.User; want != have {
+ t.Fatalf("want User = %q, have %v", want, have)
+ }
+ if want, have := "Updated message text.", updated.Message; want != have {
+ t.Fatalf("want Message = %q, have %v", want, have)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update_test.go b/vendor/gopkg.in/olivere/elastic.v5/update_test.go
index 8801bacb2..1f04cedd6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/update_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/update_test.go
@@ -12,7 +12,8 @@ import (
)
func TestUpdateViaScript(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
update := client.Update().
Index("test").Type("type1").Id("1").
Script(NewScript("ctx._source.tags += tag").Params(map[string]interface{}{"tag": "blue"}).Lang("groovy"))
@@ -37,14 +38,14 @@ func TestUpdateViaScript(t *testing.T) {
t.Fatalf("expected to marshal body as JSON, got: %v", err)
}
got := string(data)
- expected := `{"script":{"inline":"ctx._source.tags += tag","lang":"groovy","params":{"tag":"blue"}}}`
+ expected := `{"script":{"lang":"groovy","params":{"tag":"blue"},"source":"ctx._source.tags += tag"}}`
if got != expected {
t.Errorf("expected\n%s\ngot:\n%s", expected, got)
}
}
func TestUpdateViaScriptId(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
scriptParams := map[string]interface{}{
"pageViewEvent": map[string]interface{}{
@@ -53,7 +54,7 @@ func TestUpdateViaScriptId(t *testing.T) {
"time": "2014-01-01 12:32",
},
}
- script := NewScriptId("my_web_session_summariser").Params(scriptParams)
+ script := NewScriptStored("my_web_session_summariser").Params(scriptParams)
update := client.Update().
Index("sessions").Type("session").Id("dh3sgudg8gsrgl").
@@ -87,53 +88,9 @@ func TestUpdateViaScriptId(t *testing.T) {
}
}
-func TestUpdateViaScriptFile(t *testing.T) {
- client := setupTestClient(t)
-
- scriptParams := map[string]interface{}{
- "pageViewEvent": map[string]interface{}{
- "url": "foo.com/bar",
- "response": 404,
- "time": "2014-01-01 12:32",
- },
- }
- script := NewScriptFile("update_script").Params(scriptParams)
-
- update := client.Update().
- Index("sessions").Type("session").Id("dh3sgudg8gsrgl").
- Script(script).
- ScriptedUpsert(true).
- Upsert(map[string]interface{}{})
-
- path, params, err := update.url()
- if err != nil {
- t.Fatalf("expected to return URL, got: %v", err)
- }
- expectedPath := `/sessions/session/dh3sgudg8gsrgl/_update`
- if expectedPath != path {
- t.Errorf("expected URL path\n%s\ngot:\n%s", expectedPath, path)
- }
- expectedParams := url.Values{}
- if expectedParams.Encode() != params.Encode() {
- t.Errorf("expected URL parameters\n%s\ngot:\n%s", expectedParams.Encode(), params.Encode())
- }
- body, err := update.body()
- if err != nil {
- t.Fatalf("expected to return body, got: %v", err)
- }
- data, err := json.Marshal(body)
- if err != nil {
- t.Fatalf("expected to marshal body as JSON, got: %v", err)
- }
- got := string(data)
- expected := `{"script":{"file":"update_script","params":{"pageViewEvent":{"response":404,"time":"2014-01-01 12:32","url":"foo.com/bar"}}},"scripted_upsert":true,"upsert":{}}`
- if got != expected {
- t.Errorf("expected\n%s\ngot:\n%s", expected, got)
- }
-}
-
func TestUpdateViaScriptAndUpsert(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
update := client.Update().
Index("test").Type("type1").Id("1").
Script(NewScript("ctx._source.counter += count").Params(map[string]interface{}{"count": 4})).
@@ -159,14 +116,15 @@ func TestUpdateViaScriptAndUpsert(t *testing.T) {
t.Fatalf("expected to marshal body as JSON, got: %v", err)
}
got := string(data)
- expected := `{"script":{"inline":"ctx._source.counter += count","params":{"count":4}},"upsert":{"counter":1}}`
+ expected := `{"script":{"params":{"count":4},"source":"ctx._source.counter += count"},"upsert":{"counter":1}}`
if got != expected {
t.Errorf("expected\n%s\ngot:\n%s", expected, got)
}
}
func TestUpdateViaDoc(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
update := client.Update().
Index("test").Type("type1").Id("1").
Doc(map[string]interface{}{"name": "new_name"}).
@@ -199,7 +157,8 @@ func TestUpdateViaDoc(t *testing.T) {
}
func TestUpdateViaDocAndUpsert(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
update := client.Update().
Index("test").Type("type1").Id("1").
Doc(map[string]interface{}{"name": "new_name"}).
@@ -234,7 +193,8 @@ func TestUpdateViaDocAndUpsert(t *testing.T) {
}
func TestUpdateViaDocAndUpsertAndFetchSource(t *testing.T) {
- client := setupTestClient(t)
+ client := setupTestClient(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
update := client.Update().
Index("test").Type("type1").Id("1").
Doc(map[string]interface{}{"name": "new_name"}).
@@ -274,8 +234,9 @@ func TestUpdateViaDocAndUpsertAndFetchSource(t *testing.T) {
func TestUpdateAndFetchSource(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) // , SetTraceLog(log.New(os.Stdout, "", 0)))
+
res, err := client.Update().
- Index(testIndexName).Type("tweet").Id("1").
+ Index(testIndexName).Type("doc").Id("1").
Doc(map[string]interface{}{"user": "sandrae"}).
DetectNoop(true).
FetchSource(true).