mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-28 15:38:33 +02:00
docs: Query API snippets with TS (#1093)
This commit is contained in:
@@ -71,21 +71,25 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.recommend("{collection_name}", {
|
||||
positive: [100, 231],
|
||||
negative: [718, [0.2, 0.3, 0.4, 0.5]],
|
||||
strategy: "average_vector",
|
||||
filter: {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
limit: 3,
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [100, 231],
|
||||
negative: [718, [0.2, 0.3, 0.4, 0.5]],
|
||||
strategy: "average_vector"
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
limit: 3
|
||||
});
|
||||
```
|
||||
|
||||
@@ -263,11 +267,15 @@ client.query_points(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.recommend("{collection_name}", {
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
using: "image",
|
||||
limit: 10,
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
}
|
||||
},
|
||||
using: "image",
|
||||
limit: 10
|
||||
});
|
||||
```
|
||||
|
||||
@@ -375,15 +383,19 @@ client.query_points(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.recommend("{collection_name}", {
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
using: "image",
|
||||
limit: 10,
|
||||
lookup_from: {
|
||||
"collection" : "{external_collection_name}",
|
||||
"vector" : "{external_vector_name}"
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
}
|
||||
},
|
||||
using: "image",
|
||||
limit: 10,
|
||||
lookup_from: {
|
||||
collection: "{external_collection_name}",
|
||||
vector: "{external_vector_name}"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
@@ -558,33 +570,41 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
const filter = {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const searches = [
|
||||
{
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
positive: [200, 67],
|
||||
negative: [300],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [100, 231],
|
||||
negative: [718]
|
||||
}
|
||||
},
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [200, 67],
|
||||
negative: [300]
|
||||
}
|
||||
},
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
];
|
||||
|
||||
client.recommend_batch("{collection_name}", {
|
||||
searches,
|
||||
client.queryBatch("{collection_name}", {
|
||||
searches,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -825,18 +845,22 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.discover("{collection_name}", {
|
||||
target: [0.2, 0.1, 0.9, 0.7],
|
||||
context: [
|
||||
{
|
||||
positive: 100,
|
||||
negative: 718,
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
discover: {
|
||||
target: [0.2, 0.1, 0.9, 0.7],
|
||||
context: [
|
||||
{
|
||||
positive: 100,
|
||||
negative: 718,
|
||||
},
|
||||
{
|
||||
positive: 200,
|
||||
negative: 300,
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
positive: 200,
|
||||
negative: 300,
|
||||
},
|
||||
],
|
||||
limit: 10,
|
||||
});
|
||||
```
|
||||
@@ -998,17 +1022,19 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.discover("{collection_name}", {
|
||||
context: [
|
||||
{
|
||||
positive: 100,
|
||||
negative: 718,
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
context: [
|
||||
{
|
||||
positive: 100,
|
||||
negative: 718,
|
||||
},
|
||||
{
|
||||
positive: 200,
|
||||
negative: 300,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
positive: 200,
|
||||
negative: 300,
|
||||
},
|
||||
],
|
||||
limit: 10,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -254,23 +254,23 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
filter: {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -396,11 +396,9 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: {
|
||||
name: "image",
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
},
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
using: "image",
|
||||
limit: 3,
|
||||
});
|
||||
```
|
||||
@@ -505,15 +503,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: {
|
||||
name: "text",
|
||||
vector: {
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
indices: [1, 7],
|
||||
values: [2.0, 1.0]
|
||||
},
|
||||
},
|
||||
limit: 3,
|
||||
using: "text",
|
||||
limit: 3,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -604,8 +600,8 @@ client.query_points(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
with_vector: true,
|
||||
with_payload: true,
|
||||
});
|
||||
@@ -695,8 +691,8 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
with_payload: ["city", "village", "town"],
|
||||
});
|
||||
```
|
||||
@@ -797,8 +793,8 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
with_payload: {
|
||||
exclude: ["city"],
|
||||
},
|
||||
@@ -950,31 +946,31 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
const filter = {
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
must: [
|
||||
{
|
||||
key: "city",
|
||||
match: {
|
||||
value: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const searches = [
|
||||
{
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
vector: [0.5, 0.3, 0.2, 0.3],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
{
|
||||
query: [0.5, 0.3, 0.2, 0.3],
|
||||
filter,
|
||||
limit: 3,
|
||||
},
|
||||
];
|
||||
|
||||
client.searchBatch("{collection_name}", {
|
||||
searches,
|
||||
client.queryBatch("{collection_name}", {
|
||||
searches,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1125,8 +1121,8 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
with_vector: true,
|
||||
with_payload: true,
|
||||
limit: 10,
|
||||
@@ -1298,11 +1294,11 @@ client.query_points_groups(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.searchPointGroups("{collection_name}", {
|
||||
vector: [1.1],
|
||||
group_by: "document_id",
|
||||
limit: 4,
|
||||
group_size: 2,
|
||||
client.queryGroups("{collection_name}", {
|
||||
query: [1.1],
|
||||
group_by: "document_id",
|
||||
limit: 4,
|
||||
group_size: 2,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1468,16 +1464,16 @@ client.query_points_groups(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.searchPointGroups("{collection_name}", {
|
||||
vector: [1.1],
|
||||
group_by: "document_id",
|
||||
limit: 2,
|
||||
group_size: 2,
|
||||
with_lookup: {
|
||||
collection: "documents",
|
||||
with_payload: ["title", "text"],
|
||||
with_vectors: false,
|
||||
},
|
||||
client.queryGroups("{collection_name}", {
|
||||
query: [1.1],
|
||||
group_by: "document_id",
|
||||
limit: 2,
|
||||
group_size: 2,
|
||||
with_lookup: {
|
||||
collection: "documents",
|
||||
with_payload: ["title", "text"],
|
||||
with_vectors: false,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -356,15 +356,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: {
|
||||
name: "text",
|
||||
vector: {
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
indices: [1, 3, 5, 7],
|
||||
values: [0.1, 0.2, 0.3, 0.4]
|
||||
},
|
||||
},
|
||||
limit: 3,
|
||||
using: "text",
|
||||
limit: 3,
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -1093,17 +1093,17 @@ client.query_points(
|
||||
```
|
||||
|
||||
```typescript
|
||||
client.search("{collection_name}", {
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
consistency: "majority",
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
consistency: "majority",
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -223,12 +223,12 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
filter: {
|
||||
must: [{ key: "group_id", match: { value: "user_1" } }],
|
||||
},
|
||||
vector: [0.1, 0.1, 0.9],
|
||||
limit: 10,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.1, 0.1, 0.9],
|
||||
filter: {
|
||||
must: [{ key: "group_id", match: { value: "user_1" } }],
|
||||
},
|
||||
limit: 10,
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -190,13 +190,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
rescore: false,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
rescore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -558,13 +558,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -607,16 +607,16 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
ignore: false,
|
||||
rescore: true,
|
||||
oversampling: 2.0,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
ignore: false,
|
||||
rescore: true,
|
||||
oversampling: 2.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
limit: 10,
|
||||
limit: 10,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -753,13 +753,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
ignore: true,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
ignore: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1015,13 +1015,13 @@ import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.search("{collection_name}", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
rescore: false,
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
params: {
|
||||
quantization: {
|
||||
rescore: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -308,12 +308,13 @@ print(search_result)
|
||||
```
|
||||
|
||||
```typescript
|
||||
let searchResult = await client.search("test_collection", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
let searchResult = await client.query(
|
||||
"test_collection", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3
|
||||
});
|
||||
|
||||
console.debug(searchResult);
|
||||
console.debug(searchResult.points);
|
||||
```
|
||||
|
||||
```rust
|
||||
@@ -413,13 +414,13 @@ print(search_result)
|
||||
```
|
||||
|
||||
```typescript
|
||||
searchResult = await client.search("test_collection", {
|
||||
vector: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
with_payload: true,
|
||||
limit: 3,
|
||||
searchResult = await client.query("test_collection", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
with_payload: true,
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
console.debug(searchResult);
|
||||
|
||||
Reference in New Issue
Block a user