Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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