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
14 changes: 7 additions & 7 deletions fern/apis/master/openapi-overrides.yml

Large diffs are not rendered by default.

249 changes: 218 additions & 31 deletions fern/apis/v1.14.x/openapi-overrides.yml

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions snippets/csharp/query_points.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,66 @@ await client.QueryAsync(
collectionName: "{collection_name}",
query: Sample.Random
);

// Score boost depending on payload conditions (as of 1.14.0)
await client.QueryAsync(
collectionName: "{collection_name}",
prefetch:
[
new PrefetchQuery { Query = new float[] { 0.01f, 0.45f, 0.67f }, Limit = 100 },
],
query: new Formula
{
Expression = new SumExpression
{
Sum =
{
"$score",
new MultExpression
{
Mult = { 0.5f, Match("tag", ["h1", "h2", "h3", "h4"]) },
},
new MultExpression { Mult = { 0.25f, Match("tag", ["p", "li"]) } },
},
},
},
limit: 10
);

// Score boost geographically closer points (as of 1.14.0)
await client.QueryAsync(
collectionName: "{collection_name}",
prefetch:
[
new PrefetchQuery { Query = new float[] { 0.01f, 0.45f, 0.67f }, Limit = 100 },
],
query: new Formula
{
Expression = new SumExpression
{
Sum =
{
"$score",
WithExpDecay(
new()
{
X = new GeoDistance
{
Origin = new GeoPoint { Lat = 52.504043, Lon = 13.393236 },
To = "geo.location",
},
Scale = 5000,
}
),
},
},
Defaults =
{
["geo.location"] = new Dictionary<string, Value>
{
["lat"] = 48.137154,
["lon"] = 11.576124,
},
},
}
);
59 changes: 54 additions & 5 deletions snippets/curl/query_points.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Query nearest by ID
curl -X POST \
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
Expand All @@ -8,7 +8,7 @@ curl -X POST \
}'

# Recommend on the average of these vectors
curl -X POST \
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
Expand All @@ -35,7 +35,7 @@ curl -X POST \
}'

# Fusion query
curl -X POST \
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
Expand Down Expand Up @@ -71,7 +71,7 @@ curl -X POST \
}'

# 2-stage query
curl -X POST \
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
Expand Down Expand Up @@ -107,7 +107,7 @@ curl -X POST \
}'

# Random sampling (as of 1.11.0)
curl -X POST \
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
Expand All @@ -116,3 +116,52 @@ curl -X POST \
"sample": "random"
}
}'

# Score boost depending on payload conditions (as of 1.14.0)
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"prefetch": {
"query": [0.2, 0.8, ...], // <-- dense vector
"limit": 50
}
"query": {
"formula": {
"sum": [
"$score,
{ "mult": [ 0.5, { "key": "tag", "match": { "any": ["h1", "h2", "h3", "h4"] } } ] },
{ "mult": [ 0.25, { "key": "tag", "match": { "any": ["p", "li"] } } ] }
]
}
}
}'

# Score boost geographically closer points (as of 1.14.0)
curl -X POST \
'http://localhost:6333/collections/collection_name/points/query' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"prefetch": { "query": [0.2, 0.8, ...], "limit": 50 },
"query": {
"formula": {
"sum": [
"$score",
{
"gauss_decay": {
"x": {
"geo_distance": {
"origin": { "lat": 52.504043, "lon": 13.393236 } // Berlin
"to": "geo.location"
}
},
"scale": 5000 // 5km
}
}
]
},
"defaults": { "geo.location": {"lat": 48.137154, "lon": 11.576124} } // Munich
}
}'
61 changes: 61 additions & 0 deletions snippets/go/query_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,65 @@ func query() {
panic(err)
}
fmt.Println("Query results: ", points)

// Score boost depending on payload conditions (as of 1.14.0)
points, err = client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
{
Query: qdrant.NewQuery(0.01, 0.45, 0.67),
},
},
Query: qdrant.NewQueryFormula(&qdrant.Formula{
Expression: qdrant.NewExpressionSum(&qdrant.SumExpression{
Sum: []*qdrant.Expression{
qdrant.NewExpressionVariable("$score"),
qdrant.NewExpressionMult(&qdrant.MultExpression{
Mult: []*qdrant.Expression{
qdrant.NewExpressionConstant(0.5),
qdrant.NewExpressionCondition(qdrant.NewMatchKeywords("tag", "h1", "h2", "h3", "h4")),
},
}),
qdrant.NewExpressionMult(&qdrant.MultExpression{
Mult: []*qdrant.Expression{
qdrant.NewExpressionConstant(0.25),
qdrant.NewExpressionCondition(qdrant.NewMatchKeywords("tag", "p", "li")),
},
}),
},
}),
}),
})

