Add code snippets for the text search guide (#2056)

* Python snippets

* TS snippets

* Rust snippets

* Java snippets

* C# snippets

* Go snippets

* Generate .md files

* Hide client connection in Rust snippets

* Switch to builder pattern for Rust snippets

* Use Document::new instead of DocumentBuilder::new

* docs: Updated Go snippets

Signed-off-by: Anush008 <mail@anush.sh>

* docs: Updated Java snippets

Signed-off-by: Anush008 <anushshetty90@gmail.com>

* docs: Updated C# snippets

Signed-off-by: Anush008 <anushshetty90@gmail.com>

* docs: Updated BM25 avg_len Java snippet

Signed-off-by: Anush008 <anushshetty90@gmail.com>

* chore: review and format rust snippets

* chore: trigger pr update

* chore: remove qdrant_storage folder

* fix: remove tokio::main

* chore: trigger pr update

* Regenerate .md files

* George's feedback: set bm25 params at ingest-time, change Python client init to use cloud inference explicitly, and mark bm25 options unavailable in FastEmbed

---------

Signed-off-by: Anush008 <mail@anush.sh>
Signed-off-by: Anush008 <anushshetty90@gmail.com>
Co-authored-by: Anush008 <mail@anush.sh>
Co-authored-by: Anush008 <anushshetty90@gmail.com>
Co-authored-by: Daniel Boros <dancixx@gmail.com>
This commit is contained in:
Abdon Pijpelink
2026-01-16 17:57:08 +05:30
committed by GitHub
co-authored by Anush008 Anush008 Daniel Boros
parent b5e0908946
commit 2497c368ed
329 changed files with 7854 additions and 20 deletions
@@ -14,7 +14,7 @@ Qdrant is a vector search engine, making it a great tool for [semantic search](#
Semantic search is a search technique that focuses on the meaning of the text rather than just matching on keywords. This is achieved by converting text into [vectors](/documentation/concepts/vectors/) (embeddings) using machine learning models. These vectors capture the semantic meaning of the text, enabling you to find similar text even if it doesn't share exact keywords.
<aside role="status">
The examples in this guide use <a href="/documentation/concepts/inference">inference</a> to let Qdrant generate the vectors. Inference is only available on <a href="/documentation/concepts/inference/#qdrant-cloud-inference">Qdrant Cloud</a>, with the exception of the BM25 model. If you are not running on Qdrant Cloud, you can use a library like <a href="/documentation/fastembed/">FastEmbed</a> to generate vectors on the client side.
The examples in this guide use <a href="/documentation/concepts/inference">inference</a> to let Qdrant generate the vectors. Inference is only available on <a href="/documentation/concepts/inference/#qdrant-cloud-inference">Qdrant Cloud</a>, with the exception of the BM25 model. If you are not running on Qdrant Cloud, you can use a library like <a href="/documentation/fastembed/">FastEmbed</a> to generate vectors on the client side. When using FastEmbed, refer to the documentation, as its API may differ from that of server-side inference.
</aside>
For example, to search through a collection of books, you could use a model like the `all-MiniLM-L6-v2` sentence transformer model. First, create a collection and configure a dense vector for the book descriptions:
@@ -197,7 +197,7 @@ After ingesting data, you can query the sparse vector. The following example sea
#### Configuring BM25 Parameters
The BM25 [ranking function](https://en.wikipedia.org/wiki/Okapi_BM25#The_ranking_function) includes three adjustable parameters that you can set to optimize search results for your specific use case:
The BM25 [ranking function](https://en.wikipedia.org/wiki/Okapi_BM25#The_ranking_function) includes three adjustable parameters that you can set at ingest time to optimize search results for your specific use case:
- `k`. Controls term frequency saturation. Higher values increase the influence of term frequency. Defaults to 1.2.
- `b`. Controls document length normalization. Ranges from 0 (no normalization) to 1 (full normalization). A higher value means longer documents have less impact. Defaults to 0.75.
@@ -205,7 +205,7 @@ The BM25 [ranking function](https://en.wikipedia.org/wiki/Okapi_BM25#The_ranking
For instance, book titles are generally shorter than 256 words. To achieve more accurate scoring when searching for book titles, you could calculate or estimate the average title length and set the `avg_len` parameter accordingly:
{{< code-snippet path="/documentation/headless/snippets/text-search/query-bm25-avglen/" >}}
{{< code-snippet path="/documentation/headless/snippets/text-search/ingest-bm25-avglen/" >}}
#### Language-specific Settings
@@ -0,0 +1,51 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
var searchStrict = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
Filter = new Filter { Must = { MatchText("title", "time travel") } },
};
var searchRelaxed = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
Filter = new Filter { Must = { MatchTextAny("title", "time travel") } },
};
var searchVectorOnly = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
};
await client.QueryBatchAsync(
collectionName: "books",
queries: new List<QueryPoints> { searchStrict, searchRelaxed, searchVectorOnly }
);
}
}
@@ -0,0 +1,45 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
var searchStrict = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
Filter = new Filter { Must = { MatchText("title", "time travel") } },
};
var searchRelaxed = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
Filter = new Filter { Must = { MatchTextAny("title", "time travel") } },
};
var searchVectorOnly = new QueryPoints
{
CollectionName = "books",
Query = new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
Using = "description-dense",
};
await client.QueryBatchAsync(
collectionName: "books",
queries: new List<QueryPoints> { searchStrict, searchRelaxed, searchVectorOnly }
);
```
@@ -0,0 +1,32 @@
```go
strict := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
Filter: &qdrant.Filter{Must: []*qdrant.Condition{qdrant.NewMatchText("title", "time travel")}},
}
relaxed := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
Filter: &qdrant.Filter{Must: []*qdrant.Condition{qdrant.NewMatchTextAny("title", "time travel")}},
}
vectorOnly := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
}
client.QueryBatch(context.Background(), &qdrant.QueryBatchPoints{
CollectionName: "books",
QueryPoints: []*qdrant.QueryPoints{strict, relaxed, vectorOnly},
})
```
@@ -0,0 +1,56 @@
```java
import static io.qdrant.client.ConditionFactory.*;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.WithPayloadSelectorFactory.enable;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.*;
import java.util.*;
QdrantClient client =
QueryPoints searchStrict =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(Filter.newBuilder().addMust(matchText("title", "time travel")).build())
.setWithPayload(enable(true))
.build();
QueryPoints searchRelaxed =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(Filter.newBuilder().addMust(matchTextAny("title", "time travel")).build())
.setWithPayload(enable(true))
.build();
QueryPoints searchVectorOnly =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setWithPayload(enable(true))
.build();
client.queryBatchAsync("books", List.of(searchStrict, searchRelaxed, searchVectorOnly)).get();
```
@@ -0,0 +1,36 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.query_batch_points(
collection_name="books",
requests=[
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchText(text="time travel"))]
),
),
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchTextAny(text_any="time travel"))]
),
),
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
),
],
)
```
@@ -0,0 +1,42 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
Condition, Document, Filter, Query, QueryBatchPointsBuilder, QueryPointsBuilder,
};
let strict_filter = Filter::must([Condition::matches("title", "time travel".to_string())]);
let relaxed_filter = Filter::must([Condition::matches("title", "time travel".to_string())]);
let searches = vec![
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(strict_filter)
.with_payload(true)
.build(),
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(relaxed_filter)
.with_payload(true)
.build(),
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.with_payload(true)
.build(),
];
client
.query_batch(QueryBatchPointsBuilder::new("books", searches))
.await?;
```
@@ -0,0 +1,27 @@
```typescript
client.queryBatch("books", {
searches: [
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
filter: {
must: [{ key: "title", match: { text: "time travel" } }],
},
},
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
filter: {
must: [{ key: "title", match: { text_any: "time travel" } }],
},
},
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
},
],
});
```
@@ -0,0 +1,54 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
strict := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
Filter: &qdrant.Filter{Must: []*qdrant.Condition{qdrant.NewMatchText("title", "time travel")}},
}
relaxed := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
Filter: &qdrant.Filter{Must: []*qdrant.Condition{qdrant.NewMatchTextAny("title", "time travel")}},
}
vectorOnly := &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{Model: "sentence-transformers/all-minilm-l6-v2", Text: "time travel"}),
),
Using: qdrant.PtrOf("description-dense"),
}
client.QueryBatch(context.Background(), &qdrant.QueryBatchPoints{
CollectionName: "books",
QueryPoints: []*qdrant.QueryPoints{strict, relaxed, vectorOnly},
})
}
@@ -0,0 +1,61 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.ConditionFactory.*;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.WithPayloadSelectorFactory.enable;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.*;
import java.util.*;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
QueryPoints searchStrict =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(Filter.newBuilder().addMust(matchText("title", "time travel")).build())
.setWithPayload(enable(true))
.build();
QueryPoints searchRelaxed =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(Filter.newBuilder().addMust(matchTextAny("title", "time travel")).build())
.setWithPayload(enable(true))
.build();
QueryPoints searchVectorOnly =
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setWithPayload(enable(true))
.build();
client.queryBatchAsync("books", List.of(searchStrict, searchRelaxed, searchVectorOnly)).get();
}
}
@@ -0,0 +1,34 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.query_batch_points(
collection_name="books",
requests=[
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchText(text="time travel"))]
),
),
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchTextAny(text_any="time travel"))]
),
),
models.QueryRequest(
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
),
],
)
@@ -0,0 +1,46 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
Condition, Document, Filter, Query, QueryBatchPointsBuilder, QueryPointsBuilder,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let strict_filter = Filter::must([Condition::matches("title", "time travel".to_string())]);
let relaxed_filter = Filter::must([Condition::matches("title", "time travel".to_string())]);
let searches = vec![
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(strict_filter)
.with_payload(true)
.build(),
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(relaxed_filter)
.with_payload(true)
.build(),
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.with_payload(true)
.build(),
];
client
.query_batch(QueryBatchPointsBuilder::new("books", searches))
.await?;
Ok(())
}
@@ -0,0 +1,29 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.queryBatch("books", {
searches: [
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
filter: {
must: [{ key: "title", match: { text: "time travel" } }],
},
},
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
filter: {
must: [{ key: "title", match: { text_any: "time travel" } }],
},
},
{
query: { text: "time travel", model: "sentence-transformers/all-minilm-l6-v2" },
using: "description-dense",
with_payload: true,
},
],
});
@@ -0,0 +1,16 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "author",
schemaType: PayloadSchemaType.Keyword
);
}
}
@@ -0,0 +1,10 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "author",
schemaType: PayloadSchemaType.Keyword
);
```
@@ -0,0 +1,7 @@
```go
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "author",
FieldType: qdrant.FieldType_FieldTypeKeyword.Enum(),
})
```
@@ -0,0 +1,12 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
QdrantClient client =
client
.createPayloadIndexAsync(
"books", "author", PayloadSchemaType.Keyword, null, null, null, null)
.get();
```
@@ -0,0 +1,15 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="author",
field_schema=models.PayloadSchemaType.KEYWORD
)
```
@@ -0,0 +1,12 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
client
.create_field_index(CreateFieldIndexCollectionBuilder::new(
"books",
"author",
FieldType::Keyword,
))
.await?;
```
@@ -0,0 +1,6 @@
```typescript
client.createPayloadIndex("books", {
field_name: "author",
field_schema: "keyword",
});
```
@@ -0,0 +1,29 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "author",
FieldType: qdrant.FieldType_FieldTypeKeyword.Enum(),
})
}
@@ -0,0 +1,17 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createPayloadIndexAsync(
"books", "author", PayloadSchemaType.Keyword, null, null, null, null)
.get();
}
}
@@ -0,0 +1,13 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="author",
field_schema=models.PayloadSchemaType.KEYWORD
)
@@ -0,0 +1,16 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.create_field_index(CreateFieldIndexCollectionBuilder::new(
"books",
"author",
FieldType::Keyword,
))
.await?;
Ok(())
}
@@ -0,0 +1,8 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createPayloadIndex("books", {
field_name: "author",
field_schema: "keyword",
});
@@ -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); // @hide
await client.CreateCollectionAsync(
collectionName: "books",
sparseVectorsConfig: ("title-bm25", new SparseVectorParams { Modifier = Modifier.Idf })
);
}
}
@@ -0,0 +1,9 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreateCollectionAsync(
collectionName: "books",
sparseVectorsConfig: ("title-bm25", new SparseVectorParams { Modifier = Modifier.Idf })
);
```
@@ -0,0 +1,9 @@
```go
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
SparseVectorsConfig: qdrant.NewSparseVectorsConfig(
map[string]*qdrant.SparseVectorParams{
"title-bm25": {Modifier: qdrant.Modifier_Idf.Enum()},
}),
})
```
@@ -0,0 +1,20 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
QdrantClient client =
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setSparseVectorsConfig(
SparseVectorConfig.newBuilder()
.putMap(
"title-bm25",
SparseVectorParams.newBuilder().setModifier(Modifier.Idf).build())
.build())
.build())
.get();
```
@@ -0,0 +1,16 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
sparse_vectors_config={
"title-bm25": models.SparseVectorParams(modifier=models.Modifier.IDF)
},
)
```
@@ -0,0 +1,16 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Modifier, SparseVectorParamsBuilder, SparseVectorsConfigBuilder,
};
let mut sparse = SparseVectorsConfigBuilder::default();
sparse.add_named_vector_params(
"title-bm25",
SparseVectorParamsBuilder::default().modifier(Modifier::Idf),
);
client
.create_collection(CreateCollectionBuilder::new("books").sparse_vectors_config(sparse))
.await?;
```
@@ -0,0 +1,7 @@
```typescript
client.createCollection("books", {
sparse_vectors: {
"title-bm25": { modifier: "idf" },
},
});
```
@@ -0,0 +1,31 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
SparseVectorsConfig: qdrant.NewSparseVectorsConfig(
map[string]*qdrant.SparseVectorParams{
"title-bm25": {Modifier: qdrant.Modifier_Idf.Enum()},
}),
})
}
@@ -0,0 +1,25 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setSparseVectorsConfig(
SparseVectorConfig.newBuilder()
.putMap(
"title-bm25",
SparseVectorParams.newBuilder().setModifier(Modifier.Idf).build())
.build())
.build())
.get();
}
}
@@ -0,0 +1,14 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
sparse_vectors_config={
"title-bm25": models.SparseVectorParams(modifier=models.Modifier.IDF)
},
)
@@ -0,0 +1,20 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Modifier, SparseVectorParamsBuilder, SparseVectorsConfigBuilder,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let mut sparse = SparseVectorsConfigBuilder::default();
sparse.add_named_vector_params(
"title-bm25",
SparseVectorParamsBuilder::default().modifier(Modifier::Idf),
);
client
.create_collection(CreateCollectionBuilder::new("books").sparse_vectors_config(sparse))
.await?;
Ok(())
}
@@ -0,0 +1,9 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createCollection("books", {
sparse_vectors: {
"title-bm25": { modifier: "idf" },
},
});
@@ -0,0 +1,25 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreateCollectionAsync(
collectionName: "books",
vectorsConfig: new VectorParamsMap
{
Map =
{
["description-dense"] = new VectorParams
{
Size = 384,
Distance = Distance.Cosine,
},
},
}
);
}
}
@@ -0,0 +1,19 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreateCollectionAsync(
collectionName: "books",
vectorsConfig: new VectorParamsMap
{
Map =
{
["description-dense"] = new VectorParams
{
Size = 384,
Distance = Distance.Cosine,
},
},
}
);
```
@@ -0,0 +1,12 @@
```go
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
VectorsConfig: qdrant.NewVectorsConfigMap(
map[string]*qdrant.VectorParams{
"description-dense": {
Size: 384,
Distance: qdrant.Distance_Cosine,
},
}),
})
```
@@ -0,0 +1,26 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
QdrantClient client =
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setVectorsConfig(
VectorsConfig.newBuilder()
.setParamsMap(
VectorParamsMap.newBuilder()
.putMap(
"description-dense",
VectorParams.newBuilder()
.setSize(384)
.setDistance(Distance.Cosine)
.build())
.build())
.build())
.build())
.get();
```
@@ -0,0 +1,16 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
vectors_config={
"description-dense": models.VectorParams(size=384, distance=models.Distance.COSINE)
},
)
```
@@ -0,0 +1,16 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Distance, VectorParamsBuilder, VectorsConfigBuilder,
};
let mut vectors_config = VectorsConfigBuilder::default();
vectors_config.add_named_vector_params(
"description-dense",
VectorParamsBuilder::new(384, Distance::Cosine),
);
client
.create_collection(CreateCollectionBuilder::new("books").vectors_config(vectors_config))
.await?;
```
@@ -0,0 +1,7 @@
```typescript
client.createCollection("books", {
vectors: {
"description-dense": { size: 384, distance: "Cosine" },
},
});
```
@@ -0,0 +1,34 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
VectorsConfig: qdrant.NewVectorsConfigMap(
map[string]*qdrant.VectorParams{
"description-dense": {
Size: 384,
Distance: qdrant.Distance_Cosine,
},
}),
})
}
@@ -0,0 +1,31 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setVectorsConfig(
VectorsConfig.newBuilder()
.setParamsMap(
VectorParamsMap.newBuilder()
.putMap(
"description-dense",
VectorParams.newBuilder()
.setSize(384)
.setDistance(Distance.Cosine)
.build())
.build())
.build())
.build())
.get();
}
}
@@ -0,0 +1,14 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
vectors_config={
"description-dense": models.VectorParams(size=384, distance=models.Distance.COSINE)
},
)
@@ -0,0 +1,20 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Distance, VectorParamsBuilder, VectorsConfigBuilder,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let mut vectors_config = VectorsConfigBuilder::default();
vectors_config.add_named_vector_params(
"description-dense",
VectorParamsBuilder::new(384, Distance::Cosine),
);
client
.create_collection(CreateCollectionBuilder::new("books").vectors_config(vectors_config))
.await?;
Ok(())
}
@@ -0,0 +1,9 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createCollection("books", {
vectors: {
"description-dense": { size: 384, distance: "Cosine" },
},
});
@@ -0,0 +1,29 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreateCollectionAsync(
collectionName: "books",
vectorsConfig: new VectorParamsMap
{
Map =
{
["description-dense"] = new VectorParams
{
Size = 384,
Distance = Distance.Cosine,
},
},
},
sparseVectorsConfig: new SparseVectorConfig
{
Map = { ["isbn-bm25"] = new SparseVectorParams { Modifier = Modifier.Idf } },
}
);
}
}
@@ -0,0 +1,23 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreateCollectionAsync(
collectionName: "books",
vectorsConfig: new VectorParamsMap
{
Map =
{
["description-dense"] = new VectorParams
{
Size = 384,
Distance = Distance.Cosine,
},
},
},
sparseVectorsConfig: new SparseVectorConfig
{
Map = { ["isbn-bm25"] = new SparseVectorParams { Modifier = Modifier.Idf } },
}
);
```
@@ -0,0 +1,13 @@
```go
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
VectorsConfig: qdrant.NewVectorsConfigMap(
map[string]*qdrant.VectorParams{
"description-dense": {Size: 384, Distance: qdrant.Distance_Cosine},
}),
SparseVectorsConfig: qdrant.NewSparseVectorsConfig(
map[string]*qdrant.SparseVectorParams{
"isbn-bm25": {Modifier: qdrant.Modifier_Idf.Enum()},
}),
})
```
@@ -0,0 +1,32 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
QdrantClient client =
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setVectorsConfig(
VectorsConfig.newBuilder()
.setParamsMap(
VectorParamsMap.newBuilder()
.putMap(
"description-dense",
VectorParams.newBuilder()
.setSize(384)
.setDistance(Distance.Cosine)
.build())
.build())
.build())
.setSparseVectorsConfig(
SparseVectorConfig.newBuilder()
.putMap(
"isbn-bm25",
SparseVectorParams.newBuilder().setModifier(Modifier.Idf).build())
.build())
.build())
.get();
```
@@ -0,0 +1,19 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
vectors_config={
"description-dense": models.VectorParams(size=384, distance=models.Distance.COSINE)
},
sparse_vectors_config={
"isbn-bm25": models.SparseVectorParams(modifier=models.Modifier.IDF)
},
)
```
@@ -0,0 +1,27 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Distance, Modifier, SparseVectorParamsBuilder,
SparseVectorsConfigBuilder, VectorParamsBuilder, VectorsConfigBuilder,
};
let mut vectors = VectorsConfigBuilder::default();
vectors.add_named_vector_params(
"description-dense",
VectorParamsBuilder::new(384, Distance::Cosine),
);
let mut sparse = SparseVectorsConfigBuilder::default();
sparse.add_named_vector_params(
"isbn-bm25",
SparseVectorParamsBuilder::default().modifier(Modifier::Idf),
);
client
.create_collection(
CreateCollectionBuilder::new("books")
.vectors_config(vectors)
.sparse_vectors_config(sparse),
)
.await?;
```
@@ -0,0 +1,10 @@
```typescript
client.createCollection("books", {
vectors: {
"description-dense": { size: 384, distance: "Cosine" },
},
sparse_vectors: {
"isbn-bm25": { modifier: "idf" },
},
});
```
@@ -0,0 +1,35 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "books",
VectorsConfig: qdrant.NewVectorsConfigMap(
map[string]*qdrant.VectorParams{
"description-dense": {Size: 384, Distance: qdrant.Distance_Cosine},
}),
SparseVectorsConfig: qdrant.NewSparseVectorsConfig(
map[string]*qdrant.SparseVectorParams{
"isbn-bm25": {Modifier: qdrant.Modifier_Idf.Enum()},
}),
})
}
@@ -0,0 +1,37 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("books")
.setVectorsConfig(
VectorsConfig.newBuilder()
.setParamsMap(
VectorParamsMap.newBuilder()
.putMap(
"description-dense",
VectorParams.newBuilder()
.setSize(384)
.setDistance(Distance.Cosine)
.build())
.build())
.build())
.setSparseVectorsConfig(
SparseVectorConfig.newBuilder()
.putMap(
"isbn-bm25",
SparseVectorParams.newBuilder().setModifier(Modifier.Idf).build())
.build())
.build())
.get();
}
}
@@ -0,0 +1,17 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_collection(
collection_name="books",
vectors_config={
"description-dense": models.VectorParams(size=384, distance=models.Distance.COSINE)
},
sparse_vectors_config={
"isbn-bm25": models.SparseVectorParams(modifier=models.Modifier.IDF)
},
)
@@ -0,0 +1,31 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateCollectionBuilder, Distance, Modifier, SparseVectorParamsBuilder,
SparseVectorsConfigBuilder, VectorParamsBuilder, VectorsConfigBuilder,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let mut vectors = VectorsConfigBuilder::default();
vectors.add_named_vector_params(
"description-dense",
VectorParamsBuilder::new(384, Distance::Cosine),
);
let mut sparse = SparseVectorsConfigBuilder::default();
sparse.add_named_vector_params(
"isbn-bm25",
SparseVectorParamsBuilder::default().modifier(Modifier::Idf),
);
client
.create_collection(
CreateCollectionBuilder::new("books")
.vectors_config(vectors)
.sparse_vectors_config(sparse),
)
.await?;
Ok(())
}
@@ -0,0 +1,12 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createCollection("books", {
vectors: {
"description-dense": { size: 384, distance: "Cosine" },
},
sparse_vectors: {
"isbn-bm25": { modifier: "idf" },
},
});
@@ -0,0 +1,26 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "title",
schemaType: PayloadSchemaType.Text,
indexParams: new PayloadIndexParams
{
TextIndexParams = new TextIndexParams
{
Tokenizer = TokenizerType.Word,
AsciiFolding = true,
PhraseMatching = true,
Lowercase = true,
},
}
);
}
}
@@ -0,0 +1,20 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "title",
schemaType: PayloadSchemaType.Text,
indexParams: new PayloadIndexParams
{
TextIndexParams = new TextIndexParams
{
Tokenizer = TokenizerType.Word,
AsciiFolding = true,
PhraseMatching = true,
Lowercase = true,
},
}
);
```
@@ -0,0 +1,14 @@
```go
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "title",
FieldType: qdrant.FieldType_FieldTypeText.Enum(),
FieldIndexParams: qdrant.NewPayloadIndexParamsText(
&qdrant.TextIndexParams{
Tokenizer: qdrant.TokenizerType_Word,
Lowercase: qdrant.PtrOf(true),
AsciiFolding: qdrant.PtrOf(true),
PhraseMatching: qdrant.PtrOf(true),
}),
})
```
@@ -0,0 +1,29 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
import io.qdrant.client.grpc.Collections.TextIndexParams;
import io.qdrant.client.grpc.Collections.TokenizerType;
QdrantClient client =
client
.createPayloadIndexAsync(
"books",
"title",
PayloadSchemaType.Text,
PayloadIndexParams.newBuilder()
.setTextIndexParams(
TextIndexParams.newBuilder()
.setTokenizer(TokenizerType.Word)
.setAsciiFolding(true)
.setPhraseMatching(true)
.setLowercase(true)
.build())
.build(),
null,
null,
null)
.get();
```
@@ -0,0 +1,15 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="title",
field_schema=models.TextIndexParams(type=models.TextIndexType.TEXT, ascii_folding=True, phrase_matching=True),
)
```
@@ -0,0 +1,19 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateFieldIndexCollectionBuilder, FieldType, TextIndexParamsBuilder, TokenizerType,
};
let params = TextIndexParamsBuilder::new(TokenizerType::Word)
.ascii_folding(true)
.phrase_matching(true)
.lowercase(true)
.build();
client
.create_field_index(
CreateFieldIndexCollectionBuilder::new("books", "title", FieldType::Text)
.field_index_params(params),
)
.await?;
```
@@ -0,0 +1,10 @@
```typescript
client.createPayloadIndex("books", {
field_name: "title",
field_schema: {
type: "text",
ascii_folding: true,
phrase_matching: true,
},
});
```
@@ -0,0 +1,36 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "title",
FieldType: qdrant.FieldType_FieldTypeText.Enum(),
FieldIndexParams: qdrant.NewPayloadIndexParamsText(
&qdrant.TextIndexParams{
Tokenizer: qdrant.TokenizerType_Word,
Lowercase: qdrant.PtrOf(true),
AsciiFolding: qdrant.PtrOf(true),
PhraseMatching: qdrant.PtrOf(true),
}),
})
}
@@ -0,0 +1,34 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
import io.qdrant.client.grpc.Collections.TextIndexParams;
import io.qdrant.client.grpc.Collections.TokenizerType;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createPayloadIndexAsync(
"books",
"title",
PayloadSchemaType.Text,
PayloadIndexParams.newBuilder()
.setTextIndexParams(
TextIndexParams.newBuilder()
.setTokenizer(TokenizerType.Word)
.setAsciiFolding(true)
.setPhraseMatching(true)
.setLowercase(true)
.build())
.build(),
null,
null,
null)
.get();
}
}
@@ -0,0 +1,13 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="title",
field_schema=models.TextIndexParams(type=models.TextIndexType.TEXT, ascii_folding=True, phrase_matching=True),
)
@@ -0,0 +1,23 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateFieldIndexCollectionBuilder, FieldType, TextIndexParamsBuilder, TokenizerType,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let params = TextIndexParamsBuilder::new(TokenizerType::Word)
.ascii_folding(true)
.phrase_matching(true)
.lowercase(true)
.build();
client
.create_field_index(
CreateFieldIndexCollectionBuilder::new("books", "title", FieldType::Text)
.field_index_params(params),
)
.await?;
Ok(())
}
@@ -0,0 +1,12 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createPayloadIndex("books", {
field_name: "title",
field_schema: {
type: "text",
ascii_folding: true,
phrase_matching: true,
},
});
@@ -0,0 +1,25 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "title",
schemaType: PayloadSchemaType.Text,
indexParams: new PayloadIndexParams
{
TextIndexParams = new TextIndexParams
{
Tokenizer = TokenizerType.Word,
AsciiFolding = true,
Lowercase = true,
},
}
);
}
}
@@ -0,0 +1,19 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
await client.CreatePayloadIndexAsync(
collectionName: "books",
fieldName: "title",
schemaType: PayloadSchemaType.Text,
indexParams: new PayloadIndexParams
{
TextIndexParams = new TextIndexParams
{
Tokenizer = TokenizerType.Word,
AsciiFolding = true,
Lowercase = true,
},
}
);
```
@@ -0,0 +1,13 @@
```go
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "title",
FieldType: qdrant.FieldType_FieldTypeText.Enum(),
FieldIndexParams: qdrant.NewPayloadIndexParamsText(
&qdrant.TextIndexParams{
Tokenizer: qdrant.TokenizerType_Word,
Lowercase: qdrant.PtrOf(true),
AsciiFolding: qdrant.PtrOf(true),
}),
})
```
@@ -0,0 +1,28 @@
```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
import io.qdrant.client.grpc.Collections.TextIndexParams;
import io.qdrant.client.grpc.Collections.TokenizerType;
QdrantClient client =
client
.createPayloadIndexAsync(
"books",
"title",
PayloadSchemaType.Text,
PayloadIndexParams.newBuilder()
.setTextIndexParams(
TextIndexParams.newBuilder()
.setTokenizer(TokenizerType.Word)
.setAsciiFolding(true)
.setLowercase(true)
.build())
.build(),
null,
null,
null)
.get();
```
@@ -0,0 +1,15 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="title",
field_schema=models.TextIndexParams(type=models.TextIndexType.TEXT, ascii_folding=True),
)
```
@@ -0,0 +1,18 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateFieldIndexCollectionBuilder, FieldType, TextIndexParamsBuilder, TokenizerType,
};
let params = TextIndexParamsBuilder::new(TokenizerType::Word)
.ascii_folding(true)
.lowercase(true)
.build();
client
.create_field_index(
CreateFieldIndexCollectionBuilder::new("books", "title", FieldType::Text)
.field_index_params(params),
)
.await?;
```
@@ -0,0 +1,9 @@
```typescript
client.createPayloadIndex("books", {
field_name: "title",
field_schema: {
type: "text",
ascii_folding: true,
},
});
```
@@ -0,0 +1,35 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "books",
FieldName: "title",
FieldType: qdrant.FieldType_FieldTypeText.Enum(),
FieldIndexParams: qdrant.NewPayloadIndexParamsText(
&qdrant.TextIndexParams{
Tokenizer: qdrant.TokenizerType_Word,
Lowercase: qdrant.PtrOf(true),
AsciiFolding: qdrant.PtrOf(true),
}),
})
}
@@ -0,0 +1,33 @@
package com.example.snippets_amalgamation;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
import io.qdrant.client.grpc.Collections.TextIndexParams;
import io.qdrant.client.grpc.Collections.TokenizerType;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
client
.createPayloadIndexAsync(
"books",
"title",
PayloadSchemaType.Text,
PayloadIndexParams.newBuilder()
.setTextIndexParams(
TextIndexParams.newBuilder()
.setTokenizer(TokenizerType.Word)
.setAsciiFolding(true)
.setLowercase(true)
.build())
.build(),
null,
null,
null)
.get();
}
}
@@ -0,0 +1,13 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.create_payload_index(
collection_name="books",
field_name="title",
field_schema=models.TextIndexParams(type=models.TextIndexType.TEXT, ascii_folding=True),
)
@@ -0,0 +1,22 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{
CreateFieldIndexCollectionBuilder, FieldType, TextIndexParamsBuilder, TokenizerType,
};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let params = TextIndexParamsBuilder::new(TokenizerType::Word)
.ascii_folding(true)
.lowercase(true)
.build();
client
.create_field_index(
CreateFieldIndexCollectionBuilder::new("books", "title", FieldType::Text)
.field_index_params(params),
)
.await?;
Ok(())
}
@@ -0,0 +1,11 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createPayloadIndex("books", {
field_name: "title",
field_schema: {
type: "text",
ascii_folding: true,
},
});
@@ -0,0 +1,23 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.QueryAsync(
collectionName: "books",
query: new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
usingVector: "description-dense",
filter: MatchPhrase("title", "time machine"),
payloadSelector: true
);
}
}
@@ -0,0 +1,17 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
await client.QueryAsync(
collectionName: "books",
query: new Document
{
Text = "time travel",
Model = "sentence-transformers/all-minilm-l6-v2",
},
usingVector: "description-dense",
filter: MatchPhrase("title", "time machine"),
payloadSelector: true
);
```
@@ -0,0 +1,16 @@
```go
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Model: "sentence-transformers/all-minilm-l6-v2",
Text: "time travel",
}),
),
Using: qdrant.PtrOf("description-dense"),
WithPayload: qdrant.NewWithPayload(true),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{qdrant.NewMatchPhrase("title", "time machine")},
},
})
```
@@ -0,0 +1,32 @@
```java
import static io.qdrant.client.ConditionFactory.*;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.WithPayloadSelectorFactory.enable;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.*;
import java.util.*;
QdrantClient client =
Filter filter = Filter.newBuilder().addMust(matchPhrase("title", "time machine")).build();
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(filter)
.setWithPayload(enable(true))
.build())
.get();
```
@@ -0,0 +1,19 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.query_points(
collection_name="books",
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
query_filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchPhrase(phrase="time machine"))]
),
)
```
@@ -0,0 +1,20 @@
```rust
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Condition, Document, Filter, Query, QueryPointsBuilder};
let filter = Filter::must([Condition::matches("title", "time machine".to_string())]);
client
.query(
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(filter)
.with_payload(true)
.build(),
)
.await?;
```
@@ -0,0 +1,15 @@
```typescript
client.query("books", {
query: {
text: "time travel",
model: "sentence-transformers/all-minilm-l6-v2",
},
using: "description-dense",
with_payload: true,
filter: {
must: [
{ key: "title", match: { phrase: "time machine" } },
],
},
});
```
@@ -0,0 +1,38 @@
package snippet
// @hide-start
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
// @hide-end
func Main() {
//@hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil {
panic(err)
}
// @hide-end
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Model: "sentence-transformers/all-minilm-l6-v2",
Text: "time travel",
}),
),
Using: qdrant.PtrOf("description-dense"),
WithPayload: qdrant.NewWithPayload(true),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{qdrant.NewMatchPhrase("title", "time machine")},
},
})
}
@@ -0,0 +1,37 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.ConditionFactory.*;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.WithPayloadSelectorFactory.enable;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.*;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.*;
import java.util.*;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); // @hide
Filter filter = Filter.newBuilder().addMust(matchPhrase("title", "time machine")).build();
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("books")
.setQuery(
nearest(
Document.newBuilder()
.setText("time travel")
.setModel("sentence-transformers/all-minilm-l6-v2")
.build()))
.setUsing("description-dense")
.setFilter(filter)
.setWithPayload(enable(true))
.build())
.get();
}
}
@@ -0,0 +1,17 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(
url="https://xyz-example.qdrant.io:6333",
api_key="<your-api-key>",
cloud_inference=True,
)
client.query_points(
collection_name="books",
query=models.Document(text="time travel", model="sentence-transformers/all-minilm-l6-v2"),
using="description-dense",
with_payload=True,
query_filter=models.Filter(
must=[models.FieldCondition(key="title", match=models.MatchPhrase(phrase="time machine"))]
),
)
@@ -0,0 +1,24 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Condition, Document, Filter, Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let filter = Filter::must([Condition::matches("title", "time machine".to_string())]);
client
.query(
QueryPointsBuilder::new("books")
.query(Query::new_nearest(Document::new(
"time travel",
"sentence-transformers/all-minilm-l6-v2",
)))
.using("description-dense")
.filter(filter)
.with_payload(true)
.build(),
)
.await?;
Ok(())
}
@@ -0,0 +1,17 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.query("books", {
query: {
text: "time travel",
model: "sentence-transformers/all-minilm-l6-v2",
},
using: "description-dense",
with_payload: true,
filter: {
must: [
{ key: "title", match: { phrase: "time machine" } },
],
},
});
@@ -0,0 +1,23 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.QueryAsync(
collectionName: "books",
query: new Document
{
Text = "space opera",
Model = "sentence-transformers/all-minilm-l6-v2",
},
usingVector: "description-dense",
filter: MatchTextAny("title", "space war"),
payloadSelector: true
);
}
}
@@ -0,0 +1,17 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
await client.QueryAsync(
collectionName: "books",
query: new Document
{
Text = "space opera",
Model = "sentence-transformers/all-minilm-l6-v2",
},
usingVector: "description-dense",
filter: MatchTextAny("title", "space war"),
payloadSelector: true
);
```
@@ -0,0 +1,16 @@
```go
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "books",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Model: "sentence-transformers/all-minilm-l6-v2",
Text: "space opera",
}),
),
Using: qdrant.PtrOf("description-dense"),
WithPayload: qdrant.NewWithPayload(true),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{qdrant.NewMatchTextAny("title", "space war")},
},
})
```

Some files were not shown because too many files have changed in this diff Show More