diff --git a/fern/apis/master/openapi-overrides.yml b/fern/apis/master/openapi-overrides.yml index ac2a870..a993fd4 100644 --- a/fern/apis/master/openapi-overrides.yml +++ b/fern/apis/master/openapi-overrides.yml @@ -916,7 +916,7 @@ paths: - code: "using Qdrant.Client;\nusing Qdrant.Client.Grpc;\n\nvar client = new QdrantClient(\"localhost\", 6334);\n\n// Query nearest by ID\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tquery: Guid.Parse(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")\n);\n\n// Recommend on the average of these vectors\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tquery: new RecommendInput\n\t{\n\t\tPositive =\n\t\t{\n\t\t\tGuid.Parse(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"),\n\t\t\tnew float[] { 0.11f, 0.35f, 0.6f }\n\t\t},\n\t\tNegative = { new float[] { 0.01f, 0.45f, 0.67f } }\n\t}\n);\n\n// Fusion query\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tprefetch: new List\n\t{\n\t\tnew()\n\t\t{\n\t\t\tQuery = new (float, uint)[] { (0.22f, 1), (0.8f, 42), },\n\t\t\tUsing = \"sparse\",\n\t\t\tLimit = 20\n\t\t},\n\t\tnew()\n\t\t{\n\t\t\tQuery = new float[] { 0.01f, 0.45f, 0.67f },\n\t\t\tUsing = \"dense\",\n\t\t\tLimit = 20\n\t\t}\n\t},\n\tquery: Fusion.Rrf\n);\n\n// 2-stage query\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tprefetch: new List\n\t{\n\t\tnew() { Query = new float[] { 0.01f, 0.45f, 0.67f }, Limit = 100 }\n\t},\n\tquery: new float[][] { [0.1f, 0.2f], [0.2f, 0.1f], [0.8f, 0.9f] },\n\tusingVector: \"colbert\",\n\tlimit: 10\n);\n\n// Random sampling (as of 1.11.0)\nawait client.QueryAsync(\n collectionName: \"{collection_name}\",\n query: Sample.Random\n);\n\n// Score boost depending on payload conditions (as of 1.14.0)\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tprefetch:\n\t[\n\t\tnew PrefetchQuery { Query = new float[] { 0.01f, 0.45f, 0.67f }, Limit = 100 },\n\t],\n\tquery: new Formula\n\t{\n\t\tExpression = new SumExpression\n\t\t{\n\t\t\tSum =\n\t\t\t{\n\t\t\t\t\"$score\",\n\t\t\t\tnew MultExpression\n\t\t\t\t{\n\t\t\t\t\tMult = { 0.5f, Match(\"tag\", [\"h1\", \"h2\", \"h3\", \"h4\"]) },\n\t\t\t\t},\n\t\t\t\tnew MultExpression { Mult = { 0.25f, Match(\"tag\", [\"p\", \"li\"]) } },\n\t\t\t},\n\t\t},\n\t},\n\tlimit: 10\n);\n\n// Score boost geographically closer points (as of 1.14.0)\nawait client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\tprefetch:\n\t[\n\t\tnew PrefetchQuery { Query = new float[] { 0.01f, 0.45f, 0.67f }, Limit = 100 },\n\t],\n\tquery: new Formula\n\t{\n\t\tExpression = new SumExpression\n\t\t{\n\t\t\tSum =\n\t\t\t{\n\t\t\t\t\"$score\",\n\t\t\t\tWithExpDecay(\n\t\t\t\t\tnew()\n\t\t\t\t\t{\n\t\t\t\t\t\tX = new GeoDistance\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tOrigin = new GeoPoint { Lat = 52.504043, Lon = 13.393236 },\n\t\t\t\t\t\t\tTo = \"geo.location\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tScale = 5000,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\tDefaults =\n\t\t{\n\t\t\t[\"geo.location\"] = new Dictionary\n\t\t\t{\n\t\t\t\t[\"lat\"] = 48.137154,\n\t\t\t\t[\"lon\"] = 11.576124,\n\t\t\t},\n\t\t},\n\t}\n);\n" language: csharp - code-samples: - - code: "use qdrant_client::qdrant::{\n Condition, DecayParamsExpressionBuilder, Expression, FormulaBuilder, Fusion, GeoPoint,\n PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder, RecommendInputBuilder,\n Sample,\n};\nuse qdrant_client::Qdrant;\n\nlet client = Qdrant::from_url(\"http://localhost:6334\").build()?;\n\n// Query nearest by ID\nlet _nearest = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(PointId::from(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"))\n).await?;\n\n// Recommend on the average of these vectors\nlet _recommendations = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(Query::new_recommend(\n RecommendInputBuilder::default()\n .add_positive(vec![0.1; 8])\n .add_negative(PointId::from(0))\n ))\n).await?;\n\n// Fusion query\nlet _hybrid = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![(1, 0.22), (42, 0.8)])\n .using(\"sparse\")\n .limit(20u64)\n )\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .using(\"dense\")\n .limit(20u64)\n )\n .query(Fusion::Rrf)\n).await?;\n\n// 2-stage query\nlet _refined = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64)\n )\n .query(vec![\n vec![0.1, 0.2],\n vec![0.2, 0.1],\n vec![0.8, 0.9],\n ])\n .using(\"colbert\")\n .limit(10u64)\n).await?;\n\n// Random sampling (as of 1.11.0)\nlet _sampled = client\n .query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(Query::new_sample(Sample::Random))\n )\n .await?;\n\n// Score boost depending on payload conditions (as of 1.14.0)\nlet _tag_boosted = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64)\n )\n .query(FormulaBuilder::new(Expression::sum_with([\n Expression::variable(\"$score\"),\n Expression::mult_with([\n Expression::constant(0.5),\n Expression::condition(Condition::matches(\"tag\", [\"h1\", \"h2\", \"h3\", \"h4\"])),\n ]),\n Expression::mult_with([\n Expression::constant(0.25),\n Expression::condition(Condition::matches(\"tag\", [\"p\", \"li\"])),\n ]),\n ])))\n .limit(10)\n ).await?;\n\n// Score boost geographically closer points (as of 1.14.0)\nlet _geo_boosted = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(\n PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64),\n )\n .query(\n FormulaBuilder::new(Expression::sum_with([\n Expression::variable(\"$score\"),\n Expression::exp_decay(\n DecayParamsExpressionBuilder::new(Expression::geo_distance_with(\n // Berlin\n GeoPoint { lat: 52.504043, lon: 13.393236 },\n \"geo.location\",\n ))\n .scale(5_000.0),\n ),\n ]))\n // Munich\n .add_default(\"geo.location\", GeoPoint { lat: 48.137154, lon: 11.576124 }),\n )\n .limit(10),\n )\n .await?;\n" + - code: "use qdrant_client::qdrant::{\n Condition, DecayParamsExpressionBuilder, Expression, FormulaBuilder, Fusion, GeoPoint,\n PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder, RecommendInputBuilder,\n Sample,\n};\nuse qdrant_client::Qdrant;\n\nlet client = Qdrant::from_url(\"http://localhost:6334\").build()?;\n\n// Query nearest by ID\nlet _nearest = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(PointId::from(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"))\n).await?;\n\n// Recommend on the average of these vectors\nlet _recommendations = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(Query::new_recommend(\n RecommendInputBuilder::default()\n .add_positive(vec![0.1; 8])\n .add_negative(PointId::from(0))\n ))\n).await?;\n\n// Fusion query\nlet _hybrid = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![(1, 0.22), (42, 0.8)])\n .using(\"sparse\")\n .limit(20u64)\n )\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .using(\"dense\")\n .limit(20u64)\n )\n .query(Fusion::Rrf)\n).await?;\n\n// 2-stage query\nlet _refined = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64)\n )\n .query(vec![\n vec![0.1, 0.2],\n vec![0.2, 0.1],\n vec![0.8, 0.9],\n ])\n .using(\"colbert\")\n .limit(10u64)\n).await?;\n\n// Random sampling (as of 1.11.0)\nlet _sampled = client\n .query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .query(Query::new_sample(Sample::Random))\n )\n .await?;\n\n// Score boost depending on payload conditions (as of 1.14.0)\nlet _tag_boosted = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64)\n )\n .query(FormulaBuilder::new(Expression::sum_with([\n Expression::score(),\n Expression::mult_with([\n Expression::constant(0.5),\n Expression::condition(Condition::matches(\"tag\", [\"h1\", \"h2\", \"h3\", \"h4\"])),\n ]),\n Expression::mult_with([\n Expression::constant(0.25),\n Expression::condition(Condition::matches(\"tag\", [\"p\", \"li\"])),\n ]),\n ])))\n .limit(10)\n ).await?;\n\n// Score boost geographically closer points (as of 1.14.0)\nlet _geo_boosted = client.query(\n QueryPointsBuilder::new(\"{collection_name}\")\n .add_prefetch(\n PrefetchQueryBuilder::default()\n .query(vec![0.01, 0.45, 0.67])\n .limit(100u64),\n )\n .query(\n FormulaBuilder::new(Expression::sum_with([\n Expression::score(),\n Expression::exp_decay(\n DecayParamsExpressionBuilder::new(Expression::geo_distance_with(\n // Berlin\n GeoPoint { lat: 52.504043, lon: 13.393236 },\n \"geo.location\",\n ))\n .scale(5_000.0),\n ),\n ]))\n // Munich\n .add_default(\"geo.location\", GeoPoint { lat: 48.137154, lon: 11.576124 }),\n )\n .limit(10),\n )\n .await?;\n" language: rust - code-samples: - code: "# Query nearest by ID\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"query\": \"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"\n}'\n\n# Recommend on the average of these vectors\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"query\": {\n \"recommend\": {\n \"positive\": [\n [\n 0.11,\n 0.35,\n 0.6\n ]\n ],\n \"negative\": [\n \"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\",\n [\n 0.01,\n 0.45,\n 0.67\n ]\n ]\n }\n }\n}'\n\n# Fusion query\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"prefetch\": [\n {\n \"query\": {\n \"values\": [\n 0.22,\n 0.8\n ],\n \"indices\": [\n 1,\n 42\n ]\n },\n \"using\": \"sparse\",\n \"limit\": 20\n },\n {\n \"query\": [\n 0.01,\n 0.45,\n 0.67\n ],\n \"using\": \"dense\",\n \"limit\": 20\n }\n ],\n \"query\": {\n \"fusion\": \"rrf\"\n }\n}'\n\n# 2-stage query\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"prefetch\": {\n \"query\": [\n 1,\n 23,\n 45,\n 67\n ],\n \"limit\": 100\n },\n \"query\": [\n [\n 0.1,\n 0.2,\n 0.3\n ],\n [\n 0.2,\n 0.1,\n 0.35\n ],\n [\n 0.8,\n 0.9,\n 0.53\n ]\n ],\n \"using\": \"colbert\",\n \"limit\": 10\n}'\n\n# Random sampling (as of 1.11.0)\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"query\": {\n \"sample\": \"random\"\n }\n}'\n\n# Score boost depending on payload conditions (as of 1.14.0)\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"prefetch\": {\n \"query\": [0.2, 0.8, ...], // <-- dense vector\n \"limit\": 50\n }\n \"query\": {\n \"formula\": {\n \"sum\": [\n \"$score,\n { \"mult\": [ 0.5, { \"key\": \"tag\", \"match\": { \"any\": [\"h1\", \"h2\", \"h3\", \"h4\"] } } ] },\n { \"mult\": [ 0.25, { \"key\": \"tag\", \"match\": { \"any\": [\"p\", \"li\"] } } ] }\n ]\n }\n }\n}'\n\n# Score boost geographically closer points (as of 1.14.0)\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query' \\\n --header 'api-key: ' \\\n --header 'Content-Type: application/json' \\\n --data-raw '{\n \"prefetch\": { \"query\": [0.2, 0.8, ...], \"limit\": 50 },\n \"query\": {\n \"formula\": {\n \"sum\": [\n \"$score\",\n {\n \"gauss_decay\": {\n \"x\": {\n \"geo_distance\": {\n \"origin\": { \"lat\": 52.504043, \"lon\": 13.393236 } // Berlin\n \"to\": \"geo.location\"\n }\n },\n \"scale\": 5000 // 5km\n }\n }\n ]\n },\n \"defaults\": { \"geo.location\": {\"lat\": 48.137154, \"lon\": 11.576124} } // Munich\n }\n}'\n" diff --git a/fern/apis/v1.14.x/openapi-overrides.yml b/fern/apis/v1.14.x/openapi-overrides.yml index 1e098bd..776c192 100644 --- a/fern/apis/v1.14.x/openapi-overrides.yml +++ b/fern/apis/v1.14.x/openapi-overrides.yml @@ -1964,7 +1964,7 @@ paths: {collection_name}\")\n .add_prefetch(PrefetchQueryBuilder::default()\n\ \ .query(vec![0.01, 0.45, 0.67])\n .limit(100u64)\n\ \ )\n .query(FormulaBuilder::new(Expression::sum_with([\n\ - \ Expression::variable(\"$score\"),\n Expression::mult_with([\n\ + \ Expression::score(),\n Expression::mult_with([\n\ \ Expression::constant(0.5),\n Expression::condition(Condition::matches(\"\ tag\", [\"h1\", \"h2\", \"h3\", \"h4\"])),\n ]),\n \ \ Expression::mult_with([\n Expression::constant(0.25),\n\ @@ -1976,8 +1976,8 @@ paths: \ .query(vec![0.01, 0.45, 0.67])\n \ \ .limit(100u64),\n )\n .query(\n \ \ FormulaBuilder::new(Expression::sum_with([\n \ - \ Expression::variable(\"$score\"),\n Expression::exp_decay(\n\ - \ DecayParamsExpressionBuilder::new(Expression::geo_distance_with(\n\ + \ Expression::score(),\n Expression::exp_decay(\n \ + \ DecayParamsExpressionBuilder::new(Expression::geo_distance_with(\n\ \ // Berlin\n GeoPoint\ \ { lat: 52.504043, lon: 13.393236 },\n \"\ geo.location\",\n ))\n .scale(5_000.0),\n\ diff --git a/snippets/rust/query_points.rs b/snippets/rust/query_points.rs index e52cf1d..ccb8597 100644 --- a/snippets/rust/query_points.rs +++ b/snippets/rust/query_points.rs @@ -71,7 +71,7 @@ let _tag_boosted = client.query( .limit(100u64) ) .query(FormulaBuilder::new(Expression::sum_with([ - Expression::variable("$score"), + Expression::score(), Expression::mult_with([ Expression::constant(0.5), Expression::condition(Condition::matches("tag", ["h1", "h2", "h3", "h4"])), @@ -94,7 +94,7 @@ let _geo_boosted = client.query( ) .query( FormulaBuilder::new(Expression::sum_with([ - Expression::variable("$score"), + Expression::score(), Expression::exp_decay( DecayParamsExpressionBuilder::new(Expression::geo_distance_with( // Berlin