mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 04:48:30 +02:00
Migrate some code snippets
create-collection/simple query-points/with-acorn
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
|||||||
|
curl -X PUT http://localhost:6333/collections/{collection_name} \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
--data-raw '{
|
||||||
|
"vectors": {
|
||||||
|
"size": 100,
|
||||||
|
"distance": "Cosine"
|
||||||
|
}
|
||||||
|
}'
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
using Qdrant.Client;
|
||||||
|
using Qdrant.Client.Grpc;
|
||||||
|
|
||||||
|
public class Snippet
|
||||||
|
{
|
||||||
|
public static async Task Run()
|
||||||
|
{
|
||||||
|
var client = new QdrantClient("localhost", 6334);
|
||||||
|
|
||||||
|
await client.CreateCollectionAsync(
|
||||||
|
collectionName: "{collection_name}",
|
||||||
|
vectorsConfig: new VectorParams { Size = 100, Distance = Distance.Cosine }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -3,8 +3,8 @@ curl -X PUT http://localhost:6333/collections/{collection_name} \
|
|||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"vectors": {
|
"vectors": {
|
||||||
"size": 300,
|
"size": 100,
|
||||||
"distance": "Cosine"
|
"distance": "Cosine"
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
+1
-1
@@ -7,4 +7,4 @@ client.create_collection(
|
|||||||
collection_name="{collection_name}",
|
collection_name="{collection_name}",
|
||||||
vectors_config=models.VectorParams(size=100, distance=models.Distance.COSINE),
|
vectors_config=models.VectorParams(size=100, distance=models.Distance.COSINE),
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
```rust
|
```rust
|
||||||
use qdrant_client::Qdrant;
|
use qdrant_client::Qdrant;
|
||||||
use qdrant_client::qdrant::{CreateCollectionBuilder, VectorParamsBuilder};
|
use qdrant_client::qdrant::{CreateCollectionBuilder, VectorParamsBuilder, Distance};
|
||||||
|
|
||||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package snippet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/qdrant/go-client/qdrant"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Main() {
|
||||||
|
client, err := qdrant.NewClient(&qdrant.Config{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 6334,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil { panic(err) } // @hide
|
||||||
|
|
||||||
|
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||||
|
CollectionName: "{collection_name}",
|
||||||
|
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||||
|
Size: 100,
|
||||||
|
Distance: qdrant.Distance_Cosine,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.example.snippets_amalgamation;
|
||||||
|
|
||||||
|
import io.qdrant.client.grpc.Collections.Distance;
|
||||||
|
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||||
|
import io.qdrant.client.QdrantClient;
|
||||||
|
import io.qdrant.client.QdrantGrpcClient;
|
||||||
|
|
||||||
|
public class Snippet {
|
||||||
|
public static void run() throws Exception {
|
||||||
|
QdrantClient client = new QdrantClient(
|
||||||
|
QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
||||||
|
|
||||||
|
client.createCollectionAsync("{collection_name}",
|
||||||
|
VectorParams.newBuilder().setDistance(Distance.Cosine).setSize(100).build()).get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
from qdrant_client import QdrantClient, models
|
||||||
|
|
||||||
|
client = QdrantClient(url="http://localhost:6333")
|
||||||
|
|
||||||
|
client.create_collection(
|
||||||
|
collection_name="{collection_name}",
|
||||||
|
vectors_config=models.VectorParams(size=100, distance=models.Distance.COSINE),
|
||||||
|
)
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
use qdrant_client::Qdrant;
|
||||||
|
use qdrant_client::qdrant::{CreateCollectionBuilder, VectorParamsBuilder, Distance};
|
||||||
|
|
||||||
|
pub async fn main() -> anyhow::Result<()> {
|
||||||
|
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||||
|
|
||||||
|
client
|
||||||
|
.create_collection(
|
||||||
|
CreateCollectionBuilder::new("{collection_name}")
|
||||||
|
.vectors_config(VectorParamsBuilder::new(100, Distance::Cosine)),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def prepare() -> None:
|
||||||
|
cleanup()
|
||||||
|
|
||||||
|
|
||||||
|
def check() -> None:
|
||||||
|
response = requests.get("http://127.0.0.1:6333/collections/collection_name")
|
||||||
|
response.raise_for_status()
|
||||||
|
result = response.json()
|
||||||
|
assert result["result"]["config"]["params"]["vectors"]["size"] == 100
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup() -> None:
|
||||||
|
requests.delete("http://127.0.0.1:6333/collections/collection_name")
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||||
|
|
||||||
|
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||||
|
|
||||||
|
client.createCollection("{collection_name}", {
|
||||||
|
vectors: { size: 100, distance: "Cosine" },
|
||||||
|
});
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
using Qdrant.Client;
|
||||||
|
using Qdrant.Client.Grpc;
|
||||||
|
|
||||||
|
public class Snippet
|
||||||
|
{
|
||||||
|
public static async Task Run()
|
||||||
|
{
|
||||||
|
var client = new QdrantClient("localhost", 6334);
|
||||||
|
|
||||||
|
await client.QueryAsync(
|
||||||
|
collectionName: "{collection_name}",
|
||||||
|
query: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||||
|
searchParams: new SearchParams
|
||||||
|
{
|
||||||
|
Acorn = new AcornSearchParams
|
||||||
|
{
|
||||||
|
Enable = true,
|
||||||
|
MaxSelectivity = 0.4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limit: 10
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -17,4 +17,4 @@ await client.QueryAsync(
|
|||||||
},
|
},
|
||||||
limit: 10
|
limit: 10
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
+1
-1
@@ -20,4 +20,4 @@ client.Query(context.Background(), &qdrant.QueryPoints{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
+1
-1
@@ -25,4 +25,4 @@ client.queryAsync(
|
|||||||
.setLimit(10)
|
.setLimit(10)
|
||||||
.build())
|
.build())
|
||||||
.get();
|
.get();
|
||||||
```
|
```
|
||||||
+1
-1
@@ -14,4 +14,4 @@ client.query_points(
|
|||||||
),
|
),
|
||||||
limit=10,
|
limit=10,
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
+1
-1
@@ -13,4 +13,4 @@ client.query("{collection_name}", {
|
|||||||
},
|
},
|
||||||
limit: 10,
|
limit: 10,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package snippet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/qdrant/go-client/qdrant"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Main() {
|
||||||
|
client, err := qdrant.NewClient(&qdrant.Config{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 6334,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil { panic(err) } // @hide
|
||||||
|
|
||||||
|
client.Query(context.Background(), &qdrant.QueryPoints{
|
||||||
|
CollectionName: "{collection_name}",
|
||||||
|
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
|
||||||
|
Params: &qdrant.SearchParams{
|
||||||
|
Acorn: &qdrant.AcornSearchParams{
|
||||||
|
Enable: qdrant.PtrOf(true),
|
||||||
|
MaxSelectivity: qdrant.PtrOf(0.4),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.example.snippets_amalgamation;
|
||||||
|
|
||||||
|
import io.qdrant.client.QdrantClient;
|
||||||
|
import io.qdrant.client.QdrantGrpcClient;
|
||||||
|
import io.qdrant.client.grpc.Points.AcornSearchParams;
|
||||||
|
import io.qdrant.client.grpc.Points.QueryPoints;
|
||||||
|
import io.qdrant.client.grpc.Points.SearchParams;
|
||||||
|
|
||||||
|
import static io.qdrant.client.QueryFactory.nearest;
|
||||||
|
|
||||||
|
public class Snippet {
|
||||||
|
public static void run() throws Exception {
|
||||||
|
QdrantClient client =
|
||||||
|
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
||||||
|
|
||||||
|
client.queryAsync(
|
||||||
|
QueryPoints.newBuilder()
|
||||||
|
.setCollectionName("{collection_name}")
|
||||||
|
.setQuery(nearest(0.2f, 0.1f, 0.9f, 0.7f))
|
||||||
|
.setParams(
|
||||||
|
SearchParams.newBuilder()
|
||||||
|
.setAcorn(
|
||||||
|
AcornSearchParams.newBuilder()
|
||||||
|
.setEnable(true)
|
||||||
|
.setMaxSelectivity(0.4)
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.setLimit(10)
|
||||||
|
.build())
|
||||||
|
.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
from qdrant_client import QdrantClient, models
|
||||||
|
|
||||||
|
client = QdrantClient(url="http://localhost:6333")
|
||||||
|
|
||||||
|
client.query_points(
|
||||||
|
collection_name="{collection_name}",
|
||||||
|
query=[0.2, 0.1, 0.9, 0.7],
|
||||||
|
search_params=models.SearchParams(
|
||||||
|
acorn=models.AcornSearchParams(
|
||||||
|
enable=True,
|
||||||
|
max_selectivity=0.4,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
limit=10,
|
||||||
|
)
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
use qdrant_client::qdrant::{
|
||||||
|
AcornSearchParamsBuilder, QueryPointsBuilder, SearchParamsBuilder,
|
||||||
|
};
|
||||||
|
use qdrant_client::Qdrant;
|
||||||
|
|
||||||
|
pub async fn main() -> anyhow::Result<()> {
|
||||||
|
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||||
|
|
||||||
|
client
|
||||||
|
.query(
|
||||||
|
QueryPointsBuilder::new("{collection_name}")
|
||||||
|
.query(vec![0.2, 0.1, 0.9, 0.7])
|
||||||
|
.limit(10)
|
||||||
|
.params(
|
||||||
|
SearchParamsBuilder::default().acorn(
|
||||||
|
AcornSearchParamsBuilder::new(true)
|
||||||
|
.max_selectivity(0.4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||||
|
|
||||||
|
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||||
|
|
||||||
|
client.query("{collection_name}", {
|
||||||
|
query: [0.2, 0.1, 0.9, 0.7],
|
||||||
|
params: {
|
||||||
|
acorn: {
|
||||||
|
enable: true,
|
||||||
|
max_selectivity: 0.4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
limit: 10,
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user