Skip to content

Commit

Permalink
adjust typesense config
Browse files Browse the repository at this point in the history
  • Loading branch information
yujonglee committed Oct 13, 2024
1 parent 3f87e4d commit cdf9dff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/lib/canary/index/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Canary.Index.Client do
name: name,
fields: fields,
enable_nested_fields: true,
token_separators: [".", "-", "_"]
token_separators: [".", "-", "_", "@"]
}
)
|> wrap()
Expand Down
20 changes: 17 additions & 3 deletions core/lib/canary/index/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,30 @@ defmodule Canary.Index do
filter_by: filter_by,
sort_by: "_text_match:desc",
highlight_fields: "content",
stopwords: Canary.Index.Stopword.id(),
prioritize_exact_match: true,
prioritize_token_position: false,
prioritize_token_position: true,
prioritize_num_matching_fields: false,
max_candidates: 4 * 4
max_candidates: 4 * 5,
min_len_1typo: 3,
min_len_2typo: 6
}
|> add_stopwords(query)
|> add_embedding_args(opts)
end)
end

defp add_stopwords(args, query) do
if query
|> String.split(" ")
|> Enum.filter(&(&1 != ""))
|> length() < 2 do
args
else
args
|> Map.put(:stopwords, Canary.Index.Stopword.id())
end
end

defp add_embedding_args(args, opts) do
embedding = opts[:embedding]
embedding_alpha = opts[:embedding_alpha] || 0.3
Expand Down

0 comments on commit cdf9dff

Please sign in to comment.