Skip to content

Commit 84e3be0

Browse files
Merge pull request #6 from andreibondarev/points-get_all
Points #get_all() method
2 parents 0eeb9c9 + 842c482 commit 84e3be0

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QDRANT_URL=
2+
QDRANT_API_KEY=

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ client.points.get(
163163
consistency: "int"
164164
)
165165

166+
# Retrieve full information of points by ids
167+
client.points.get_all(
168+
collection_name: "string", # required
169+
ids: "[int]", # required
170+
with_payload: "boolean"
171+
with_vector: "boolean"
172+
)
173+
166174
# Lists all data objects in reverse order of creation. The data will be returned as an array of objects.
167175
client.points.list(
168176
collection_name: "string", # required

bin/console

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ require "pry"
1212
# Pry.start
1313

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

1919
require "irb"

lib/qdrant/points.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ def get(
7171
response.body
7272
end
7373

74+
# Retrieve full information of points by ids
75+
def get_all(
76+
collection_name:,
77+
ids:,
78+
consistency: nil,
79+
with_payload: nil,
80+
with_vector: nil
81+
)
82+
response = client.connection.post("collections/#{collection_name}/#{PATH}") do |req|
83+
req.params["consistency"] = consistency unless consistency.nil?
84+
85+
req.body = {}
86+
req.body["ids"] = ids
87+
req.body["with_payload"] = with_payload unless with_payload.nil?
88+
req.body["with_vector"] = with_vector unless with_vector.nil?
89+
end
90+
response.body
91+
end
92+
7493
# Set payload values for points
7594
def set_payload(
7695
collection_name:,

spec/qdrant/points_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@
3737
end
3838
end
3939

40-
describe "#get" do
40+
describe "#get_all" do
4141
let(:response) {
42-
OpenStruct.new(body: point_fixture)
42+
OpenStruct.new(body: points_fixture)
4343
}
4444

4545
before do
46-
allow_any_instance_of(Faraday::Connection).to receive(:get)
47-
.with("collections/test_collection/points/1")
46+
allow_any_instance_of(Faraday::Connection).to receive(:post)
47+
.with("collections/test_collection/points")
4848
.and_return(response)
4949
end
5050

5151
it "return the data" do
52-
response = client.points.get(
52+
response = client.points.get_all(
5353
collection_name: "test_collection",
54-
id: 1
54+
ids: [4, 1, 2, 5, 6]
5555
)
56-
expect(response.dig("result", "id")).to eq(1)
56+
expect(response.dig("result").count).to eq(5)
5757
end
5858
end
5959

0 commit comments

Comments
 (0)