Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typesense:
image: typesense/typesense:27.1
image: typesense/typesense:29.0
command: --data-dir /tmp --api-key=hexdocs
ports:
- 8108:8108
12 changes: 8 additions & 4 deletions lib/hexdocs/search/typesense.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ defmodule Hexdocs.Search.Typesense do
{:ok, 200, _resp_headers, ndjson} ->
ndjson
|> String.split("\n")
|> Enum.each(fn json ->
case :json.decode(json) do
|> Enum.zip(search_items)
|> Enum.each(fn {response, search_item} ->
case :json.decode(response) do
%{"success" => true} ->
:ok

%{"success" => false, "error" => error, "document" => document} ->
raise "Failed to index search item for #{package} #{version} for document #{inspect(document)}: #{inspect(error)}"
%{"success" => false, "error" => error} ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericmj 29.0 doesn't include document in the error response anymore.

error = if is_binary(error), do: error, else: inspect(error)

raise "Failed to index search item #{inspect(search_item)} for #{package} #{version}: " <>
error
end
end)

Expand Down
6 changes: 4 additions & 2 deletions test/hexdocs/search_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ defmodule Hexdocs.SearchTest do
}
]}

assert msg =~ "Failed to index search item for #{package} 1.0.0 for document "
assert msg =~ "Failed to index search item "
assert msg =~ " for #{package} 1.0.0: "
assert msg =~ "Field `doc` has been declared in the schema, but is not found in the document."
end

Expand Down Expand Up @@ -281,7 +282,8 @@ defmodule Hexdocs.SearchTest do
}
]}

assert msg =~ "Failed to index search item for #{package} 1.0.0 for document "
assert msg =~ "Failed to index search item "
assert msg =~ " for #{package} 1.0.0: "
assert msg =~ "Field `type` must be a string."
end

Expand Down