diff --git a/bin/setup b/bin/setup index c5f7909..23ac7d7 100755 --- a/bin/setup +++ b/bin/setup @@ -31,7 +31,7 @@ if [ ! $CI ]; then rm -rf vendor/; mkdir vendor/; - mix elasticsearch.install vendor --version 6.8.1 || { echo "Elasticsearch could not be installed!"; exit 1; } + mix elasticsearch.install vendor --version 7.12.0 || { echo "Elasticsearch could not be installed!"; exit 1; } fi echo "----------------------------------------------------------" diff --git a/docker-compose.yml b/docker-compose.yml index 631d12b..e31ebc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,11 +7,12 @@ services: environment: POSTGRES_HOST_AUTH_METHOD: "trust" elasticsearch: - # image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2 - image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13 + image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0 + # image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13 environment: - node.name=es01 - bootstrap.memory_lock=true + - discovery.type=single-node - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: diff --git a/lib/elasticsearch.ex b/lib/elasticsearch.ex index 569111e..2d8f4e1 100644 --- a/lib/elasticsearch.ex +++ b/lib/elasticsearch.ex @@ -229,13 +229,13 @@ defmodule Elasticsearch do iex> Elasticsearch.get(Cluster, "/nonexistent") {:error, %Elasticsearch.Exception{col: nil, line: nil, - message: "no such index", query: nil, + message: "no such index [nonexistent]", query: nil, raw: %{"error" => %{"index" => "nonexistent", - "index_uuid" => "_na_", "reason" => "no such index", + "index_uuid" => "_na_", "reason" => "no such index [nonexistent]", "resource.id" => "nonexistent", "resource.type" => "index_or_alias", "root_cause" => [%{"index" => "nonexistent", - "index_uuid" => "_na_", "reason" => "no such index", + "index_uuid" => "_na_", "reason" => "no such index [nonexistent]", "resource.id" => "nonexistent", "resource.type" => "index_or_alias", "type" => "index_not_found_exception"}], @@ -263,7 +263,7 @@ defmodule Elasticsearch do true iex> Elasticsearch.get!(Cluster, "/nonexistent") - ** (Elasticsearch.Exception) (index_not_found_exception) no such index + ** (Elasticsearch.Exception) (index_not_found_exception) no such index [nonexistent] """ @spec get!(Cluster.t(), url) :: map | no_return @spec get!(Cluster.t(), url, opts) :: map | no_return @@ -374,7 +374,7 @@ defmodule Elasticsearch do iex> query = %{"query" => %{"match_all" => %{}}} ...> Elasticsearch.post!(Cluster, "/nonexistent/_search", query) - ** (Elasticsearch.Exception) (index_not_found_exception) no such index + ** (Elasticsearch.Exception) (index_not_found_exception) no such index [nonexistent] """ @spec post!(Cluster.t(), url, data) :: map | no_return @spec post!(Cluster.t(), url, data, opts) :: map | no_return @@ -398,13 +398,13 @@ defmodule Elasticsearch do iex> Elasticsearch.delete(Cluster, "/nonexistent") {:error, %Elasticsearch.Exception{col: nil, line: nil, - message: "no such index", query: nil, + message: "no such index [nonexistent]", query: nil, raw: %{"error" => %{"index" => "nonexistent", - "index_uuid" => "_na_", "reason" => "no such index", + "index_uuid" => "_na_", "reason" => "no such index [nonexistent]", "resource.id" => "nonexistent", "resource.type" => "index_or_alias", "root_cause" => [%{"index" => "nonexistent", - "index_uuid" => "_na_", "reason" => "no such index", + "index_uuid" => "_na_", "reason" => "no such index [nonexistent]", "resource.id" => "nonexistent", "resource.type" => "index_or_alias", "type" => "index_not_found_exception"}], @@ -433,7 +433,7 @@ defmodule Elasticsearch do Raises an error if the resource is invalid. iex> Elasticsearch.delete!(Cluster, "/nonexistent") - ** (Elasticsearch.Exception) (index_not_found_exception) no such index + ** (Elasticsearch.Exception) (index_not_found_exception) no such index [nonexistent] """ @spec delete!(Cluster.t(), url) :: map | no_return @spec delete!(Cluster.t(), url, opts) :: map | no_return diff --git a/lib/elasticsearch/indexing/bulk.ex b/lib/elasticsearch/indexing/bulk.ex index f1a4aec..ed62660 100644 --- a/lib/elasticsearch/indexing/bulk.ex +++ b/lib/elasticsearch/indexing/bulk.ex @@ -49,7 +49,7 @@ defmodule Elasticsearch.Index.Bulk do \"\"\" iex> Bulk.encode!(Cluster, 123, "my-index") - ** (Protocol.UndefinedError) protocol Elasticsearch.Document not implemented for 123 of type Integer + ** (Protocol.UndefinedError) protocol Elasticsearch.Document not implemented for 123 of type Integer. This protocol is implemented for the following type(s): Comment, Post """ def encode!(cluster, struct, index, action \\ "create") do config = Cluster.Config.get(cluster) diff --git a/lib/elasticsearch/indexing/index.ex b/lib/elasticsearch/indexing/index.ex index 2659191..ace8a57 100644 --- a/lib/elasticsearch/indexing/index.ex +++ b/lib/elasticsearch/indexing/index.ex @@ -159,7 +159,7 @@ defmodule Elasticsearch.Index do :ok iex> Index.refresh!(Cluster, "nonexistent") - ** (Elasticsearch.Exception) (index_not_found_exception) no such index + ** (Elasticsearch.Exception) (index_not_found_exception) no such index [nonexistent] """ @spec refresh!(Cluster.t(), String.t()) :: :ok def refresh!(cluster, name) do diff --git a/mix.lock b/mix.lock index 34644b5..c4761fb 100644 --- a/mix.lock +++ b/mix.lock @@ -27,6 +27,7 @@ "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm", "8f7168911120e13419e086e78d20e4d1a6776f1eee2411ac9f790af10813389f"}, "postgrex": {:hex, :postgrex, "0.15.7", "724410acd48abac529d0faa6c2a379fb8ae2088e31247687b16cacc0e0883372", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "88310c010ff047cecd73d5ceca1d99205e4b1ab1b9abfdab7e00f5c9d20ef8f9"}, "sigaws": {:hex, :sigaws, "0.7.2", "2b0bcd3979f2ae19337d0a6e52b4b1f37ac3d778201019240e641471a2d36685", [:mix], [], "hexpm", "5d3f3c9a259b052015297b3392800b95a7672c7cf3e878cf88c0d33213ac2e55"}, + "sigaws_otp_24": {:hex, :sigaws_otp_24, "1.0.0", "cd8e41a6c198ba8c9005d2ec8cf427196100d7f0d6089b68afa501df3e035049", [:mix], [], "hexpm", "624550f60c651be6680fa200afc11e01fa8c10df16e3b6dfe2c8b0f2a54abddd"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, diff --git a/test/mix/elasticsearch.build_test.exs b/test/mix/elasticsearch.build_test.exs index 4777fe6..e23a6d7 100644 --- a/test/mix/elasticsearch.build_test.exs +++ b/test/mix/elasticsearch.build_test.exs @@ -141,7 +141,7 @@ defmodule Mix.Tasks.Elasticsearch.BuildTest do Index created, but not aliased: posts The following errors occurred: - %Elasticsearch.Exception{col: nil, line: nil, message: \"reason\", query: nil, raw: %{\"error\" => %{\"reason\" => \"reason\", \"type\" => \"type\"}}, status: nil, type: \"type\"}\n + %Elasticsearch.Exception{status: nil, line: nil, col: nil, message: \"reason\", type: \"type\", query: nil, raw: %{\"error\" => %{\"reason\" => \"reason\", \"type\" => \"type\"}}}\n """, fn -> rerun("elasticsearch.build", ["posts", "--cluster", inspect(ErrorCluster)]) @@ -183,7 +183,7 @@ defmodule Mix.Tasks.Elasticsearch.BuildTest do """ Index posts could not be created. - %Elasticsearch.Exception{col: nil, line: nil, message: \"Gateway Error\", query: nil, raw: nil, status: nil, type: nil} + %Elasticsearch.Exception{status: nil, line: nil, col: nil, message: \"Gateway Error\", type: nil, query: nil, raw: nil} """, fn -> rerun("elasticsearch.build", ["posts", "--cluster", inspect(ErrorCluster)]) @@ -204,7 +204,7 @@ defmodule Mix.Tasks.Elasticsearch.BuildTest do assert output =~ "Pausing 0ms between bulk pages" resp = Elasticsearch.get!(TestCluster, "/posts/_search") - assert resp["hits"]["total"] == 10_000 + assert resp["hits"]["total"]["value"] == 10_000 end test "respects --bulk options" do @@ -222,7 +222,7 @@ defmodule Mix.Tasks.Elasticsearch.BuildTest do assert output =~ "Pausing 10ms between bulk pages" resp = Elasticsearch.get!(TestCluster, "/posts/_search") - assert resp["hits"]["total"] == 2 + assert resp["hits"]["total"]["value"] == 2 end test "only keeps two index versions" do diff --git a/test/support/settings/posts.json b/test/support/settings/posts.json index 2f23c9e..a973e08 100644 --- a/test/support/settings/posts.json +++ b/test/support/settings/posts.json @@ -1,23 +1,21 @@ { - "mappings": { - "_doc": { - "properties": { - "title": { - "type": "text" - }, - "body": { - "type": "text" - }, - "author": { - "type": "text" - }, - "doctype": { - "type": "join", - "relations": { - "post": "comment" - } + "mappings": { + "properties": { + "title": { + "type": "text" + }, + "body": { + "type": "text" + }, + "author": { + "type": "text" + }, + "doctype": { + "type": "join", + "relations": { + "post": "comment" + } + } } - } } - } }