diff --git a/fern/apis/master/openapi-overrides.yml b/fern/apis/master/openapi-overrides.yml index 784940e..ac2a870 100644 --- a/fern/apis/master/openapi-overrides.yml +++ b/fern/apis/master/openapi-overrides.yml @@ -913,25 +913,25 @@ paths: post: x-fern-examples: - code-samples: - - 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" + - 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;\nuse qdrant_client::qdrant::{Condition, Filter, PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder};\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(Query::new_nearest(PointId::new(\"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(Query::new_nearest([(1, 0.22), (42, 0.8)].as_slice()))\n .using(\"sparse\")\n .limit(20u64)\n )\n .add_prefetch(PrefetchQueryBuilder::default()\n .query(Query::new_nearest(vec![0.01, 0.45, 0.67]))\n .using(\"dense\")\n .limit(20u64)\n )\n .query(Query::new_fusion(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(Query::new_nearest(vec![0.01, 0.45, 0.67]))\n .limit(100u64)\n )\n .query(Query::new_nearest(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" + - 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" 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" + - 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" language: curl - code-samples: - - code: "from qdrant_client import QdrantClient, models\n\nclient = QdrantClient(url=\"http://localhost:6333\")\n\n# Query nearest by ID\nnearest = client.query_points(\n collection_name=\"{collection_name}\",\n query=\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\",\n)\n\n# Recommend on the average of these vectors\nrecommended = client.query_points(\n collection_name=\"{collection_name}\",\n query=models.RecommendQuery(recommend=models.RecommendInput(\n positive=[\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\", [0.11, 0.35, 0.6, ...]],\n negative=[[0.01, 0.45, 0.67, ...]]\n ))\n)\n\n# Fusion query\nhybrid = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=[\n models.Prefetch(\n query=models.SparseVector(indices=[1, 42], values=[0.22, 0.8]),\n using=\"sparse\",\n limit=20,\n ),\n models.Prefetch(\n query=[0.01, 0.45, 0.67, ...], # <-- dense vector\n using=\"dense\",\n limit=20,\n ),\n ],\n query=models.FusionQuery(fusion=models.Fusion.RRF),\n)\n\n# 2-stage query\nrefined = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=models.Prefetch(\n query=[0.01, 0.45, 0.67, ...], # <-- dense vector\n limit=100,\n ),\n query=[\n [0.1, 0.2, ...], # <─┐\n [0.2, 0.1, ...], # < ├─ multi-vector\n [0.8, 0.9, ...], # < ┘\n ],\n using=\"colbert\",\n limit=10,\n)\n\n# Random sampling (as of 1.11.0)\nsampled = client.query_points(\n collection_name=\"{collection_name}\",\n query=models.SampleQuery(sample=models.Sample.Random)\n)\n" + - code: "from qdrant_client import QdrantClient, models\n\nclient = QdrantClient(url=\"http://localhost:6333\")\n\n# Query nearest by ID\nnearest = client.query_points(\n collection_name=\"{collection_name}\",\n query=\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\",\n)\n\n# Recommend on the average of these vectors\nrecommended = client.query_points(\n collection_name=\"{collection_name}\",\n query=models.RecommendQuery(recommend=models.RecommendInput(\n positive=[\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\", [0.11, 0.35, 0.6, ...]],\n negative=[[0.01, 0.45, 0.67, ...]]\n ))\n)\n\n# Fusion query\nhybrid = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=[\n models.Prefetch(\n query=models.SparseVector(indices=[1, 42], values=[0.22, 0.8]),\n using=\"sparse\",\n limit=20,\n ),\n models.Prefetch(\n query=[0.01, 0.45, 0.67, ...], # <-- dense vector\n using=\"dense\",\n limit=20,\n ),\n ],\n query=models.FusionQuery(fusion=models.Fusion.RRF),\n)\n\n# 2-stage query\nrefined = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=models.Prefetch(\n query=[0.01, 0.45, 0.67, ...], # <-- dense vector\n limit=100,\n ),\n query=[\n [0.1, 0.2, ...], # <─┐\n [0.2, 0.1, ...], # < ├─ multi-vector\n [0.8, 0.9, ...], # < ┘\n ],\n using=\"colbert\",\n limit=10,\n)\n\n# Random sampling (as of 1.11.0)\nsampled = client.query_points(\n collection_name=\"{collection_name}\",\n query=models.SampleQuery(sample=models.Sample.RANDOM)\n)\n\n# Score boost depending on payload conditions (as of 1.14.0)\ntag_boosted = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=models.Prefetch(\n query=[0.2, 0.8, ...], # <-- dense vector\n limit=50\n ),\n query=models.FormulaQuery(\n formula=models.SumExpression(sum=[\n \"$score\",\n models.MultExpression(mult=[0.5, models.FieldCondition(key=\"tag\", match=models.MatchAny(any=[\"h1\", \"h2\", \"h3\", \"h4\"]))]),\n models.MultExpression(mult=[0.25, models.FieldCondition(key=\"tag\", match=models.MatchAny(any=[\"p\", \"li\"]))])\n ]\n ))\n)\n\n# Score boost geographically closer points (as of 1.14.0)\ngeo_boosted = client.query_points(\n collection_name=\"{collection_name}\",\n prefetch=models.Prefetch(\n query=[0.2, 0.8, ...], # <-- dense vector\n limit=50\n ),\n query=models.FormulaQuery(\n formula=models.SumExpression(sum=[\n \"$score\",\n models.GaussDecayExpression(\n gauss_decay=models.DecayParamsExpression(\n x=models.GeoDistance(\n geo_distance=models.GeoDistanceParams(\n origin=models.GeoPoint(\n lat=52.504043,\n lon=13.393236\n ), # Berlin\n to=\"geo.location\"\n )\n ),\n scale=5000 # 5km\n )\n )\n ]),\n defaults={\"geo.location\": models.GeoPoint(lat=48.137154, lon=11.576124)} # Munich\n )\n)\n" language: python - code-samples: - - code: "import static io.qdrant.client.QueryFactory.fusion;\nimport static io.qdrant.client.QueryFactory.nearest;\nimport static io.qdrant.client.QueryFactory.recommend;\nimport static io.qdrant.client.VectorInputFactory.vectorInput;\n\nimport java.util.UUID;\n\nimport io.qdrant.client.QdrantClient;\nimport io.qdrant.client.QdrantGrpcClient;\nimport io.qdrant.client.grpc.Points.Fusion;\nimport io.qdrant.client.grpc.Points.PrefetchQuery;\nimport io.qdrant.client.grpc.Points.QueryPoints;\nimport io.qdrant.client.grpc.Points.RecommendInput;\n\nQdrantClient client =\n new QdrantClient(QdrantGrpcClient.newBuilder(\"localhost\", 6334, false).build());\n\n// Query nearest by ID\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(nearest(UUID.fromString(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")))\n .build())\n .get();\n\n// Recommend on the average of these vectors\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(\n recommend(\n RecommendInput.newBuilder()\n .addPositive(vectorInput(UUID.fromString(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")))\n .addPositive(vectorInput(0.11f, 0.35f, 0.6f))\n .addNegative(vectorInput(0.01f, 0.45f, 0.67f))\n .build()))\n .build())\n .get();\n\n// Fusion query\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(List.of(0.22f, 0.8f), List.of(1, 42)))\n .setUsing(\"sparse\")\n .setLimit(20)\n .build())\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(List.of(0.01f, 0.45f, 0.67f)))\n .setUsing(\"dense\")\n .setLimit(20)\n .build())\n .setQuery(fusion(Fusion.RRF))\n .build())\n .get();\n\n// 2-stage query\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f, 0.45f, 0.67f))\n .setLimit(100)\n .build())\n .setQuery(\n nearest(\n new float[][] {\n {0.1f, 0.2f},\n {0.2f, 0.1f},\n {0.8f, 0.9f}\n }))\n .setUsing(\"colbert\")\n .setLimit(10)\n .build())\n .get();\n\n// Random sampling (as of 1.11.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(sample(Sample.Random))\n .build())\n .get();\n" + - code: "import static io.qdrant.client.QueryFactory.fusion;\nimport static io.qdrant.client.QueryFactory.nearest;\nimport static io.qdrant.client.QueryFactory.recommend;\nimport static io.qdrant.client.VectorInputFactory.vectorInput;\n\nimport java.util.UUID;\n\nimport io.qdrant.client.QdrantClient;\nimport io.qdrant.client.QdrantGrpcClient;\nimport io.qdrant.client.grpc.Points.Fusion;\nimport io.qdrant.client.grpc.Points.PrefetchQuery;\nimport io.qdrant.client.grpc.Points.QueryPoints;\nimport io.qdrant.client.grpc.Points.RecommendInput;\n\nQdrantClient client =\n new QdrantClient(QdrantGrpcClient.newBuilder(\"localhost\", 6334, false).build());\n\n// Query nearest by ID\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(nearest(UUID.fromString(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")))\n .build())\n .get();\n\n// Recommend on the average of these vectors\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(\n recommend(\n RecommendInput.newBuilder()\n .addPositive(vectorInput(UUID.fromString(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")))\n .addPositive(vectorInput(0.11f, 0.35f, 0.6f))\n .addNegative(vectorInput(0.01f, 0.45f, 0.67f))\n .build()))\n .build())\n .get();\n\n// Fusion query\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(List.of(0.22f, 0.8f), List.of(1, 42)))\n .setUsing(\"sparse\")\n .setLimit(20)\n .build())\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(List.of(0.01f, 0.45f, 0.67f)))\n .setUsing(\"dense\")\n .setLimit(20)\n .build())\n .setQuery(fusion(Fusion.RRF))\n .build())\n .get();\n\n// 2-stage query\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f, 0.45f, 0.67f))\n .setLimit(100)\n .build())\n .setQuery(\n nearest(\n new float[][] {\n {0.1f, 0.2f},\n {0.2f, 0.1f},\n {0.8f, 0.9f}\n }))\n .setUsing(\"colbert\")\n .setLimit(10)\n .build())\n .get();\n\n// Random sampling (as of 1.11.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .setQuery(sample(Sample.Random))\n .build())\n .get();\n\n// Score boost depending on payload conditions (as of 1.14.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f, 0.45f, 0.67f))\n .setLimit(100)\n .build())\n .setQuery(\n formula(\n Formula.newBuilder()\n .setExpression(\n sum(\n SumExpression.newBuilder()\n .addSum(variable(\"$score\"))\n .addSum(\n mult(\n MultExpression.newBuilder()\n .addMult(constant(0.5f))\n .addMult(\n condition(\n matchKeywords(\n \"tag\",\n List.of(\"h1\", \"h2\", \"h3\", \"h4\"))))\n .build()))\n .addSum(mult(MultExpression.newBuilder()\n .addMult(constant(0.25f))\n .addMult(\n condition(\n matchKeywords(\n \"tag\",\n List.of(\"p\", \"li\"))))\n .build()))\n .build()))\n .build()))\n .build())\n .get();\n\n// Score boost geographically closer points (as of 1.14.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f, 0.45f, 0.67f))\n .setLimit(100)\n .build())\n .setQuery(\n formula(\n Formula.newBuilder()\n .setExpression(\n sum(\n SumExpression.newBuilder()\n .addSum(variable(\"$score\"))\n .addSum(\n expDecay(\n DecayParamsExpression.newBuilder()\n .setX(\n geoDistance(\n GeoDistance.newBuilder()\n .setOrigin(\n GeoPoint.newBuilder()\n .setLat(52.504043)\n .setLon(13.393236)\n .build())\n .setTo(\"geo.location\")\n .build()))\n .setScale(5000)\n .build()))\n .build()))\n .putDefaults(\n \"geo.location\",\n value(\n Map.of(\n \"lat\", value(48.137154),\n \"lon\", value(11.576124))))\n .build()))\n .build())\n .get();\n" language: java - code-samples: - - code: "package client\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/qdrant/go-client/qdrant\"\n)\n\nfunc query() {\n\tclient, err := qdrant.NewClient(&qdrant.Config{\n\t\tHost: \"localhost\",\n\t\tPort: 6334,\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Query nearest by ID\n\tpoints, err := client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQueryID(qdrant.NewID(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Recommend on the average of these vectors\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQueryRecommend(&qdrant.RecommendInput{\n\t\t\tPositive: []*qdrant.VectorInput{\n\t\t\t\tqdrant.NewVectorInputID(qdrant.NewID(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")),\n\t\t\t\tqdrant.NewVectorInput(0.11, 0.35, 0.6),\n\t\t\t},\n\t\t\tNegative: []*qdrant.VectorInput{\n\t\t\t\tqdrant.NewVectorInput(0.01, 0.45, 0.67),\n\t\t\t},\n\t\t}),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Fusion query\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuerySparse([]uint32{1, 42}, []float32{0.22, 0.8}),\n\t\t\t\tUsing: qdrant.PtrOf(\"sparse\"),\n\t\t\t},\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t\tUsing: qdrant.PtrOf(\"dense\"),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryFusion(qdrant.Fusion_RRF),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// 2-stage query\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryMulti([][]float32{\n\t\t\t{0.1, 0.2},\n\t\t\t{0.2, 0.1},\n\t\t\t{0.8, 0.9},\n\t\t}),\n\t\tUsing: qdrant.PtrOf(\"colbert\"),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Random sampling (as of 1.11.0)\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQuerySample(qdrant.Sample_Random),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n}\n" + - code: "package client\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/qdrant/go-client/qdrant\"\n)\n\nfunc query() {\n\tclient, err := qdrant.NewClient(&qdrant.Config{\n\t\tHost: \"localhost\",\n\t\tPort: 6334,\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Query nearest by ID\n\tpoints, err := client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQueryID(qdrant.NewID(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Recommend on the average of these vectors\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQueryRecommend(&qdrant.RecommendInput{\n\t\t\tPositive: []*qdrant.VectorInput{\n\t\t\t\tqdrant.NewVectorInputID(qdrant.NewID(\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")),\n\t\t\t\tqdrant.NewVectorInput(0.11, 0.35, 0.6),\n\t\t\t},\n\t\t\tNegative: []*qdrant.VectorInput{\n\t\t\t\tqdrant.NewVectorInput(0.01, 0.45, 0.67),\n\t\t\t},\n\t\t}),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Fusion query\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuerySparse([]uint32{1, 42}, []float32{0.22, 0.8}),\n\t\t\t\tUsing: qdrant.PtrOf(\"sparse\"),\n\t\t\t},\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t\tUsing: qdrant.PtrOf(\"dense\"),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryFusion(qdrant.Fusion_RRF),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// 2-stage query\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryMulti([][]float32{\n\t\t\t{0.1, 0.2},\n\t\t\t{0.2, 0.1},\n\t\t\t{0.8, 0.9},\n\t\t}),\n\t\tUsing: qdrant.PtrOf(\"colbert\"),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Random sampling (as of 1.11.0)\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQuerySample(qdrant.Sample_Random),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results: \", points)\n\n\t// Score boost depending on payload conditions (as of 1.14.0)\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryFormula(&qdrant.Formula{\n\t\t\tExpression: qdrant.NewExpressionSum(&qdrant.SumExpression{\n\t\t\t\tSum: []*qdrant.Expression{\n\t\t\t\t\tqdrant.NewExpressionVariable(\"$score\"),\n\t\t\t\t\tqdrant.NewExpressionMult(&qdrant.MultExpression{\n\t\t\t\t\t\tMult: []*qdrant.Expression{\n\t\t\t\t\t\t\tqdrant.NewExpressionConstant(0.5),\n\t\t\t\t\t\t\tqdrant.NewExpressionCondition(qdrant.NewMatchKeywords(\"tag\", \"h1\", \"h2\", \"h3\", \"h4\")),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t\tqdrant.NewExpressionMult(&qdrant.MultExpression{\n\t\t\t\t\t\tMult: []*qdrant.Expression{\n\t\t\t\t\t\t\tqdrant.NewExpressionConstant(0.25),\n\t\t\t\t\t\t\tqdrant.NewExpressionCondition(qdrant.NewMatchKeywords(\"tag\", \"p\", \"li\")),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t}),\n\t\t}),\n\t})\n\n\t// Score boost geographically closer points (as of 1.14.0)\n\tclient.Query(context.Background(), &qdrant.QueryPoints{\n\t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.2, 0.8),\n\t\t\t},\n\t\t},\n\t\tQuery: qdrant.NewQueryFormula(&qdrant.Formula{\n\t\t\tExpression: qdrant.NewExpressionSum(&qdrant.SumExpression{\n\t\t\t\tSum: []*qdrant.Expression{\n\t\t\t\t\tqdrant.NewExpressionVariable(\"$score\"),\n\t\t\t\t\tqdrant.NewExpressionExpDecay(&qdrant.DecayParamsExpression{\n\t\t\t\t\t\tX: qdrant.NewExpressionGeoDistance(&qdrant.GeoDistance{\n\t\t\t\t\t\t\tOrigin: &qdrant.GeoPoint{\n\t\t\t\t\t\t\t\tLat: 52.504043,\n\t\t\t\t\t\t\t\tLon: 13.393236,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tTo: \"geo.location\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t}),\n\t\t\tDefaults: qdrant.NewValueMap(map[string]any{\n\t\t\t\t\"geo.location\": map[string]any{\n\t\t\t\t\t\"lat\": 48.137154,\n\t\t\t\t\t\"lon\": 11.576124,\n\t\t\t\t},\n\t\t\t}),\n\t\t}),\n\t})\n}\n" language: go - code-samples: - - code: "import { QdrantClient } from \"@qdrant/js-client-rest\";\n\nconst client = new QdrantClient({ host: \"localhost\", port: 6333 });\n\n// Query nearest by ID\nlet _nearest = client.query(\"{collection_name\", {\n query: \"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"\n});\n\n// Recommend on the average of these vectors\nlet _recommendations = client.query(\"{collection_name}\", {\n query: {\n recommend: {\n positive: [\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\", [0.11, 0.35, 0.6]],\n negative: [0.01, 0.45, 0.67]\n }\n }\n});\n\n// Fusion query\nlet _hybrid = client.query(\"{collection_name}\", {\n prefetch: [\n {\n query: {\n values: [0.22, 0.8],\n indices: [1, 42],\n },\n using: 'sparse',\n limit: 20,\n },\n {\n query: [0.01, 0.45, 0.67],\n using: 'dense',\n limit: 20,\n },\n ],\n query: {\n fusion: 'rrf',\n },\n});\n\n// 2-stage query\nlet _refined = client.query(\"{collection_name}\", {\n prefetch: {\n query: [1, 23, 45, 67],\n limit: 100,\n },\n query: [\n [0.1, 0.2],\n [0.2, 0.1],\n [0.8, 0.9],\n ],\n using: 'colbert',\n limit: 10,\n});\n\n// Random sampling (as of 1.11.0)\nlet _sampled = client.query(\"{collection_name}\", {\n query: { sample: \"random\" },\n});\n" + - code: "import { QdrantClient } from \"@qdrant/js-client-rest\";\n\nconst client = new QdrantClient({ host: \"localhost\", port: 6333 });\n\n// Query nearest by ID\nlet _nearest = client.query(\"{collection_name\", {\n query: \"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\"\n});\n\n// Recommend on the average of these vectors\nlet _recommendations = client.query(\"{collection_name}\", {\n query: {\n recommend: {\n positive: [\"43cf51e2-8777-4f52-bc74-c2cbde0c8b04\", [0.11, 0.35, 0.6]],\n negative: [0.01, 0.45, 0.67]\n }\n }\n});\n\n// Fusion query\nlet _hybrid = client.query(\"{collection_name}\", {\n prefetch: [\n {\n query: {\n values: [0.22, 0.8],\n indices: [1, 42],\n },\n using: 'sparse',\n limit: 20,\n },\n {\n query: [0.01, 0.45, 0.67],\n using: 'dense',\n limit: 20,\n },\n ],\n query: {\n fusion: 'rrf',\n },\n});\n\n// 2-stage query\nlet _refined = client.query(\"{collection_name}\", {\n prefetch: {\n query: [1, 23, 45, 67],\n limit: 100,\n },\n query: [\n [0.1, 0.2],\n [0.2, 0.1],\n [0.8, 0.9],\n ],\n using: 'colbert',\n limit: 10,\n});\n\n// Random sampling (as of 1.11.0)\nlet _sampled = client.query(\"{collection_name}\", {\n query: { sample: \"random\" },\n});\n\n// Score boost depending on payload conditions (as of 1.14.0)\nconst tag_boosted = await client.query(\"{collection_name}\", {\n prefetch: {\n query: [0.2, 0.8, 0.1, 0.9],\n limit: 50\n },\n query: {\n formula: {\n sum: [\n \"$score\",\n {\n mult: [ 0.5, { key: \"tag\", match: { any: [\"h1\", \"h2\", \"h3\", \"h4\"] }} ]\n },\n {\n mult: [ 0.25, { key: \"tag\", match: { any: [\"p\", \"li\"] }} ]\n }\n ]\n }\n }\n});\n\n// Score boost geographically closer points (as of 1.14.0)\nconst distance_boosted = await client.query(\"{collection_name}\", {\n prefetch: {\n query: [0.2, 0.8, ...],\n limit: 50\n },\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" language: typescript description: Universally query points. This endpoint covers all capabilities of search, recommend, discover, filters. But also enables hybrid and multi-stage queries. summary: Query points diff --git a/fern/apis/v1.14.x/openapi-overrides.yml b/fern/apis/v1.14.x/openapi-overrides.yml index 36ad8da..1e098bd 100644 --- a/fern/apis/v1.14.x/openapi-overrides.yml +++ b/fern/apis/v1.14.x/openapi-overrides.yml @@ -1912,41 +1912,85 @@ paths: \ 0.2f], [0.2f, 0.1f], [0.8f, 0.9f] },\n\tusingVector: \"colbert\",\n\t\ limit: 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\n// Score boost depending on payload conditions (as of 1.14.0)\n\ + await client.QueryAsync(\n\tcollectionName: \"{collection_name}\",\n\t\ + prefetch:\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\t\ + Expression = 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;\nuse qdrant_client::qdrant::{Condition,\ - \ Filter, PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder};\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(Query::new_nearest(PointId::new(\"\ - 43cf51e2-8777-4f52-bc74-c2cbde0c8b04\")))\n).await?;\n\n// Recommend on\ + - code: "use qdrant_client::qdrant::{\n Condition, DecayParamsExpressionBuilder,\ + \ Expression, FormulaBuilder, Fusion, GeoPoint,\n PointId, PrefetchQueryBuilder,\ + \ Query, QueryPointsBuilder, RecommendInputBuilder,\n Sample,\n};\n\ + use 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(Query::new_nearest([(1, 0.22), (42, 0.8)].as_slice()))\n\ - \ .using(\"sparse\")\n .limit(20u64)\n )\n\ - \ .add_prefetch(PrefetchQueryBuilder::default()\n .query(Query::new_nearest(vec![0.01,\ - \ 0.45, 0.67]))\n .using(\"dense\")\n .limit(20u64)\n\ - \ )\n .query(Query::new_fusion(Fusion::Rrf))\n).await?;\n\ - \n// 2-stage query\nlet _refined = client.query(\n QueryPointsBuilder::new(\"\ + \ .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(Query::new_nearest(vec![0.01, 0.45, 0.67]))\n \ - \ .limit(100u64)\n )\n .query(Query::new_nearest(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" + \ .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)\n\ + let _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" language: rust - code-samples: - - code: "# Query nearest by ID\ncurl -X POST \\\n 'http://localhost:6333/collections/collection_name/points/query'\ + - 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\ + \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\"\ @@ -1954,7 +1998,7 @@ paths: \ 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# 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\ @@ -1963,18 +2007,41 @@ paths: \ },\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'\ + \ 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 \"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" + : \"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" language: curl - code-samples: - code: "from qdrant_client import QdrantClient, models\n\nclient = QdrantClient(url=\"\ @@ -1998,8 +2065,30 @@ paths: \ 0.1, ...], # < \u251C\u2500 multi-vector\n [0.8, 0.9, ...],\ \ # < \u2518\n ],\n using=\"colbert\",\n limit=10,\n)\n\n# Random\ \ sampling (as of 1.11.0)\nsampled = client.query_points(\n collection_name=\"\ - {collection_name}\",\n query=models.SampleQuery(sample=models.Sample.Random)\n\ - )\n" + {collection_name}\",\n query=models.SampleQuery(sample=models.Sample.RANDOM)\n\ + )\n\n# Score boost depending on payload conditions (as of 1.14.0)\ntag_boosted\ + \ = client.query_points(\n collection_name=\"{collection_name}\",\n\ + \ prefetch=models.Prefetch(\n query=[0.2, 0.8, ...], # <--\ + \ dense vector\n limit=50\n ),\n query=models.FormulaQuery(\n\ + \ formula=models.SumExpression(sum=[\n \"$score\",\n\ + \ models.MultExpression(mult=[0.5, models.FieldCondition(key=\"\ + tag\", match=models.MatchAny(any=[\"h1\", \"h2\", \"h3\", \"h4\"]))]),\n\ + \ models.MultExpression(mult=[0.25, models.FieldCondition(key=\"\ + tag\", match=models.MatchAny(any=[\"p\", \"li\"]))])\n ]\n ))\n\ + )\n\n# Score boost geographically closer points (as of 1.14.0)\ngeo_boosted\ + \ = client.query_points(\n collection_name=\"{collection_name}\",\n\ + \ prefetch=models.Prefetch(\n query=[0.2, 0.8, ...], # <--\ + \ dense vector\n limit=50\n ),\n query=models.FormulaQuery(\n\ + \ formula=models.SumExpression(sum=[\n \"$score\",\n\ + \ models.GaussDecayExpression(\n gauss_decay=models.DecayParamsExpression(\n\ + \ x=models.GeoDistance(\n geo_distance=models.GeoDistanceParams(\n\ + \ origin=models.GeoPoint(\n \ + \ lat=52.504043,\n lon=13.393236\n\ + \ ), # Berlin\n \ + \ to=\"geo.location\"\n )\n \ + \ ),\n scale=5000 # 5km\n )\n \ + \ )\n ]),\n defaults={\"geo.location\": models.GeoPoint(lat=48.137154,\ + \ lon=11.576124)} # Munich\n )\n)\n" language: python - code-samples: - code: "import static io.qdrant.client.QueryFactory.fusion;\nimport static\ @@ -2042,7 +2131,62 @@ paths: \ .build())\n .get();\n\n// Random sampling (as of 1.11.0)\n\ client\n .queryAsync(\n QueryPoints.newBuilder()\n \ \ .setCollectionName(\"{collection_name}\")\n .setQuery(sample(Sample.Random))\n\ - \ .build())\n .get();\n" + \ .build())\n .get();\n\n// Score boost depending on payload\ + \ conditions (as of 1.14.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n\ + \ .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n\ + \ PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f,\ + \ 0.45f, 0.67f))\n .setLimit(100)\n \ + \ .build())\n .setQuery(\n formula(\n \ + \ Formula.newBuilder()\n .setExpression(\n\ + \ sum(\n SumExpression.newBuilder()\n\ + \ .addSum(variable(\"$score\"))\n \ + \ .addSum(\n \ + \ mult(\n MultExpression.newBuilder()\n\ + \ .addMult(constant(0.5f))\n\ + \ .addMult(\n \ + \ condition(\n \ + \ matchKeywords(\n \ + \ \"tag\",\n \ + \ List.of(\"h1\",\ + \ \"h2\", \"h3\", \"h4\"))))\n \ + \ .build()))\n .addSum(mult(MultExpression.newBuilder()\n\ + \ .addMult(constant(0.25f))\n \ + \ .addMult(\n \ + \ condition(\n \ + \ matchKeywords(\n \"\ + tag\",\n List.of(\"p\"\ + , \"li\"))))\n .build()))\n \ + \ .build()))\n .build()))\n\ + \ .build())\n .get();\n\n// Score boost geographically closer\ + \ points (as of 1.14.0)\nclient\n .queryAsync(\n QueryPoints.newBuilder()\n\ + \ .setCollectionName(\"{collection_name}\")\n .addPrefetch(\n\ + \ PrefetchQuery.newBuilder()\n .setQuery(nearest(0.01f,\ + \ 0.45f, 0.67f))\n .setLimit(100)\n \ + \ .build())\n .setQuery(\n formula(\n \ + \ Formula.newBuilder()\n .setExpression(\n\ + \ sum(\n SumExpression.newBuilder()\n\ + \ .addSum(variable(\"$score\"))\n \ + \ .addSum(\n \ + \ expDecay(\n \ + \ DecayParamsExpression.newBuilder()\n \ + \ .setX(\n \ + \ geoDistance(\n \ + \ GeoDistance.newBuilder()\n \ + \ .setOrigin(\n \ + \ GeoPoint.newBuilder()\n \ + \ .setLat(52.504043)\n\ + \ .setLon(13.393236)\n\ + \ .build())\n\ + \ .setTo(\"\ + geo.location\")\n \ + \ .build()))\n .setScale(5000)\n\ + \ .build()))\n \ + \ .build()))\n .putDefaults(\n\ + \ \"geo.location\",\n \ + \ value(\n Map.of(\n \ + \ \"lat\", value(48.137154),\n \ + \ \"lon\", value(11.576124))))\n \ + \ .build()))\n .build())\n .get();\n" language: java - code-samples: - code: "package client\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/qdrant/go-client/qdrant\"\ @@ -2078,7 +2222,34 @@ paths: points, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\ \t\tCollectionName: \"{collection_name}\",\n\t\tQuery: qdrant.NewQuerySample(qdrant.Sample_Random),\n\ \t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"Query results:\ - \ \", points)\n}\n" + \ \", points)\n\n\t// Score boost depending on payload conditions (as\ + \ of 1.14.0)\n\tpoints, err = client.Query(context.Background(), &qdrant.QueryPoints{\n\ + \t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\ + \t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.01, 0.45, 0.67),\n\t\t\t},\n\ + \t\t},\n\t\tQuery: qdrant.NewQueryFormula(&qdrant.Formula{\n\t\t\tExpression:\ + \ qdrant.NewExpressionSum(&qdrant.SumExpression{\n\t\t\t\tSum: []*qdrant.Expression{\n\ + \t\t\t\t\tqdrant.NewExpressionVariable(\"$score\"),\n\t\t\t\t\tqdrant.NewExpressionMult(&qdrant.MultExpression{\n\ + \t\t\t\t\t\tMult: []*qdrant.Expression{\n\t\t\t\t\t\t\tqdrant.NewExpressionConstant(0.5),\n\ + \t\t\t\t\t\t\tqdrant.NewExpressionCondition(qdrant.NewMatchKeywords(\"\ + tag\", \"h1\", \"h2\", \"h3\", \"h4\")),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\ + \t\t\t\t\tqdrant.NewExpressionMult(&qdrant.MultExpression{\n\t\t\t\t\t\ + \tMult: []*qdrant.Expression{\n\t\t\t\t\t\t\tqdrant.NewExpressionConstant(0.25),\n\ + \t\t\t\t\t\t\tqdrant.NewExpressionCondition(qdrant.NewMatchKeywords(\"\ + tag\", \"p\", \"li\")),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\ + \t\t}),\n\t\t}),\n\t})\n\n\t// Score boost geographically closer points\ + \ (as of 1.14.0)\n\tclient.Query(context.Background(), &qdrant.QueryPoints{\n\ + \t\tCollectionName: \"{collection_name}\",\n\t\tPrefetch: []*qdrant.PrefetchQuery{\n\ + \t\t\t{\n\t\t\t\tQuery: qdrant.NewQuery(0.2, 0.8),\n\t\t\t},\n\t\t},\n\ + \t\tQuery: qdrant.NewQueryFormula(&qdrant.Formula{\n\t\t\tExpression:\ + \ qdrant.NewExpressionSum(&qdrant.SumExpression{\n\t\t\t\tSum: []*qdrant.Expression{\n\ + \t\t\t\t\tqdrant.NewExpressionVariable(\"$score\"),\n\t\t\t\t\tqdrant.NewExpressionExpDecay(&qdrant.DecayParamsExpression{\n\ + \t\t\t\t\t\tX: qdrant.NewExpressionGeoDistance(&qdrant.GeoDistance{\n\t\ + \t\t\t\t\t\tOrigin: &qdrant.GeoPoint{\n\t\t\t\t\t\t\t\tLat: 52.504043,\n\ + \t\t\t\t\t\t\t\tLon: 13.393236,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tTo: \"\ + geo.location\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t}),\n\ + \t\t\tDefaults: qdrant.NewValueMap(map[string]any{\n\t\t\t\t\"geo.location\"\ + : map[string]any{\n\t\t\t\t\t\"lat\": 48.137154,\n\t\t\t\t\t\"lon\": 11.576124,\n\ + \t\t\t\t},\n\t\t\t}),\n\t\t}),\n\t})\n}\n" language: go - code-samples: - code: "import { QdrantClient } from \"@qdrant/js-client-rest\";\n\nconst\ @@ -2101,7 +2272,23 @@ paths: \ [0.1, 0.2],\n [0.2, 0.1],\n [0.8, 0.9],\n ],\n \ \ using: 'colbert',\n limit: 10,\n});\n\n// Random sampling (as of\ \ 1.11.0)\nlet _sampled = client.query(\"{collection_name}\", {\n query:\ - \ { sample: \"random\" },\n});\n" + \ { sample: \"random\" },\n});\n\n// Score boost depending on payload\ + \ conditions (as of 1.14.0)\nconst tag_boosted = await client.query(\"\ + {collection_name}\", {\n prefetch: {\n query: [0.2, 0.8, 0.1, 0.9],\n\ + \ limit: 50\n },\n query: {\n formula: {\n sum: [\n \ + \ \"$score\",\n {\n mult: [ 0.5, { key: \"tag\", match:\ + \ { any: [\"h1\", \"h2\", \"h3\", \"h4\"] }} ]\n },\n {\n\ + \ mult: [ 0.25, { key: \"tag\", match: { any: [\"p\", \"li\"\ + ] }} ]\n }\n ]\n }\n }\n});\n\n// Score boost geographically\ + \ closer points (as of 1.14.0)\nconst distance_boosted = await client.query(\"\ + {collection_name}\", {\n prefetch: {\n query: [0.2, 0.8, ...],\n \ + \ limit: 50\n },\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" language: typescript /collections/{collection_name}/points/query/batch: post: diff --git a/snippets/csharp/query_points.cs b/snippets/csharp/query_points.cs index 528e896..951516d 100644 --- a/snippets/csharp/query_points.cs +++ b/snippets/csharp/query_points.cs @@ -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 + { + ["lat"] = 48.137154, + ["lon"] = 11.576124, + }, + }, + } +); diff --git a/snippets/curl/query_points.sh b/snippets/curl/query_points.sh index 5ebb0b4..187d220 100644 --- a/snippets/curl/query_points.sh +++ b/snippets/curl/query_points.sh @@ -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: ' \ --header 'Content-Type: application/json' \ @@ -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: ' \ --header 'Content-Type: application/json' \ @@ -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: ' \ --header 'Content-Type: application/json' \ @@ -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: ' \ --header 'Content-Type: application/json' \ @@ -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: ' \ --header 'Content-Type: application/json' \ @@ -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: ' \ + --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: ' \ + --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 + } +}' diff --git a/snippets/go/query_points.go b/snippets/go/query_points.go index 9b0d743..748403c 100644 --- a/snippets/go/query_points.go +++ b/snippets/go/query_points.go @@ -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, + }, + }), + }), + }) } diff --git a/snippets/java/query_points.java b/snippets/java/query_points.java index 953ea5e..f740c20 100644 --- a/snippets/java/query_points.java +++ b/snippets/java/query_points.java @@ -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(); diff --git a/snippets/python/query_points.py b/snippets/python/query_points.py index 80f6f1f..9b8f395 100644 --- a/snippets/python/query_points.py +++ b/snippets/python/query_points.py @@ -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 + ) ) diff --git a/snippets/rust/query_points.rs b/snippets/rust/query_points.rs index 2ef7392..e52cf1d 100644 --- a/snippets/rust/query_points.rs +++ b/snippets/rust/query_points.rs @@ -1,12 +1,16 @@ +use qdrant_client::qdrant::{ + Condition, DecayParamsExpressionBuilder, Expression, FormulaBuilder, Fusion, GeoPoint, + PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder, RecommendInputBuilder, + Sample, +}; use qdrant_client::Qdrant; -use qdrant_client::qdrant::{Condition, Filter, PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder}; let client = Qdrant::from_url("http://localhost:6334").build()?; // Query nearest by ID let _nearest = client.query( QueryPointsBuilder::new("{collection_name}") - .query(Query::new_nearest(PointId::new("43cf51e2-8777-4f52-bc74-c2cbde0c8b04"))) + .query(PointId::from("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")) ).await?; // Recommend on the average of these vectors @@ -23,30 +27,30 @@ let _recommendations = client.query( let _hybrid = client.query( QueryPointsBuilder::new("{collection_name}") .add_prefetch(PrefetchQueryBuilder::default() - .query(Query::new_nearest([(1, 0.22), (42, 0.8)].as_slice())) + .query(vec![(1, 0.22), (42, 0.8)]) .using("sparse") .limit(20u64) ) .add_prefetch(PrefetchQueryBuilder::default() - .query(Query::new_nearest(vec![0.01, 0.45, 0.67])) + .query(vec![0.01, 0.45, 0.67]) .using("dense") .limit(20u64) ) - .query(Query::new_fusion(Fusion::Rrf)) + .query(Fusion::Rrf) ).await?; // 2-stage query let _refined = client.query( QueryPointsBuilder::new("{collection_name}") .add_prefetch(PrefetchQueryBuilder::default() - .query(Query::new_nearest(vec![0.01, 0.45, 0.67])) + .query(vec![0.01, 0.45, 0.67]) .limit(100u64) ) - .query(Query::new_nearest(vec![ + .query(vec![ vec![0.1, 0.2], vec![0.2, 0.1], vec![0.8, 0.9], - ])) + ]) .using("colbert") .limit(10u64) ).await?; @@ -58,3 +62,51 @@ let _sampled = client .query(Query::new_sample(Sample::Random)) ) .await?; + +// Score boost depending on payload conditions (as of 1.14.0) +let _tag_boosted = client.query( + QueryPointsBuilder::new("{collection_name}") + .add_prefetch(PrefetchQueryBuilder::default() + .query(vec![0.01, 0.45, 0.67]) + .limit(100u64) + ) + .query(FormulaBuilder::new(Expression::sum_with([ + Expression::variable("$score"), + Expression::mult_with([ + Expression::constant(0.5), + Expression::condition(Condition::matches("tag", ["h1", "h2", "h3", "h4"])), + ]), + Expression::mult_with([ + Expression::constant(0.25), + Expression::condition(Condition::matches("tag", ["p", "li"])), + ]), + ]))) + .limit(10) + ).await?; + +// Score boost geographically closer points (as of 1.14.0) +let _geo_boosted = client.query( + QueryPointsBuilder::new("{collection_name}") + .add_prefetch( + PrefetchQueryBuilder::default() + .query(vec![0.01, 0.45, 0.67]) + .limit(100u64), + ) + .query( + FormulaBuilder::new(Expression::sum_with([ + Expression::variable("$score"), + Expression::exp_decay( + DecayParamsExpressionBuilder::new(Expression::geo_distance_with( + // Berlin + GeoPoint { lat: 52.504043, lon: 13.393236 }, + "geo.location", + )) + .scale(5_000.0), + ), + ])) + // Munich + .add_default("geo.location", GeoPoint { lat: 48.137154, lon: 11.576124 }), + ) + .limit(10), + ) + .await?; diff --git a/snippets/typescript/query_points.ts b/snippets/typescript/query_points.ts index cd30250..96de8a8 100644 --- a/snippets/typescript/query_points.ts +++ b/snippets/typescript/query_points.ts @@ -58,3 +58,51 @@ let _refined = client.query("{collection_name}", { let _sampled = client.query("{collection_name}", { query: { sample: "random" }, }); + +// Score boost depending on payload conditions (as of 1.14.0) +const tag_boosted = await client.query("{collection_name}", { + prefetch: { + query: [0.2, 0.8, 0.1, 0.9], + 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) +const distance_boosted = await client.query("{collection_name}", { + 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 + } +});