summaryrefslogtreecommitdiff
path: root/test/elixir/test/nouveau_test.exs
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2023-05-10 10:21:35 +0100
committerRobert Newson <rnewson@apache.org>2023-05-10 14:42:24 +0100
commit51267a5fd170c865cba795b5af3f7d3f348caed5 (patch)
treefba244a7a73f6e16796e01e408b2616c7b13a6c8 /test/elixir/test/nouveau_test.exs
parent9851bb396a8511c0317365dab2d7585cf86a0e3f (diff)
downloadcouchdb-51267a5fd170c865cba795b5af3f7d3f348caed5.tar.gz
Improve nouveau mango integration
1) Fix sorting on strings and numbers 2) use 'string' type for string fields 3) use 'text' type for the default field
Diffstat (limited to 'test/elixir/test/nouveau_test.exs')
-rw-r--r--test/elixir/test/nouveau_test.exs51
1 files changed, 46 insertions, 5 deletions
diff --git a/test/elixir/test/nouveau_test.exs b/test/elixir/test/nouveau_test.exs
index 3bea874d9..ad48e58ea 100644
--- a/test/elixir/test/nouveau_test.exs
+++ b/test/elixir/test/nouveau_test.exs
@@ -11,10 +11,10 @@ defmodule NouveauTest do
resp = Couch.post("/#{db_name}/_bulk_docs",
headers: ["Content-Type": "application/json"],
body: %{:docs => [
- %{"_id" => "doc4", "foo" => "foo", "bar" => 42},
- %{"_id" => "doc3", "foo" => "bar", "bar" => 12.0},
- %{"_id" => "doc1", "foo" => "baz", "bar" => 0},
- %{"_id" => "doc2", "foo" => "foobar", "bar" => 100},
+ %{"_id" => "doc4", "foo" => "foo", "bar" => 42, "baz" => "hello there"},
+ %{"_id" => "doc3", "foo" => "bar", "bar" => 12.0, "baz" => "hello"},
+ %{"_id" => "doc1", "foo" => "baz", "bar" => 0, "baz" => "there"},
+ %{"_id" => "doc2", "foo" => "foobar", "bar" => 100, "baz" => "hi"},
]}
)
assert resp.status_code in [201]
@@ -61,13 +61,15 @@ defmodule NouveauTest do
index: %{
fields: [
%{name: "foo", type: "string"},
- %{name: "bar", type: "number"}
+ %{name: "bar", type: "number"},
+ %{name: "baz", type: "string"},
]
}
}
resp = Couch.post("/#{db_name}/_index", body: body)
assert resp.status_code in [200]
+ resp.body
end
def get_ids(resp) do
@@ -303,6 +305,45 @@ defmodule NouveauTest do
assert ids == ["doc4"]
end
+ @tag :with_db
+ test "mango search by text", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_mango_index(db_name)
+
+ url = "/#{db_name}/_find"
+ resp = Couch.post(url, body: %{selector: %{"$text": "hello"}})
+ assert_status_code(resp, 200)
+ ids = get_mango_ids(resp)
+ assert ids == ["doc4", "doc3"]
+ end
+
+ @tag :with_db
+ test "mango sort by number", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_mango_index(db_name)
+
+ url = "/#{db_name}/_find"
+ resp = Couch.post(url, body: %{sort: [%{"bar:number": "asc"}], selector: %{bar: %{"$gt": 5}}})
+ assert_status_code(resp, 200)
+ ids = get_mango_ids(resp)
+ assert ids == ["doc3", "doc4", "doc2"]
+ end
+
+ @tag :with_db
+ test "mango sort by string", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_mango_index(db_name)
+
+ url = "/#{db_name}/_find"
+ resp = Couch.post(url, body: %{sort: [%{"foo:string": "asc"}], selector: %{bar: %{"$gte": 0}}})
+ assert_status_code(resp, 200)
+ ids = get_mango_ids(resp)
+ assert ids == ["doc3", "doc1", "doc4", "doc2"]
+ end
+
@tag :with_partitioned_db
test "search GET (partitioned)", context do
db_name = context[:db_name]