mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-10 21:38:30 +02:00
Automated snippet conversion by scripts
These changes are purely mechanical to differentiate them from manual fixes/adjustments made in the next commit. This results in broken code as some snippets contain errors. Made in four steps: 1. Run ./migrate-snippet.py that converts `.md` files to code files and perhaps adds missing lines under `// @hide` comments. 2. Sort Java imports. 3. Remove old `.md` files. 4. Run ./generate.md to produce `*/generated/*.md` files.
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
|
||||
await client.CreatePayloadIndexAsync(
|
||||
collectionName: "{collection_name}",
|
||||
fieldName: "name_of_the_field_to_index",
|
||||
schemaType: PayloadSchemaType.Text,
|
||||
indexParams: new PayloadIndexParams
|
||||
{
|
||||
TextIndexParams = new TextIndexParams
|
||||
{
|
||||
Tokenizer = TokenizerType.Word,
|
||||
Stemmer = new StemmingAlgorithm
|
||||
{
|
||||
Snowball = new SnowballParams
|
||||
{
|
||||
Language = "english"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+27
@@ -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,
|
||||
})
|
||||
|
||||
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
FieldName: "name_of_the_field_to_index",
|
||||
FieldType: qdrant.FieldType_FieldTypeText.Enum(),
|
||||
FieldIndexParams: qdrant.NewPayloadIndexParamsText(
|
||||
&qdrant.TextIndexParams{
|
||||
Tokenizer: qdrant.TokenizerType_Word,
|
||||
Stemmer: qdrant.NewStemmingAlgorithmSnowball(&qdrant.SnowballParams{
|
||||
Language: "english",
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
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.SnowballParams;
|
||||
import io.qdrant.client.grpc.Collections.StemmingAlgorithm;
|
||||
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());
|
||||
|
||||
client
|
||||
.createPayloadIndexAsync(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
PayloadSchemaType.Text,
|
||||
PayloadIndexParams.newBuilder()
|
||||
.setTextIndexParams(
|
||||
TextIndexParams.newBuilder()
|
||||
.setTokenizer(TokenizerType.Word)
|
||||
.setStemmer(
|
||||
StemmingAlgorithm.newBuilder()
|
||||
.setSnowball(
|
||||
SnowballParams.newBuilder().setLanguage("english").build())
|
||||
.build())
|
||||
.build())
|
||||
.build(),
|
||||
true,
|
||||
null,
|
||||
null)
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
client.create_payload_index(
|
||||
collection_name="{collection_name}",
|
||||
field_name="name_of_the_field_to_index",
|
||||
field_schema=models.TextIndexParams(
|
||||
type="text",
|
||||
tokenizer=models.TokenizerType.WORD,
|
||||
stemmer=models.SnowballParams(
|
||||
type=models.Snowball.SNOWBALL,
|
||||
language=models.SnowballLanguage.ENGLISH
|
||||
)
|
||||
),
|
||||
)
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
use qdrant_client::qdrant::{
|
||||
CreateFieldIndexCollectionBuilder,
|
||||
TextIndexParamsBuilder,
|
||||
FieldType,
|
||||
TokenizerType,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let text_index_params = TextIndexParamsBuilder::new(TokenizerType::Word)
|
||||
.snowball_stemmer("english".to_string());
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"{field_name}",
|
||||
FieldType::Text,
|
||||
).field_index_params(text_index_params.build()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.createPayloadIndex("{collection_name}", {
|
||||
field_name: "name_of_the_field_to_index",
|
||||
field_schema: {
|
||||
type: "text",
|
||||
tokenizer: "word",
|
||||
stemmer: {
|
||||
type: "snowball",
|
||||
language: "english"
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user