// Score boost geographically closer points (as of 1.14.0)
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
{
Query: qdrant.NewQuery(0.2, 0.8),
},
},
Query: qdrant.NewQueryFormula(&qdrant.Formula{
Expression: qdrant.NewExpressionSum(&qdrant.SumExpression{
Sum: []*qdrant.Expression{
qdrant.NewExpressionVariable("$score"),
qdrant.NewExpressionExpDecay(&qdrant.DecayParamsExpression{
X: qdrant.NewExpressionGeoDistance(&qdrant.GeoDistance{
Origin: &qdrant.GeoPoint{
Lat: 52.504043,
Lon: 13.393236,
},
To: "geo.location",
}),
}),
},
}),
Defaults: qdrant.NewValueMap(map[string]any{
"geo.location": map[string]any{
"lat": 48.137154,
"lon": 11.576124,
},
}),
}),
})
}
83 changes: 83 additions & 0 deletions snippets/java/query_points.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,86 @@
.setQuery(sample(Sample.Random))
.build())
.get();

// Score boost depending on payload conditions (as of 1.14.0)
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.addPrefetch(
PrefetchQuery.newBuilder()
.setQuery(nearest(0.01f, 0.45f, 0.67f))
.setLimit(100)
.build())
.setQuery(
formula(
Formula.newBuilder()
.setExpression(
sum(
SumExpression.newBuilder()
.addSum(variable("$score"))
.addSum(
mult(
MultExpression.newBuilder()
.addMult(constant(0.5f))
.addMult(
condition(
matchKeywords(
"tag",
List.of("h1", "h2", "h3", "h4"))))
.build()))
.addSum(mult(MultExpression.newBuilder()
.addMult(constant(0.25f))
.addMult(
condition(
matchKeywords(
"tag",
List.of("p", "li"))))
.build()))
.build()))
.build()))
.build())
.get();

// Score boost geographically closer points (as of 1.14.0)
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.addPrefetch(
PrefetchQuery.newBuilder()
.setQuery(nearest(0.01f, 0.45f, 0.67f))
.setLimit(100)
.build())
.setQuery(
formula(
Formula.newBuilder()
.setExpression(
sum(
SumExpression.newBuilder()
.addSum(variable("$score"))
.addSum(
expDecay(
DecayParamsExpression.newBuilder()
.setX(
geoDistance(
GeoDistance.newBuilder()
.setOrigin(
GeoPoint.newBuilder()
.setLat(52.504043)
.setLon(13.393236)
.build())
.setTo("geo.location")
.build()))
.setScale(5000)
.build()))
.build()))
.putDefaults(
"geo.location",
value(
Map.of(
"lat", value(48.137154),
"lon", value(11.576124))))
.build()))
.build())
.get();
47 changes: 46 additions & 1 deletion snippets/python/query_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,50 @@
# Random sampling (as of 1.11.0)
sampled = client.query_points(
collection_name="{collection_name}",
query=models.SampleQuery(sample=models.Sample.Random)
query=models.SampleQuery(sample=models.Sample.RANDOM)
)

# Score boost depending on payload conditions (as of 1.14.0)
tag_boosted = client.query_points(
collection_name="{collection_name}",
prefetch=models.Prefetch(
query=[0.2, 0.8, ...], # <-- dense vector
limit=50
),
query=models.FormulaQuery(
formula=models.SumExpression(sum=[
"$score",
models.MultExpression(mult=[0.5, models.FieldCondition(key="tag", match=models.MatchAny(any=["h1", "h2", "h3", "h4"]))]),
models.MultExpression(mult=[0.25, models.FieldCondition(key="tag", match=models.MatchAny(any=["p", "li"]))])
]
))
)

# Score boost geographically closer points (as of 1.14.0)
geo_boosted = client.query_points(
collection_name="{collection_name}",
prefetch=models.Prefetch(
query=[0.2, 0.8, ...], # <-- dense vector
limit=50
),
query=models.FormulaQuery(
formula=models.SumExpression(sum=[
"$score",
models.GaussDecayExpression(
gauss_decay=models.DecayParamsExpression(
x=models.GeoDistance(
geo_distance=models.GeoDistanceParams(
origin=models.GeoPoint(
lat=52.504043,
lon=13.393236
), # Berlin
to="geo.location"
)
),
scale=5000 # 5km
)
)
]),
defaults={"geo.location": models.GeoPoint(lat=48.137154, lon=11.576124)} # Munich
)
)
Loading