Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qdrant-ruby (0.9.9)
qdrant-ruby (0.9.10)
faraday (>= 2.0.1, < 3)

GEM
Expand Down
11 changes: 7 additions & 4 deletions lib/qdrant/collections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ def update_aliases(actions:)
def create_index(
collection_name:,
field_name:,
field_schema: nil
field_schema: nil,
wait: nil,
ordering: nil
)
response = client.connection.put("#{PATH}/#{collection_name}/index") do |req|
req.body = {
field_name: field_name
}
req.params["ordering"] = ordering unless ordering.nil?
# Add explicit false check to avoid nil case. True is default behavior.
req.params["wait"] = wait unless wait.nil?
req.body = {field_name: field_name}
req.body["field_schema"] = field_schema unless field_schema.nil?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/qdrant/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Qdrant
VERSION = "0.9.9"
VERSION = "0.9.10"
end
46 changes: 46 additions & 0 deletions spec/qdrant/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,52 @@
expect(response.dig("status")).to eq("ok")
expect(response.dig("result")).to eq(true)
end

it "adds wait=false query param when specified" do
allow_any_instance_of(Faraday::Connection).to receive(:put)
.with("collections/test_collection/index?wait=false")
.and_return(response)

response = collections.create_index(
collection_name: "test_collection",
field_name: "description",
field_schema: "text",
wait: false
)
expect(response.dig("status")).to eq("ok")
expect(response.dig("result")).to eq(true)
end

it "adds ordering query param when specified" do
allow_any_instance_of(Faraday::Connection).to receive(:put)
.with("collections/test_collection/index?ordering=weak")
.and_return(response)

response = collections.create_index(
collection_name: "test_collection",
field_name: "description",
field_schema: "text",
ordering: "weak"
)
expect(response.dig("status")).to eq("ok")
expect(response.dig("result")).to eq(true)
end

it "adds both wait=false and ordering params when specified" do
allow_any_instance_of(Faraday::Connection).to receive(:put)
.with("collections/test_collection/index?ordering=weak&wait=false")
.and_return(response)

response = collections.create_index(
collection_name: "test_collection",
field_name: "description",
field_schema: "text",
ordering: "weak",
wait: false
)
expect(response.dig("status")).to eq("ok")
expect(response.dig("result")).to eq(true)
end
end

describe "#delete_index" do
Expand Down