Skip to content

Commit

Permalink
Swagger vector search (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshrajamani authored Aug 21, 2023
1 parent 30cfb25 commit de9b75d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
54 changes: 51 additions & 3 deletions src/main/java/io/stargate/sgv2/jsonapi/StargateJsonApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@
}
}
"""),
@ExampleObject(
name = "findOneVectorSearch",
summary = "`findOne` command with vector search",
value =
"""
{
"findOne": {
"filter": {"location": "London", "race.competitors" : {"$eq" : 100}},
"projection": {"_id":0, "location":1, "race.start_date":1, "tags":1},
"sort" : {"$vector" : [0.25,0.25,0.25,0.25,0.25]},
"options": {"includeSimilarity" : true}
}
}
"""),
@ExampleObject(
name = "countDocuments",
summary = "`countDocuments` command",
Expand All @@ -105,6 +119,20 @@
}
}
"""),
@ExampleObject(
name = "findVectorSearch",
summary = "`find` command with vector search",
value =
"""
{
"find": {
"filter": {"location": "London", "race.competitors" : {"$eq" : 100}},
"projection": {"tags":0},
"sort" : {"$vector" : [0.25,0.25,0.25,0.25,0.25]},
"options": {"limit" : 1000, "includeSimilarity" : true}
}
}
"""),
@ExampleObject(
name = "findOneAndUpdate",
summary = "`findOneAndUpdate` command",
Expand Down Expand Up @@ -234,7 +262,8 @@
"competitors": 100,
"start_date": "2022-08-15"
},
"tags": [ ]
"tags": [ ],
"$vector" : [0.25,0.25,0.25,0.25,0.25]
}
}
}
Expand All @@ -254,7 +283,8 @@
"competitors": 100,
"start_date": "2022-08-15"
},
"tags" : [ "eu" ]
"tags" : [ "eu" ],
"$vector" : [0.35,0.35,0.35,0.35,0.35]
},
{
"_id": "2",
Expand All @@ -263,7 +293,8 @@
"competitors": 150,
"start_date": "2022-09-15"
},
"tags": [ "us" ]
"tags": [ "us" ],
"$vector" : [0.45,0.45,0.45,0.45,0.45]
}
],
"options": {
Expand Down Expand Up @@ -332,6 +363,23 @@
}
}
"""),
@ExampleObject(
name = "createCollectionVectorSearch",
summary = "`CreateCollection` command with vector search",
value =
"""
{
"createCollection": {
"name": "events_vector",
"options": {
"vector": {
"size": 2,
"function": "cosine"
}
}
}
}
"""),
@ExampleObject(
name = "findCollections",
summary = "`FindCollections` command",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public CollectionResource(MeteredCommandProcessor meteredCommandProcessor) {
@ExampleObject(ref = "deleteOne"),
@ExampleObject(ref = "deleteMany"),
@ExampleObject(ref = "find"),
@ExampleObject(ref = "findVectorSearch"),
@ExampleObject(ref = "findOne"),
@ExampleObject(ref = "findOneVectorSearch"),
@ExampleObject(ref = "findOneAndDelete"),
@ExampleObject(ref = "findOneAndReplace"),
@ExampleObject(ref = "findOneAndUpdate"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public NamespaceResource(MeteredCommandProcessor meteredCommandProcessor) {
schema = @Schema(anyOf = {CreateCollectionCommand.class}),
examples = {
@ExampleObject(ref = "createCollection"),
@ExampleObject(ref = "createCollectionVectorSearch"),
@ExampleObject(ref = "findCollections"),
@ExampleObject(ref = "deleteCollection"),
}))
Expand Down

0 comments on commit de9b75d

Please sign in to comment.