Skip to content

Commit

Permalink
Fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
vovayartsev authored and MikaAK committed Nov 28, 2024
1 parent 1824003 commit d7441f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/pinecone.ex
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ defmodule Pinecone do
end
end

defp post_root(path, name, body, opts) do
with {:ok, host} <- index_host(name) do
HTTP.post({:root, host}, path, body, opts)
end
end

defp index_host(index_name) do
with {:ok, %{"host" => host}} <- describe_index(index_name) do
{:ok, host}
Expand Down Expand Up @@ -434,7 +440,7 @@ defmodule Pinecone do

body = if opts[:namespace], do: Map.put(body, "namespace", opts[:namespace]), else: body

post_vector("query", name, body, opts[:config])
post_root("query", name, body, opts[:config])
end

## Collection Operations
Expand Down
4 changes: 4 additions & 0 deletions lib/pinecone/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ defmodule Pinecone.HTTP do
Path.join("https://#{host}/vectors", endpoint)
end

defp url({:root, host}, endpoint, _env) do
Path.join("https://#{host}", endpoint)
end

defp headers(api_key) do
api_key =
if api_key do
Expand Down

0 comments on commit d7441f5

Please sign in to comment.