Skip to content

Commit

Permalink
Merge pull request #6 from andreibondarev/points-get_all
Browse files Browse the repository at this point in the history
Points #get_all() method
  • Loading branch information
andreibondarev authored Aug 31, 2023
2 parents 0eeb9c9 + 842c482 commit 84e3be0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
QDRANT_URL=
QDRANT_API_KEY=
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ client.points.get(
consistency: "int"
)

# Retrieve full information of points by ids
client.points.get_all(
collection_name: "string", # required
ids: "[int]", # required
with_payload: "boolean"
with_vector: "boolean"
)

# Lists all data objects in reverse order of creation. The data will be returned as an array of objects.
client.points.list(
collection_name: "string", # required
Expand Down
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require "pry"
# Pry.start

client = Qdrant::Client.new(
url: "https://02e23d35-486d-4555-a471-0415ac641516.us-east-1-0.aws.cloud.qdrant.io:6333",
api_key: "yCjKEx3UPJXgTUfHgzzmZAP8kXk-4nUy7LoCdFwe8HtcDzXA-8KVVw"
url: ENV["QDRANT_URL"],
api_key: ENV["QDRANT_API_KEY"]
)

require "irb"
Expand Down
19 changes: 19 additions & 0 deletions lib/qdrant/points.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ def get(
response.body
end

# Retrieve full information of points by ids
def get_all(
collection_name:,
ids:,
consistency: nil,
with_payload: nil,
with_vector: nil
)
response = client.connection.post("collections/#{collection_name}/#{PATH}") do |req|
req.params["consistency"] = consistency unless consistency.nil?

req.body = {}
req.body["ids"] = ids
req.body["with_payload"] = with_payload unless with_payload.nil?
req.body["with_vector"] = with_vector unless with_vector.nil?
end
response.body
end

# Set payload values for points
def set_payload(
collection_name:,
Expand Down
14 changes: 7 additions & 7 deletions spec/qdrant/points_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@
end
end

describe "#get" do
describe "#get_all" do
let(:response) {
OpenStruct.new(body: point_fixture)
OpenStruct.new(body: points_fixture)
}

before do
allow_any_instance_of(Faraday::Connection).to receive(:get)
.with("collections/test_collection/points/1")
allow_any_instance_of(Faraday::Connection).to receive(:post)
.with("collections/test_collection/points")
.and_return(response)
end

it "return the data" do
response = client.points.get(
response = client.points.get_all(
collection_name: "test_collection",
id: 1
ids: [4, 1, 2, 5, 6]
)
expect(response.dig("result", "id")).to eq(1)
expect(response.dig("result").count).to eq(5)
end
end

Expand Down

0 comments on commit 84e3be0

Please sign in to comment.