Skip to content

Commit cd3ed33

Browse files
Vector Field Modes (#21)
* Enable specifying field modes * 0.0.12
1 parent 440c808 commit cd3ed33

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

lib/manifold/services/vector_service.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,22 @@ def load_vector_config(vector_name)
3232
private
3333

3434
def transform_attributes_to_schema(attributes)
35-
attributes.map do |name, type|
35+
attributes.map do |name, type_str|
36+
type, mode = parse_type_and_mode(type_str)
3637
{
3738
"name" => name,
3839
"type" => type.upcase,
39-
"mode" => "NULLABLE"
40+
"mode" => mode
4041
}
4142
end
4243
end
4344

45+
def parse_type_and_mode(type_str)
46+
type, mode = type_str.split(":")
47+
mode = mode&.upcase || "NULLABLE"
48+
[type, mode]
49+
end
50+
4451
def config_path(vector_name)
4552
Pathname.pwd.join("vectors", "#{vector_name.downcase}.yml")
4653
end

lib/manifold/templates/vector_template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ attributes:
55
# id: STRING
66
# created_at: TIMESTAMP
77
# status: STRING
8+
# names: STRING:REPEATED
89

910
# Optionally, reference a view specifying how to select vector dimensions
1011
# merge:

lib/manifold/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Manifold
4-
VERSION = "0.0.11"
4+
VERSION = "0.0.12"
55
end

spec/manifold/services/vector_service_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"attributes" => {
1414
"id" => "string",
1515
"url" => "string",
16-
"created_at" => "timestamp"
16+
"created_at" => "timestamp",
17+
"tags" => "string:repeated",
18+
"email" => "string:required"
1719
}
1820
}
1921
end
@@ -25,7 +27,9 @@
2527
"fields" => [
2628
{ "name" => "id", "type" => "STRING", "mode" => "NULLABLE" },
2729
{ "name" => "url", "type" => "STRING", "mode" => "NULLABLE" },
28-
{ "name" => "created_at", "type" => "TIMESTAMP", "mode" => "NULLABLE" }
30+
{ "name" => "created_at", "type" => "TIMESTAMP", "mode" => "NULLABLE" },
31+
{ "name" => "tags", "type" => "STRING", "mode" => "REPEATED" },
32+
{ "name" => "email", "type" => "STRING", "mode" => "REQUIRED" }
2933
]
3034
}
3135
end

0 commit comments

Comments
 (0)