### Install Qdrant Client for Go Source: https://qdrant.tech/documentation/cloud-quickstart/index.md Get the Qdrant client library for Go projects using the go get command. ```bash go get github.com/qdrant/go-client # for Go projects ``` -------------------------------- ### Complete Semantic-Router Example with Qdrant Source: https://qdrant.tech/documentation/frameworks/semantic-router/index.md A full example demonstrating route definition, encoder setup, Qdrant index initialization (in-memory), and RouteLayer usage for routing user input. ```python import os from semantic_router import Route from semantic_router.encoders import OpenAIEncoder from semantic_router.index import QdrantIndex from semantic_router.layer import RouteLayer # we could use this as a guide for our chatbot to avoid political conversations politics = Route( name="politics value", utterances=[ "isn't politics the best thing ever", "why don't you tell me about your political opinions", "don't you just love the president", "they're going to destroy this country!", "they will save the country!", ], ) # this could be used as an indicator to our chatbot to switch to a more # conversational prompt chitchat = Route( name="chitchat", utterances=[ "how's the weather today?", "how are things going?", "lovely weather today", "the weather is horrendous", "let's go to the chippy", ], ) # we place both of our decisions together into single list routes = [politics, chitchat] os.environ["OPENAI_API_KEY"] = "" encoder = OpenAIEncoder() rl = RouteLayer( encoder=encoder, routes=routes, index=QdrantIndex(location=":memory:"), ) print(rl("What have you been upto?").name) ``` -------------------------------- ### Go Context Search Example Source: https://qdrant.tech/documentation/search/explore/index.md Implement context search using the Qdrant Go client. This example demonstrates initializing the client and constructing a context search query with positive and negative examples. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.Query(context.Background(), &qdrant.QueryPoints{ CollectionName: "{collection_name}", Query: qdrant.NewQueryContext(&qdrant.ContextInput{ Pairs: []*qdrant.ContextInputPair{ { Positive: qdrant.NewVectorInputID(qdrant.NewIDNum(100)), Negative: qdrant.NewVectorInputID(qdrant.NewIDNum(718)), }, { Positive: qdrant.NewVectorInputID(qdrant.NewIDNum(200)), Negative: qdrant.NewVectorInputID(qdrant.NewIDNum(300)), }, }, }), }) ``` -------------------------------- ### Install Qdrant Client Source: https://qdrant.tech/documentation/tutorials-basics/reranking-hybrid-search?q=late+interaction Install the Qdrant client library for your preferred language. ```bash qdrant-client ``` ```bash qdrant/js-client-rest ``` ```bash qdrant-client ``` ```bash io.qdrant:client ``` ```bash Qdrant.Client ``` ```bash github.com/qdrant/go-client ``` -------------------------------- ### Install qdrant-client Source: https://qdrant.tech/documentation/fastembed/fastembed-colbert/index.md Install the qdrant-client library to interact with Qdrant. ```python pip install "qdrant-client>=1.14.2" ``` -------------------------------- ### Install Qdrant Client Source: https://qdrant.tech/documentation/tutorials-operations/time-based-sharding Install the Qdrant client library using pip. ```bash !pip install qdrant-client ``` -------------------------------- ### Setup Vanna Agent with Qdrant and OpenAI Source: https://qdrant.tech/documentation/frameworks/vanna-ai Configure a Vanna agent by subclassing Qdrant_VectorStore and OpenAI_Chat. This example demonstrates initializing the agent with Qdrant client details and an OpenAI model. ```python from vanna.openai import OpenAI_Chat from vanna.qdrant import Qdrant_VectorStore from qdrant_client import QdrantClient class MyVanna(Qdrant, OpenAI_Chat): def __init__(self, config=None): Qdrant_VectorStore.__init__(self, config=config) OpenAI_Chat.__init__(self, config=config) vn = MyVanna(config={ 'client': QdrantClient(...), 'api_key': sk-…, 'model': gpt-4-…, }) ``` -------------------------------- ### Install Qdrant Cloud CLI from Source Source: https://qdrant.tech/documentation/cloud-cli/index.md Build and install the qcloud CLI directly from source using Go. Ensure you have Go installed. ```sh go install github.com/qdrant/qcloud-cli/cmd/qcloud@latest ``` -------------------------------- ### Initialize and Start QdrantContainer in TypeScript Source: https://qdrant.tech/documentation/frameworks/testcontainers/index.md Start a Qdrant container instance in TypeScript using the Testcontainers Qdrant module. This example demonstrates starting the container immediately after initialization. ```typescript import { QdrantContainer } from "@testcontainers/qdrant"; const qdrantContainer = await new QdrantContainer("qdrant/qdrant").start(); ``` -------------------------------- ### Set up Python Clients Source: https://qdrant.tech/documentation/embeddings/premai/index.md Initialize the Prem AI and Qdrant clients using their respective SDKs in Python. ```python prem_client = Prem(api_key="xxxx-xxx-xxx") qdrant_client = QdrantClient(url=QDRANT_SERVER_URL) ``` -------------------------------- ### Setup Qdrant Client and Libraries Source: https://qdrant.tech/documentation/tutorials-search-engineering/collaborative-filtering/index.md Imports necessary libraries and initializes the Qdrant client with environment variables for host and API key. This is the initial setup for interacting with Qdrant. ```python import os import pandas as pd import requests from qdrant_client import QdrantClient, models from qdrant_client.models import PointStruct, SparseVector, NamedSparseVector from collections import defaultdict # OMDB API Key - for movie posters omdb_api_key = os.getenv("OMDB_API_KEY") # Collection name collection_name = "movies" # Set Qdrant Client qdrant_client = QdrantClient( os.getenv("QDRANT_HOST"), api_key=os.getenv("QDRANT_API_KEY") ) ``` -------------------------------- ### Install NLWeb and Set Up Environment Source: https://qdrant.tech/documentation/frameworks/nlweb Clone the NLWeb repository, set up a Python virtual environment, and install dependencies. Ensure you activate the virtual environment before proceeding. ```bash git clone https://github.com/microsoft/NLWeb cd NLWeb python -m venv .venv source venv/bin/activate # or `venv\Scripts\activate` on Windows cd code pip install -r requirements.txt ``` -------------------------------- ### Mastra Setup Source: https://qdrant.tech/documentation/frameworks/mastra Install the Mastra core package using npm. ```APIDOC ## Setup ``` npm install @mastra/core ``` ``` -------------------------------- ### Get Facet Counts (Go) Source: https://qdrant.tech/documentation/manage-data/payload Use the Go client to get facet counts. This example demonstrates passing context and a pointer to a boolean for the 'exact' field. ```go res, err := client.Facet(context.Background(), &qdrant.FacetCounts{ CollectionName: "{collection_name}", Key: "key", Exact: qdrant.PtrOf(true), }) ``` -------------------------------- ### Create Collection with Product Quantization (Go) Source: https://qdrant.tech/documentation/manage-data/quantization Go example using the Qdrant client to create a collection with product quantization. Shows how to set vector parameters and quantization configuration. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.CreateCollection(context.Background(), &qdrant.CreateCollection{ CollectionName: "{collection_name}", VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{ Size: 768, Distance: qdrant.Distance_Cosine, }), QuantizationConfig: qdrant.NewQuantizationProduct( &qdrant.ProductQuantization{ Compression: qdrant.CompressionRatio_x16, AlwaysRam: qdrant.PtrOf(true), }, ), }) ``` -------------------------------- ### Get Facet Counts with Filter (TypeScript) Source: https://qdrant.tech/documentation/manage-data/payload Use the TypeScript client to get facet counts, including a filter condition. This example demonstrates filtering by a 'color' field. ```typescript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); client.facet("{collection_name}", { filter: { must: [ { key: "color", match: { value: "red", }, }, ], }, key: "size", }); ``` -------------------------------- ### Clone Repository and Navigate Source: https://qdrant.tech/documentation/tutorials-build-essentials/agentic-rag-crewai-zoom/index.md Clone the example repository and navigate into the specific project directory. ```bash git clone https://github.com/qdrant/examples.git cd agentic_rag_zoom_crewai ``` -------------------------------- ### Go SDK Example Source: https://qdrant.tech/documentation/search Example of enabling ACORN search using the Qdrant Go client. This shows how to configure ACORN parameters using pointers. ```APIDOC ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) 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), }, }, }) ``` ``` -------------------------------- ### Get Facet Counts (C#) Source: https://qdrant.tech/documentation/manage-data/payload/index.md Asynchronously get facet counts using the Qdrant client in C#. This example demonstrates setting the collection name, key, and exact matching option. ```csharp using Qdrant.Client; using Qdrant.Client.Grpc; await client.FacetAsync( "{collection_name}", key: "size", exact: true ); ``` -------------------------------- ### Install Dependencies for LlamaIndex and Qdrant Source: https://qdrant.tech/documentation/examples/hybrid-search-llamaindex-jinaai/index.md Install the required Python packages for LlamaIndex, JinaAI embeddings, HuggingFace LLMs, and Qdrant vector store integration. This setup is necessary for building the RAG system. ```python !pip install -U \ llama-index \ llama-parse \ python-dotenv \ llama-index-embeddings-jinaai \ llama-index-llms-huggingface \ llama-index-vector-stores-qdrant \ "huggingface_hub[inference]" \ datasets ``` -------------------------------- ### Example Qdrant Configuration from Environment Variables Source: https://qdrant.tech/documentation/ops-configuration/configuration This shows the resulting configuration structure when using the environment variables from the previous example. ```yaml log_level: INFO service: enable_tls: true api_key: tls: cert: ./tls/cert.pem ``` -------------------------------- ### Instantiate Traceloop SDK Source: https://qdrant.tech/documentation/observability/openllmetry Initialize the Traceloop SDK to start tracing your qdrant_client usage. This should be done after installation. ```python from traceloop.sdk import Traceloop Traceloop.init() ``` -------------------------------- ### Random Sampling using Go SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant Go client. ```APIDOC ## Random Sampling with Go SDK ### Description Use the `QueryGroups` method with `qdrant.NewQuerySample(qdrant.Sample_Random)` to fetch random points. ### Method Signature `client.QueryGroups(context.Context, *qdrant.QueryPointGroups)` ### Parameters - **context.Context** - The context for the request. - **qdrant.QueryPointGroups** - Struct containing query details. - **CollectionName** (string) - Required - The name of the collection. - **Query** (*qdrant.Query) - Required - Use `qdrant.NewQuerySample(qdrant.Sample_Random)` for random sampling. ### Request Example ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.QueryGroups(context.Background(), &qdrant.QueryPointGroups{ CollectionName: "{collection_name}", Query: qdrant.NewQuerySample(qdrant.Sample_Random), }) ``` ``` -------------------------------- ### Set up TypeScript Clients Source: https://qdrant.tech/documentation/embeddings/premai/index.md Initialize the Prem AI and Qdrant clients using their respective SDKs in TypeScript. ```typescript const premaiClient = new Prem({ apiKey: "xxxx-xxx-xxx" }) const qdrantClient = new QdrantClient({ url: SERVER_URL }); ``` -------------------------------- ### Random Sampling using C# SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant C# client. ```APIDOC ## Random Sampling with C# SDK ### Description Call the `QueryAsync` method with `Sample.Random` to obtain a random sample of points. ### Method Signature `await client.QueryAsync(collectionName: string, query: Sample)` ### Parameters - **collectionName** (string) - Required - The name of the collection. - **query** (Sample) - Required - Set to `Sample.Random` for random sampling. ### Request Example ```csharp using Qdrant.Client; using Qdrant.Client.Grpc; var client = new QdrantClient("localhost", 6334); await client.QueryAsync(collectionName: "{collection_name}", query: Sample.Random); ``` ``` -------------------------------- ### Set up Prem AI and Qdrant Clients (Python) Source: https://qdrant.tech/documentation/embeddings/premai Initialize Prem AI and Qdrant clients using API keys and server URLs in Python. ```python prem_client = Prem(api_key="xxxx-xxx-xxx") qdrant_client = QdrantClient(url=QDRANT_SERVER_URL) ``` -------------------------------- ### Random Sampling using Java SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant Java client. ```APIDOC ## Random Sampling with Java SDK ### Description Use the `queryAsync` method with `sample(Sample.Random)` to retrieve random points. ### Method Signature `client.queryAsync(QueryPoints)` ### Parameters - **QueryPoints** - Builder for the query. - `.setQuery(sample(Sample.Random))` - Configures the query for random sampling. ### Request Example ```java import static io.qdrant.client.QueryFactory.sample; import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Points.QueryPoints; import io.qdrant.client.grpc.Points.Sample; QdrantClient client = new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client .queryAsync( QueryPoints.newBuilder() .setCollectionName("{collection_name}") .setQuery(sample(Sample.Random)) .build()) .get(); ``` ``` -------------------------------- ### Random Sampling using Rust SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant Rust client. ```APIDOC ## Random Sampling with Rust SDK ### Description Employ the `query` method with `Query::new_sample(Sample::Random)` to fetch random points. ### Method Signature `client.query(QueryPointsBuilder)` ### Parameters - **QueryPointsBuilder** - Used to construct the query. - `.query(Query::new_sample(Sample::Random))` - Specifies random sampling. ### Request Example ```rust use qdrant_client::Qdrant; use qdrant_client::qdrant::{Query, QueryPointsBuilder, Sample}; let client = Qdrant::from_url("http://localhost:6334").build()?; let sampled = client .query( QueryPointsBuilder::new("{collection_name}") .query(Query::new_sample(Sample::Random)) ) .await?; ``` ``` -------------------------------- ### Create VoltAgent Project with Qdrant Example Source: https://qdrant.tech/documentation/frameworks/voltagent/index.md Use this command to generate a new VoltAgent project pre-configured with Qdrant integration and example data. ```bash npm create voltagent-app@latest -- --example with-qdrant cd with-qdrant ``` -------------------------------- ### Random Sampling using JavaScript SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant JavaScript client. ```APIDOC ## Random Sampling with JavaScript SDK ### Description Utilize the `query` method with a `sample: "random"` object to retrieve random points. ### Method Signature `client.query(collectionName: string, query: object)` ### Parameters - **collectionName** (string) - Required - The name of the collection. - **query** (object) - Required - An object containing the query parameters, including `sample: "random"`. ### Request Example ```javascript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); const sampled = await client.query("{collection_name}", { query: { sample: "random", }, }); ``` ``` -------------------------------- ### Create Collection with Product Quantization (C#) Source: https://qdrant.tech/documentation/manage-data/quantization C# example using the Qdrant client to create a collection with product quantization. Includes configuration for vector parameters and quantization. ```csharp using Qdrant.Client; using Qdrant.Client.Grpc; var client = new QdrantClient("localhost", 6334); await client.CreateCollectionAsync( collectionName: "{collection_name}", vectorsConfig: new VectorParams { Size = 768, Distance = Distance.Cosine }, quantizationConfig: new QuantizationConfig { Product = new ProductQuantization { Compression = CompressionRatio.X16, AlwaysRam = true } } ); ``` -------------------------------- ### Random Sampling using Python SDK Source: https://qdrant.tech/documentation/search/search Example of how to get a random sample of points using the Qdrant Python client. ```APIDOC ## Random Sampling with Python SDK ### Description Use the `query_points` method with `models.Sample.RANDOM` to fetch random points. ### Method Signature `client.query_points(collection_name: str, query: models.SampleQuery)` ### Parameters - **collection_name** (str) - Required - The name of the collection to query. - **query** (models.SampleQuery) - Required - A `SampleQuery` object with `sample=models.Sample.RANDOM`. ### Request Example ```python from qdrant_client import QdrantClient, models client = QdrantClient(url="http://localhost:6333") sampled = client.query_points( collection_name="{collection_name}", query=models.SampleQuery(sample=models.Sample.RANDOM) ) ``` ``` -------------------------------- ### Install Project Dependencies Source: https://qdrant.tech/documentation/frameworks/voltagent/index.md After creating the project, run this command to install all necessary dependencies. ```bash npm install ``` -------------------------------- ### Connect to Qdrant with TLS using curl Source: https://qdrant.tech/documentation/security/index.md When TLS is enabled, use HTTPS to connect to the Qdrant instance. This example shows a basic GET request. ```bash curl -X GET https://localhost:6333 ``` -------------------------------- ### Initialize VectaX and Qdrant Clients Source: https://qdrant.tech/documentation/frameworks/mirror-security Set up the Mirror SDK and Qdrant client. Ensure you have your API key and secret from the Mirror Security Platform. ```python from mirror_sdk.core.mirror_core import MirrorSDK, MirrorConfig from qdrant_client import QdrantClient from qdrant_client.models import Distance, VectorParams # Get your API key from # https://platform.mirrorsecurity.io config = MirrorConfig( api_key="", server_url="https://mirrorapi.azure-api.net/v1", secret="", ) mirror_sdk = MirrorSDK(config) # Connects to http://localhost:6333/ by default qdrant = QdrantClient() ``` -------------------------------- ### Install and Run Qdrant Locally with Docker Source: https://qdrant.tech/documentation/send-data/data-streaming-kafka-qdrant/index.md Use Docker to pull the Qdrant image and start a local instance. This makes Qdrant accessible at http://localhost:6333. ```bash docker pull qdrant/qdrant docker run -p 6334:6334 -p 6333:6333 qdrant/qdrant ``` -------------------------------- ### Create Collection with Product Quantization (Java) Source: https://qdrant.tech/documentation/manage-data/quantization Java example using the Qdrant client to create a collection with product quantization. Shows configuration for vector parameters and quantization. ```java import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Collections.CompressionRatio; import io.qdrant.client.grpc.Collections.CreateCollection; import io.qdrant.client.grpc.Collections.Distance; import io.qdrant.client.grpc.Collections.ProductQuantization; import io.qdrant.client.grpc.Collections.QuantizationConfig; import io.qdrant.client.grpc.Collections.VectorParams; import io.qdrant.client.grpc.Collections.VectorsConfig; QdrantClient client = new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client .createCollectionAsync( CreateCollection.newBuilder() .setCollectionName("{collection_name}") .setVectorsConfig( VectorsConfig.newBuilder() .setParams( VectorParams.newBuilder() .setSize(768) .setDistance(Distance.Cosine) .build()) .build()) .setQuantizationConfig( QuantizationConfig.newBuilder() .setProduct( ProductQuantization.newBuilder() .setCompression(CompressionRatio.x16) .setAlwaysRam(true) .build()) .build()) .build()) .get(); ``` -------------------------------- ### Run Ollama Model Source: https://qdrant.tech/documentation/examples/rag-chatbot-vultr-dspy-ollama/index.md Install and run a specific LLM model, such as 'gemma:2b', using the Ollama CLI. This command downloads and starts the model on your Ollama instance. ```shell ollama run gemma:2b ``` -------------------------------- ### Query with Lookup from Another Collection (Python) Source: https://qdrant.tech/documentation/search/explore?q=distance+ Python client example for querying points and specifying a collection to look up vectors from. Ensure the `qdrant-client` library is installed. ```python client.query_points( collection_name="{collection_name}", query=models.RecommendQuery( recommend=models.RecommendInput( positive=[100, 231], negative=[718], ) ), using="image", limit=10, lookup_from=models.LookupLocation( collection="{external_collection_name}", vector="{external_vector_name}" ), ) ``` -------------------------------- ### Go SDK Example Source: https://qdrant.tech/documentation/manage-data/indexing Example of how to create a field index with ASCII folding enabled using the Qdrant Go client. ```APIDOC ## CreateFieldIndex (Go) ### Description Creates a field index for a specified field in a collection, with options for text indexing including ASCII folding. ### Method Signature ```go client.CreateFieldIndex(context.Context, *CreateFieldIndexCollection) ``` ### Parameters - **ctx** (context.Context) - Required - The context for the request. - **CreateFieldIndexCollection** - Struct for creating a field index. - **CollectionName** (string) - Required - The name of the collection. - **FieldName** (string) - Required - The name of the field to index. - **FieldType** (FieldType) - Required - The type of the field, e.g., `FieldType_FieldTypeText`. - **FieldIndexParams** (*PayloadIndexParamsText) - Required - Parameters for the text index. - **Tokenizer** (TokenizerType) - Required - The tokenizer to use, e.g., `TokenizerType_Word`. - **AsciiFolding** (*bool) - Required - Pointer to a boolean, set to `true` to enable ASCII folding. ``` -------------------------------- ### BM25 Query with TypeScript Client Source: https://qdrant.tech/documentation/inference/index.md This TypeScript example demonstrates how to connect to a Qdrant instance and execute a BM25 query. Make sure to install the @qdrant/js-client-rest package. ```typescript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); client.query("{collection_name}", { query: { text: 'How to bake cookies?', model: 'qdrant/bm25', }, using: 'my-bm25-vector', }); ``` -------------------------------- ### Initialize RetrieveAssistantAgent and QdrantRetrieveUserProxyAgent Source: https://qdrant.tech/documentation/frameworks/autogen/index.md Set up the AssistantAgent and the Qdrant-backed RetrieveUserProxyAgent. The system message for the assistant and detailed instructions for the user proxy are configured here. ```python from qdrant_client import QdrantClient from sentence_transformers import SentenceTransformer from autogen import AssistantAgent from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent # 1. Create an AssistantAgent instance named "assistant" assistant = AssistantAgent( name="assistant", system_message="You are a helpful assistant.", llm_config={ "timeout": 600, "cache_seed": 42, "config_list": config_list, }, ) sentence_transformer_ef = SentenceTransformer("all-distilroberta-v1").encode client = QdrantClient(url="http://localhost:6333/") # 2. Create the RetrieveUserProxyAgent instance named "ragproxyagent" # Refer to https://microsoft.github.io/autogen/docs/reference/agentchat/contrib/retrieve_user_proxy_agent # for more information on the RetrieveUserProxyAgent ragproxyagent = RetrieveUserProxyAgent( name="ragproxyagent", human_input_mode="NEVER", max_consecutive_auto_reply=10, retrieve_config={ "task": "code", "docs_path": [ "path/to/some/doc.md", "path/to/some/other/doc.md", ], "chunk_token_size": 2000, "model": config_list[0]["model"], "vector_db": "qdrant", "db_config": {"client": client}, "get_or_create": True, "overwrite": True, "embedding_function": sentence_transformer_ef, # Defaults to "BAAI/bge-small-en-v1.5" via FastEmbed }, code_execution_config=False, ) ``` -------------------------------- ### Start Unsecured Qdrant with Docker Compose Source: https://qdrant.tech/documentation/tutorials-operations/secure-qdrant Defines the Docker Compose configuration for running an unsecured Qdrant instance. This setup exposes the default ports for Qdrant. ```yaml services: qdrant: image: qdrant/qdrant ports: - "6333:6333" - "6334:6334" volumes: - qdrant_storage:/qdrant/storage:z volumes: qdrant_storage: ``` -------------------------------- ### Create Collection using Go Client Source: https://qdrant.tech/documentation/manage-data/collections/index.md Go example for creating a collection. Requires the go-client library. Ensure the client is initialized with the correct configuration. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.CreateCollection(context.Background(), &qdrant.CreateCollection{ CollectionName: "{collection_name}", VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{ Size: 100, Distance: qdrant.Distance_Cosine, }), }) ``` -------------------------------- ### Install Postgres with Docker Compose Source: https://qdrant.tech/documentation/data-management/cocoindex Set up a Postgres instance for CocoIndex's metadata store using Docker Compose. This command fetches the configuration and starts the service. ```bash docker compose -f <(curl -L https://raw.githubusercontent.com/cocoindex-io/cocoindex/refs/heads/main/dev/postgres.yaml) up -d ``` -------------------------------- ### Initialize Qdrant and Mistral Clients Source: https://qdrant.tech/documentation/embeddings/mistral/index.md Set up Qdrant and Mistral clients in memory. Ensure you have your Mistral API key ready. ```python from mistralai.client import MistralClient from qdrant_client import QdrantClient from qdrant_client.models import PointStruct, VectorParams, Distance collection_name = "example_collection" MISTRAL_API_KEY = "your_mistral_api_key" client = QdrantClient(":memory:") mistral_client = MistralClient(api_key=MISTRAL_API_KEY) texts = [ "Qdrant is the best vector search engine!", "Loved by Enterprises and everyone building for low latency, high performance, and scale.", ] ``` -------------------------------- ### Create Payload Index with `is_tenant` (Python) Source: https://qdrant.tech/documentation/manage-data/multitenancy Python example for creating a payload index with the `is_tenant` parameter set to true. Ensure you have the Qdrant client library installed. ```python client.create_payload_index( collection_name="{collection_name}", field_name="group_id", field_schema=models.KeywordIndexParams( type=models.KeywordIndexType.KEYWORD, is_tenant=True, ), ) ``` -------------------------------- ### Run Frontend Dashboard Source: https://qdrant.tech/documentation/tutorials-build-essentials/video-anomaly-edge-part-3 Navigate to the frontend directory and start the development server using pnpm. ```bash cd frontend && pnpm dev ``` -------------------------------- ### Get Facet Counts with Filter (C#) Source: https://qdrant.tech/documentation/manage-data/payload/index.md Fetch facet counts with a keyword match filter using the C# client. This example utilizes the MatchKeyword condition for filtering. ```csharp using Qdrant.Client; using static Qdrant.Client.Grpc.Conditions; var client = new QdrantClient("localhost", 6334); await client.FacetAsync( "{collection_name}", key: "size", filter: MatchKeyword("color", "red") ); ``` -------------------------------- ### Create Tenant Index (Go) Source: https://qdrant.tech/documentation/manage-data/indexing Go client example for creating a tenant index. This involves setting up the client and then calling CreateFieldIndex with the appropriate collection, field, type, and tenant parameters. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) 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_FieldTypeKeyword.Enum(), FieldIndexParams: qdrant.NewPayloadIndexParamsKeyword( &qdrant.KeywordIndexParams{ IsTenant: qdrant.PtrOf(true), }), }) ``` -------------------------------- ### Get Facet Counts with Filter (Go) Source: https://qdrant.tech/documentation/manage-data/payload/index.md Obtain facet counts with a filter using the Go client. This example demonstrates constructing a filter with a must condition for matching values. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) res, err := client.Facet(context.Background(), &qdrant.FacetCounts{ CollectionName: "{collection_name}", Key: "size", Filter: &qdrant.Filter{ Must: []*qdrant.Condition{ qdrant.NewMatch("color", "red"), }, }, }) ``` -------------------------------- ### Install Qdrant Client and Datasets Source: https://qdrant.tech/documentation/tutorials-operations/create-snapshot/index.md Install the necessary Python libraries for interacting with Qdrant and loading datasets. ```shell pip install qdrant-client datasets ``` -------------------------------- ### Run Cheshire Cat Core with Docker Source: https://qdrant.tech/documentation/frameworks/cheshire-cat Use Docker to run the Cheshire Cat core image, exposing the default port 1865. This is a quick way to get started. ```bash docker run --rm -it -p 1865:80 ghcr.io/cheshire-cat-ai/core:latest ``` -------------------------------- ### Setup Postgres with Docker Compose Source: https://qdrant.tech/documentation/data-management/cocoindex/index.md Set up a Postgres instance using Docker Compose by downloading the configuration file and running the command. ```bash docker compose -f <(curl -L https://raw.githubusercontent.com/cocoindex-io/cocoindex/refs/heads/main/dev/postgres.yaml) up -d ``` -------------------------------- ### Initialize QdrantIndex Source: https://qdrant.tech/documentation/frameworks/semantic-router/index.md Set up the QdrantIndex with your Qdrant instance URL and API key. ```python from semantic_router.index import QdrantIndex qdrant_index = QdrantIndex( url="https://xyz-example.eu-central.aws.cloud.qdrant.io", api_key="" ) ``` -------------------------------- ### Java Discover Search with Context Source: https://qdrant.tech/documentation/search/explore/index.md Perform a discovery search in Java using positive and negative context examples to guide the search. Ensure the Qdrant client is properly initialized. ```java import static io.qdrant.client.QueryFactory.discover; import static io.qdrant.client.VectorInputFactory.vectorInput; import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Points.ContextInput; import io.qdrant.client.grpc.Points.ContextInputPair; import io.qdrant.client.grpc.Points.DiscoverInput; import io.qdrant.client.grpc.Points.QueryPoints; import java.util.List; QdrantClient client = new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client.queryAsync(QueryPoints.newBuilder() .setCollectionName("{collection_name}") .setQuery(discover(DiscoverInput.newBuilder() .setTarget(vectorInput(0.2f, 0.1f, 0.9f, 0.7f)) .setContext(ContextInput.newBuilder() .addAllPairs(List.of( ContextInputPair.newBuilder() .setPositive(vectorInput(100)) .setNegative(vectorInput(718)) .build(), ContextInputPair.newBuilder() .setPositive(vectorInput(200)) .setNegative(vectorInput(300)) .build())) .build()) .build())) .setLimit(10) .build()).get(); ``` -------------------------------- ### Configure Environment Variables Source: https://qdrant.tech/documentation/tutorials-build-essentials/video-anomaly-edge-part-1/index.md Copy the example environment file and edit it with your specific credentials and settings for Qdrant, Twelve Labs, NVIDIA VSS, and the model. ```bash cp .env.example .env ``` ```env QDRANT_URL=http://localhost:6333 QDRANT_API_KEY= # Twelve Labs (cloud video understanding) TWELVE_LABS_API_KEY= TWELVE_LABS_API_URL=https://api.twelvelabs.io/v1.3 TWELVE_LABS_MARENGO_INDEX_NAME=anomaly-marengo-search TWELVE_LABS_PEGASUS_INDEX_NAME=anomaly-pegasus-summary TWELVE_LABS_MARENGO_MODEL=marengo3.0 TWELVE_LABS_PEGASUS_MODEL=pegasus1.2 # NVIDIA VSS NVIDIA_VSS_BASE_URL=http://localhost:8080 VSS_ENABLED=false # Model MODEL_NAME=MCG-NJU/videomae-base MODEL_SERVER_URL=http://localhost:9877 ANOMALY_THRESHOLD=0.15 ``` -------------------------------- ### Example LLM Generated Answer Source: https://qdrant.tech/documentation/examples/rag-chatbot-red-hat-openshift-haystack/index.md Shows a sample answer generated by the LLM based on the retrieved documents and the user's query about installing an application via the OpenShift web console. ```text Answer: To install an application using the OpenShift web console, follow these steps: 1. Select +Add on the left side of the web console. 2. Identify the container image to install. 3. Using your web browser, navigate to the Developer Sandbox for Red Hat OpenShift and select Start your Sandbox for free. 4. Install an application from source code stored in a GitHub repository using the OpenShift web console. ``` -------------------------------- ### Create Collection with Go Client Source: https://qdrant.tech/documentation/manage-data/collections Create a collection using the Go client. This example shows how to initialize the client and then create a collection with specified vector configuration. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.CreateCollection(context.Background(), &qdrant.CreateCollection{ CollectionName: "{collection_name}", VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{ Size: 100, Distance: qdrant.Distance_Cosine, }), }) ``` -------------------------------- ### Get Facet Counts with Filter (Rust) Source: https://qdrant.tech/documentation/manage-data/payload/index.md Use the Rust client to obtain facet counts, including a filter for specific criteria. This example demonstrates building a filter with a match condition. ```rust use qdrant_client::qdrant::{Condition, FacetCountsBuilder, Filter}; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; client .facet( FacetCountsBuilder::new("{collection_name}", "size") .limit(10) .filter(Filter::must(vec![Condition::matches( "color", "red".to_string(), )])) ) .await?; ``` -------------------------------- ### Create Collection with Binary Quantization (Go) Source: https://qdrant.tech/documentation/manage-data/quantization This Go example demonstrates creating a collection with binary quantization. It configures the client and sets `AlwaysRam` to `true` for the binary quantization. ```go import ( "context" "github.com/qdrant/go-client/qdrant" ) client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) client.CreateCollection(context.Background(), &qdrant.CreateCollection{ CollectionName: "{collection_name}", VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{ Size: 1536, Distance: qdrant.Distance_Cosine, }), QuantizationConfig: qdrant.NewQuantizationBinary( &qdrant.BinaryQuantization{ AlwaysRam: qdrant.PtrOf(true), }, ), }) ```