diff --git a/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.json index 224b4f11f..49b9e3a59 100644 --- a/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Milvus-Cluster mit Helm-Diagramm aufrüsten","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Milvus Helm Chart prüfen","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Durchführen eines rollenden Upgrades","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Upgrade von Milvus mit Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrieren Sie die Metadaten","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Milvus-Cluster mit Helm-Diagramm aufrüsten","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Milvus Helm Chart prüfen","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Durchführen eines rollenden Upgrades","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Upgrade von Milvus mit Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrieren Sie die Metadaten","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.md index 0fc2fadfe..8847bfdaa 100644 --- a/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/de/adminGuide/upgrade_milvus_cluster-helm.md @@ -23,7 +23,7 @@ title: Milvus-Cluster mit Helm-Diagramm aufrüsten d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

Diese Anleitung beschreibt, wie Sie Ihren Milvus-Cluster mit Milvus Helm Charts aufrüsten.

+

Diese Anleitung beschreibt, wie Sie Ihren Milvus-Cluster mit Milvus Helm-Charts aufrüsten.

Milvus Helm Chart prüfen
@@ -153,7 +153,7 @@ zilliztech/milvus 4.1.0 2.3.0 Milvus is an ope
helm repo update
 helm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here
 
-

Verwenden Sie die Helm-Diagrammversion im vorangegangenen Befehl. Einzelheiten dazu, wie Sie die Helm-Diagrammversion erhalten, finden Sie unter Prüfen der Milvus-Version.

+

Verwenden Sie die Helm-Diagrammversion im vorangegangenen Befehl. Einzelheiten dazu, wie Sie die Helm-Chart-Version erhalten, finden Sie unter Prüfen der Milvus-Version.

Migrieren Sie die Metadaten

Knowledge Table, entwickelt von WhyHow AI, ist ein Open-Source-Paket, das die Extraktion und Erkundung strukturierter Daten aus unstrukturierten Dokumenten erleichtern soll. Es bietet den Nutzern eine kalkulationsähnliche Oberfläche und ermöglicht die Erstellung von Wissensrepräsentationen, wie z. B. Tabellen und Diagramme, über eine natürlichsprachliche Abfrageoberfläche. Das Paket enthält anpassbare Extraktionsregeln, Formatierungsoptionen und die Rückverfolgbarkeit der Daten durch die Provenienz, wodurch es für verschiedene Anwendungen anpassbar ist. Es unterstützt die nahtlose Integration in RAG-Workflows und richtet sich sowohl an Geschäftsanwender, die eine benutzerfreundliche Oberfläche benötigen, als auch an Entwickler, die ein flexibles Backend für eine effiziente Dokumentenverarbeitung benötigen.

+

Standardmäßig verwendet Knowledge Table die Milvus-Datenbank, um die extrahierten Daten zu speichern und abzurufen. Dies ermöglicht es den Benutzern, die Daten mit Hilfe der leistungsstarken Funktionen von Milvus einfach zu suchen, zu filtern und zu analysieren. In diesem Tutorial zeigen wir Ihnen, wie Sie mit Knowledge Table und Milvus loslegen können.

+

Voraussetzungen

    +
  • Docker
  • +
  • Docker Compose
  • +
+

Klonen des Projekts

$ git clone https://github.com/whyhow-ai/knowledge-table.git
+
+

Einrichten der Umgebung

Sie finden die Datei .env.example im Stammverzeichnis des Projekts. Kopieren Sie diese Datei nach .env und tragen Sie die erforderlichen Umgebungsvariablen ein.

+

Für Milvus sollten Sie die Umgebungsvariablen MILVUS_DB_URI und MILVUS_DB_TOKEN setzen. Hier sind einige Tipps:

+
+
    +
  • Das Setzen von MILVUS_DB_URI als lokale Datei, z. B../milvus.db, ist die bequemste Methode, da Milvus Lite automatisch alle Daten in dieser Datei speichert.
  • +
  • Wenn Sie große Datenmengen haben, z. B. mehr als eine Million Vektoren, können Sie einen leistungsfähigeren Milvus-Server auf Docker oder Kubernetes einrichten. Bei dieser Einrichtung verwenden Sie bitte die Serveradresse und den Port als Uri, z. B.http://localhost:19530. Wenn Sie die Authentifizierungsfunktion auf Milvus aktivieren, verwenden Sie "<Ihr_Benutzername>:<Ihr_Passwort>" als Token, andernfalls setzen Sie das Token nicht.
  • +
  • Wenn Sie Zilliz Cloud, den vollständig verwalteten Cloud-Dienst für Milvus, verwenden möchten, passen Sie MILVUS_DB_URI und MILVUS_DB_TOKEN an, die dem öffentlichen Endpunkt und dem Api-Schlüssel in Zilliz Cloud entsprechen.
  • +
+
+

Neben Milvus sollten Sie auch andere Umgebungen einstellen, z.B. OPENAI_API_KEY. Diese können Sie von den jeweiligen Websites beziehen.

+

Starten der App

$ docker-compose up -d --build
+
+

Stoppen der App

$ docker-compose down
+
+

Zugriff auf das Projekt

Auf das Frontend kann unter http://localhost:3000 zugegriffen werden, auf das Backend unter http://localhost:8000.

+

+ + + + +

+

Sie können mit der Benutzeroberfläche herumspielen und Ihre eigenen Dokumente ausprobieren.

+

Weitere Beispiele für die Verwendung von Knowledge Table finden Sie in der offiziellen Dokumentation von Knowledge Table.

diff --git a/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..8b257d2b5 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Erste Schritte mit Mem0 und Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Vorbereitung","href":"Preparation","type":2,"isActive":false},{"label":"Verwaltung von Benutzerspeichern mit Mem0 und Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..aa11d2b12 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,218 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + In diesem Tutorial werden wir die grundlegenden + Mem0-Speicherverwaltungsoperationen zum Hinzufügen, Abrufen, Aktualisieren, + Suchen, Löschen und Verfolgen des Speicherverlaufs mit Milvus, einer + leistungsstarken Open-Source-Vektordatenbank, die eine effiziente Speicherung + und Abfrage ermöglicht, behandeln. Diese praktische Einführung führt Sie durch + die grundlegenden Speicheroperationen und hilft Ihnen, personalisierte + KI-Interaktionen mit Mem0 und Milvus zu erstellen. +title: Erste Schritte mit Mem0 und Milvus +--- +

Erste Schritte mit Mem0 und Milvus

+Open In Colab + + +GitHub Repository +

+

Mem0 ist eine intelligente Speicherebene für KI-Anwendungen, die personalisierte und effiziente Interaktionen ermöglicht, indem sie Benutzerpräferenzen speichert und sich im Laufe der Zeit kontinuierlich anpasst. Mem0 ist ideal für Chatbots und KI-gesteuerte Tools und schafft nahtlose, kontextbezogene Erlebnisse.

+

In diesem Tutorial werden wir die grundlegenden Mem0-Speicherverwaltungsvorgänge - Hinzufügen, Abrufen, Aktualisieren, Suchen, Löschen und Verfolgen des Speicherverlaufs - unter Verwendung von Milvus, einer leistungsstarken Open-Source-Vektordatenbank, die eine effiziente Speicherung und Abfrage ermöglicht, behandeln. Diese praktische Einführung führt Sie durch die grundlegenden Speicheroperationen und hilft Ihnen, personalisierte KI-Interaktionen mit Mem0 und Milvus zu erstellen.

+

Vorbereitung

Download der erforderlichen Bibliotheken

$ pip install mem0ai pymilvus
+
+
+

Wenn Sie Google Colab verwenden, müssen Sie möglicherweise die Runtime neu starten, um die soeben installierten Abhängigkeiten zu aktivieren (klicken Sie auf das Menü "Runtime" am oberen Rand des Bildschirms und wählen Sie "Sitzung neu starten" aus dem Dropdown-Menü).

+
+

Mem0 mit Milvus konfigurieren

Wir werden in diesem Beispiel OpenAI als LLM verwenden. Sie sollten den Api-Schlüssel OPENAI_API_KEY als Umgebungsvariable vorbereiten.

+
import os
+
+os.environ["OPENAI_API_KEY"] = "sk-***********"
+
+

Nun können wir Mem0 so konfigurieren, dass es Milvus als Vektorspeicher verwendet

+
# Define Config
+from mem0 import Memory
+
+config = {
+    "vector_store": {
+        "provider": "milvus",
+        "config": {
+            "collection_name": "quickstart_mem0_with_milvus",
+            "embedding_model_dims": "1536",
+            "url": "./milvus.db",  # Use local vector database for demo purpose
+        },
+    },
+    "version": "v1.1",
+}
+
+m = Memory.from_config(config)
+
+
+
+
    +
  • Wenn Sie nur eine lokale Vektordatenbank für kleine Datenmengen oder Prototypen benötigen, ist die Einstellung der Uri als lokale Datei, z. B../milvus.db, die bequemste Methode, da sie automatisch Milvus Lite verwendet, um alle Daten in dieser Datei zu speichern.
  • +
  • Wenn Sie große Datenmengen haben, z. B. mehr als eine Million Vektoren, können Sie einen leistungsfähigeren Milvus-Server auf Docker oder Kubernetes einrichten. Bei dieser Einrichtung verwenden Sie bitte die Serveradresse und den Port als Uri, z. B.http://localhost:19530. Wenn Sie die Authentifizierungsfunktion auf Milvus aktivieren, verwenden Sie "<Ihr_Benutzername>:<Ihr_Passwort>" als Token, andernfalls setzen Sie das Token nicht.
  • +
  • Wenn Sie Zilliz Cloud, den vollständig verwalteten Cloud-Service für Milvus, verwenden, passen Sie uri und token an, die dem öffentlichen Endpunkt und dem API-Schlüssel in Zilliz Cloud entsprechen.
  • +
+
+
+

Verwaltung von Benutzerspeichern mit Mem0 und Milvus

Hinzufügen eines Speichers

Die Funktion add speichert unstrukturierten Text in Milvus als Speicher und verknüpft ihn mit einem bestimmten Benutzer und optionalen Metadaten.

+

Hier fügen wir Alices Erinnerung "Ich arbeite an der Verbesserung meiner Tennisfähigkeiten" zusammen mit relevanten Metadaten für den Kontext zu Milvus hinzu.

+
# Add a memory to user: Working on improving tennis skills
+res = m.add(
+    messages="I am working on improving my tennis skills.",
+    user_id="alice",
+    metadata={"category": "hobbies"},
+)
+
+res
+
+
{'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+   'memory': 'Working on improving tennis skills',
+   'event': 'ADD'}],
+ 'relations': []}
+
+

Aktualisieren einer Erinnerung

Wir können den Rückgabewert der Funktion add verwenden, um die Speicher-ID abzurufen, so dass wir diesen Speicher mit neuen Informationen über update aktualisieren können.

+
# Get memory_id
+memory_id = res["results"][0]["id"]
+
+# Update this memory with new information: Likes to play tennis on weekends
+m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
+
+
{'message': 'Memory updated successfully!'}
+
+

Alle Speicher für einen Benutzer abrufen

Mit der Funktion get_all können wir alle eingefügten Speicher anzeigen oder nach user_id in Milvus filtern.

+

Wie wir sehen, hat sich die Erinnerung von "Ich arbeite daran, meine Tennisfähigkeiten zu verbessern" in "Ich spiele am Wochenende gerne Tennis" geändert.

+
# Get all memory for the user Alice
+m.get_all(user_id="alice")
+
+
{'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+   'memory': 'Likes to play tennis on weekends',
+   'hash': '4c3bc9f87b78418f19df6407bc86e006',
+   'metadata': None,
+   'created_at': '2024-11-01T19:33:44.116920-07:00',
+   'updated_at': '2024-11-01T19:33:47.619857-07:00',
+   'user_id': 'alice'}]}
+
+

Verlauf der Speicheraktualisierung anzeigen

Wir können uns auch den Verlauf der Speicheraktualisierung ansehen, indem wir mit der Funktion history angeben, an welcher memory_id wir interessiert sind.

+
m.history(memory_id=memory_id)
+
+
[{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
+  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+  'old_memory': None,
+  'new_memory': 'Working on improving tennis skills',
+  'event': 'ADD',
+  'created_at': '2024-11-01T19:33:44.116920-07:00',
+  'updated_at': None},
+ {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
+  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+  'old_memory': 'Working on improving tennis skills',
+  'new_memory': 'Likes to play tennis on weekends',
+  'event': 'UPDATE',
+  'created_at': '2024-11-01T19:33:44.116920-07:00',
+  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
+
+

Speicher suchen

Mit der Funktion search können wir nach dem für den Benutzer relevantesten Speicherplatz suchen.

+

Beginnen wir mit dem Hinzufügen eines weiteren Speichers für Alice.

+
new_mem = m.add(
+    "I have a linear algebra midterm exam on November 20",
+    user_id="alice",
+    metadata={"category": "task"},
+)
+
+

Nun rufen wir get_all unter Angabe der user_id auf, um zu überprüfen, ob wir tatsächlich 2 Speichereinträge für den Benutzer Alice haben.

+
m.get_all(user_id="alice")
+
+
{'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+   'memory': 'Likes to play tennis on weekends',
+   'hash': '4c3bc9f87b78418f19df6407bc86e006',
+   'metadata': None,
+   'created_at': '2024-11-01T19:33:44.116920-07:00',
+   'updated_at': '2024-11-01T19:33:47.619857-07:00',
+   'user_id': 'alice'},
+  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
+   'memory': 'Has a linear algebra midterm exam on November 20',
+   'hash': '575182f46965111ca0a8279c44920ea2',
+   'metadata': {'category': 'task'},
+   'created_at': '2024-11-01T19:33:57.271657-07:00',
+   'updated_at': None,
+   'user_id': 'alice'}]}
+
+

Wir können nun search ausführen, indem wir query und user_id bereitstellen. Beachten Sie, dass wir standardmäßig die Metrik L2 für die Ähnlichkeitssuche verwenden, so dass eine kleinere score eine größere Ähnlichkeit bedeutet.

+
m.search(query="What are Alice's hobbies", user_id="alice")
+
+
{'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
+   'memory': 'Likes to play tennis on weekends',
+   'hash': '4c3bc9f87b78418f19df6407bc86e006',
+   'metadata': None,
+   'score': 1.2807445526123047,
+   'created_at': '2024-11-01T19:33:44.116920-07:00',
+   'updated_at': '2024-11-01T19:33:47.619857-07:00',
+   'user_id': 'alice'},
+  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
+   'memory': 'Has a linear algebra midterm exam on November 20',
+   'hash': '575182f46965111ca0a8279c44920ea2',
+   'metadata': {'category': 'task'},
+   'score': 1.728922724723816,
+   'created_at': '2024-11-01T19:33:57.271657-07:00',
+   'updated_at': None,
+   'user_id': 'alice'}]}
+
+

Speicher löschen

Wir können auch delete einen Speicher löschen, indem wir die entsprechende memory_id angeben.

+

Wir löschen den Speicher "Spielt am Wochenende gerne Tennis", da sein memory_id bereits abgerufen wurde, und rufen get_all auf, um zu überprüfen, ob die Löschung erfolgreich war.

+
m.delete(memory_id=memory_id)
+
+m.get_all("alice")
+
+
{'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
+   'memory': 'Has a linear algebra midterm exam on November 20',
+   'hash': '575182f46965111ca0a8279c44920ea2',
+   'metadata': {'category': 'task'},
+   'created_at': '2024-11-01T19:33:57.271657-07:00',
+   'updated_at': None,
+   'user_id': 'alice'}]}
+
diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..cf67ad9b4 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Verwenden Sie Milvus in DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Anforderungen","href":"Requirements","type":2,"isActive":false},{"label":"Klonen Sie das Repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Add dependency","href":"Add-dependency","type":2,"isActive":false},{"label":"Umgebungsvariablen setzen","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Starten Sie die Dienste","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..74c5b5051 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,142 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + In diesem Tutorial zeigen wir Ihnen, wie Sie Milvus als + Backend-Vektordatenbank für DocsGPT verwenden können. +title: Verwenden Sie Milvus in DocsGPT +--- +

Verwenden Sie Milvus in DocsGPT

DocsGPT ist eine fortschrittliche Open-Source-Lösung, die das Auffinden von Informationen in der Projektdokumentation durch die Integration leistungsstarker GPT-Modelle vereinfacht. Sie ermöglicht es Entwicklern, auf einfache Weise genaue Antworten auf ihre Fragen zu einem Projekt zu erhalten, wodurch zeitaufwändige manuelle Suchen vermieden werden.

+

In diesem Tutorial zeigen wir Ihnen, wie Sie Milvus als Backend-Vektor-Datenbank für DocsGPT verwenden.

+
+

Dieses Tutorial bezieht sich hauptsächlich auf die offizielle DocsGPT-Installationsanleitung. Wenn Sie feststellen, dass diese Anleitung veraltete Teile enthält, können Sie vorrangig die offizielle Anleitung befolgen und eine Anfrage an uns stellen.

+
+

Anforderungen

Stellen Sie sicher, dass Sie Docker installiert haben

+

Klonen Sie das Repository

Klonen Sie das Repository und navigieren Sie zu ihm:

+
$ git clone https://github.com/arc53/DocsGPT.git
+$ cd DocsGPT
+
+

Add dependency

Fügen Sie die Abhängigkeit langchain-milvus an die Datei requirements.txt im Ordner application an:

+
$ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
+
+

Umgebungsvariablen setzen

Fügen Sie VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... zu den Umgebungsvariablen für die beiden Dienste backend und worker in der Datei docker-compose.yaml hinzu, genau so:

+
  backend:
+    build: ./application
+    environment:
+      - VECTOR_STORE=milvus
+      - MILVUS_URI=...
+      - MILVUS_TOKEN=...
+
+
  worker:
+    build: ./application
+    command: celery -A application.app.celery worker -l INFO -B
+    environment:
+      - VECTOR_STORE=milvus
+      - MILVUS_URI=...
+      - MILVUS_TOKEN=...
+
+

Für die Dienste MILVUS_URI und MILVUS_TOKEN können Sie entweder den vollständig verwalteten Dienst Zilliz Cloud(empfohlen) oder den manuell gestarteten Dienst Milvus verwenden.

+
    +
  • Für den vollständig verwalteten Zillz Cloud-Dienst: Wir empfehlen die Verwendung des Zilliz-Cloud-Dienstes. Sie können sich für ein kostenloses Testkonto bei Zilliz Cloud anmelden. Danach erhalten Sie die MILVUS_URI und MILVUS_TOKEN, die dem öffentlichen Endpunkt und dem API-Schlüssel entsprechen.

  • +
  • Für manuell gestartete Milvus-Dienste: Wenn Sie einen Milvus-Dienst einrichten möchten, können Sie der offiziellen Milvus-Dokumentation folgen, um einen Milvus-Server einzurichten, und dann die MILVUS_URI und MILVUS_TOKEN vom Server abrufen. Die Dateien MILVUS_URI und MILVUS_TOKEN sollten das Format http://<your_server_ip>:19530 bzw. <your_username>:<your_password> haben.

  • +
+

Starten Sie die Dienste

Ausführen: ./setup.sh

+

Navigieren Sie dann zu http://localhost:5173/.

+

Sie können mit der Benutzeroberfläche herumspielen und Fragen zu Ihren Dokumenten stellen.

+

+ + alt text + Alt-Text

+

Wenn Sie die Dienste stoppen wollen, führen Sie aus:

+
$ docker-compose down
+
+

Weitere Details und fortgeschrittene Einstellungen finden Sie in der offiziellen DocsGPT-Dokumentation.

diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.json b/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.json index 494dc1876..fcdb3afee 100644 --- a/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.json +++ b/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.json @@ -1 +1 @@ -{"codeList":["$ git clone https://github.com/zylon-ai/private-gpt\n$ cd private-gpt\n","$ brew install make\n","$ choco install make\n","$ poetry install --extras \"llms-ollama embeddings-ollama vector-stores-milvus ui\"\n","$ ollama serve\n","$ ollama pull llama3.1\n$ ollama pull nomic-embed-text\n","vectorstore:\n database: milvus\n","milvus:\n uri: http://localhost:19530\n collection_name: my_collection\n","PGPT_PROFILES=ollama make run\n"],"headingContent":"Use Milvus in PrivateGPT","anchorList":[{"label":"Milvus in PrivateGPT verwenden","href":"Use-Milvus-in-PrivateGPT","type":1,"isActive":false},{"label":"Grundvoraussetzungen für den Betrieb von PrivateGPT","href":"Base-requirements-to-run-PrivateGPT","type":2,"isActive":false},{"label":"Verfügbare Module installieren","href":"Install-Available-Modules","type":2,"isActive":false},{"label":"Ollama-Dienst starten","href":"Start-Ollama-service","type":2,"isActive":false},{"label":"Milvus-Einstellungen ändern","href":"Change-Milvus-Settings","type":2,"isActive":false},{"label":"PrivateGPT starten","href":"Start-PrivateGPT","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ git clone https://github.com/zylon-ai/private-gpt\n$ cd private-gpt\n","$ brew install make\n","$ choco install make\n","$ poetry install --extras \"llms-ollama embeddings-ollama vector-stores-milvus ui\"\n","$ ollama serve\n","$ ollama pull llama3.1\n$ ollama pull nomic-embed-text\n","vectorstore:\n database: milvus\n","milvus:\n uri: http://localhost:19530\n collection_name: my_collection\n","PGPT_PROFILES=ollama make run\n"],"headingContent":"Use Milvus in PrivateGPT","anchorList":[{"label":"Milvus in PrivateGPT verwenden","href":"Use-Milvus-in-PrivateGPT","type":1,"isActive":false},{"label":"Grundvoraussetzungen für den Betrieb von PrivateGPT","href":"Base-requirements-to-run-PrivateGPT","type":2,"isActive":false},{"label":"Verfügbare Module installieren","href":"Install-Available-Modules","type":2,"isActive":false},{"label":"Starten Sie den Ollama-Dienst","href":"Start-Ollama-service","type":2,"isActive":false},{"label":"Milvus-Einstellungen ändern","href":"Change-Milvus-Settings","type":2,"isActive":false},{"label":"PrivateGPT starten","href":"Start-PrivateGPT","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.md index eaea421f6..4035ec024 100644 --- a/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/de/integrations/use_milvus_in_private_gpt.md @@ -67,16 +67,18 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

PrivateGPT erlaubt die Anpassung des Setups. Wir müssen einige Modul-Einstellungen festlegen. In diesem Tutorial werden wir die folgenden Module verwenden:

+

PrivateGPT erlaubt die Anpassung des Setups für einige Module, z.B. LLM, Embeddings, Vector Stores, UI.

+

In diesem Tutorium werden wir die folgenden Module verwenden:

  • LLM: Ollama
  • Einbettungen: Ollama
  • -
  • Vektor-Speicher: Milvus
  • +
  • Vektorspeicher: Milvus
  • UI: Gradio
+

Führen Sie den folgenden Befehl aus, um mit Hilfe von poetry die erforderlichen Modulabhängigkeiten zu installieren:

$ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
 
-

Ollama-Dienst starten

Gehen Sie zu ollama.ai und folgen Sie den Anweisungen, um Ollama auf Ihrem Rechner zu installieren.

Nach der Installation stellen Sie sicher, dass die Ollama-Desktop-Anwendung geschlossen ist.

-

Starten Sie nun den Ollama-Dienst (es wird ein lokaler Inferenz-Server gestartet, der sowohl die LLM als auch die Embeddings bedient):

+

Starten Sie nun den Ollama-Dienst (es wird ein lokaler Inferenz-Server gestartet, der sowohl den LLM als auch die Einbettungen bedient):

$ ollama serve
 
-

Installieren Sie die zu verwendenden Modelle. settings-ollama.yaml ist standardmäßig auf den Benutzer llama3.1 8b LLM (~4GB) und nomic-embed-text Embeddings (~275MB) konfiguriert.

+

Installieren Sie die zu verwendenden Modelle. settings-ollama.yaml ist standardmäßig auf den Benutzer llama3.1 8b LLM (~4GB) und nomic-embed-text Embeddings (~275MB) konfiguriert.

Standardmäßig zieht PrivateGPT die Modelle automatisch nach Bedarf. Dieses Verhalten kann durch Ändern der Eigenschaft ollama.autopull_models geändert werden.

-

Wenn Sie die Modelle jedoch manuell abrufen möchten, führen Sie die folgenden Befehle aus:

+

Wenn Sie die Modelle manuell abrufen möchten, führen Sie die folgenden Befehle aus:

$ ollama pull llama3.1
 $ ollama pull nomic-embed-text
 
@@ -133,8 +135,8 @@ $ ollama pull nomic-embed-text Feld OptionBeschreibung -uriStandardmäßig ist "local_data/private_gpt/milvus/milvus_local.db" als lokale Datei eingestellt; Sie können auch einen leistungsfähigeren Milvus-Server auf Docker oder k8s, z. B. http://localhost:19530, als Ihre uri einrichten; Um Zilliz Cloud zu verwenden, passen Sie die uri und das Token an Endpoint und Api-Schlüssel in Zilliz Cloud an. -TokenPair mit Milvus Server auf Docker oder k8s oder Zilliz Cloud Api Schlüssel. +uriStandardmäßig ist "local_data/private_gpt/milvus/milvus_local.db" als lokale Datei eingestellt; Sie können auch einen leistungsfähigeren Milvus-Server auf Docker oder k8s, z. B. http://localhost:19530, als Ihre uri einrichten; Um Zilliz Cloud zu verwenden, passen Sie die uri und das Token an den öffentlichen Endpunkt und den API-Schlüssel in Zilliz Cloud an. +TokenPair mit Milvus Server auf Docker oder k8s oder Zilliz Cloud api key. sammlung_nameDer Name der Sammlung, standardmäßig auf "milvus_db" eingestellt. überschreibenÜberschreibt die Daten in der Sammlung, falls vorhanden, standardmäßig auf True gesetzt. @@ -154,10 +156,10 @@ $ ollama pull nomic-embed-text d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

Sobald alle Einstellungen vorgenommen sind, können Sie PrivateGPT mit einer gradio-Benutzeroberfläche starten.

+

Sobald alle Einstellungen vorgenommen wurden, können Sie PrivateGPT mit einer Gradio-Benutzeroberfläche starten.

PGPT_PROFILES=ollama make run
 
-

Die UI wird unterhttp://0.0.0.0:8001 verfügbar sein.

+

Die UI wird unter http://0.0.0.0:8001 verfügbar sein.

@@ -165,3 +167,4 @@ $ ollama pull nomic-embed-text

Sie können mit der UI herumspielen und Fragen zu Ihren Dokumenten stellen.

+

Weitere Details finden Sie in der offiziellen PrivateGPT-Dokumentation.

diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..ee08666d5 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Verwenden Sie Milvus mit SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Voraussetzungen","href":"Prerequisites","type":2,"isActive":false},{"label":"Klonen Sie das Repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Ändern Sie den Typ des Vektorspeichers","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Installieren Sie Abhängigkeiten","href":"Install-dependencies","type":2,"isActive":false},{"label":"Starten Sie die Anwendung","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..f4def3e63 --- /dev/null +++ b/localization/v2.4.x/site/de/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,135 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + Dieses Tutorial nutzt die Milvus-Integration in den SambaNova AI Starter Kits, + um ein Enterprise Knowledge Retrieval System, ähnlich wie RAG + (Retrieval-Augmented Generation), für das Retrieval und die Beantwortung von + Fragen auf Basis der privaten Dokumente des Unternehmens zu erstellen. +title: Verwenden Sie Milvus mit SambaNova +--- +

Verwenden Sie Milvus mit SambaNova

SambaNova ist eine innovative KI-Technologieplattform, die den Einsatz fortschrittlicher KI- und Deep-Learning-Funktionen beschleunigt. Sie wurde für den Einsatz in Unternehmen entwickelt und ermöglicht es Organisationen, generative KI für mehr Leistung und Effizienz zu nutzen. Durch die Bereitstellung von Spitzenlösungen wie der SambaNova Suite und DataScale ermöglicht die Plattform Unternehmen, wertvolle Erkenntnisse aus ihren Daten zu gewinnen, betriebliche Verbesserungen voranzutreiben und neue Möglichkeiten in der KI-Landschaft zu fördern.

+

Die SambaNova AI Starter Kits sind eine Sammlung von Open-Source-Ressourcen, die Entwicklern und Unternehmen bei der Implementierung von KI-gesteuerten Anwendungen mit SambaNova helfen sollen. Diese Kits enthalten praktische Beispiele und Anleitungen, die die Implementierung verschiedener KI-Anwendungsfälle erleichtern und es den Benutzern ermöglichen, die fortschrittliche Technologie von SambaNova zu nutzen.

+

Dieses Tutorial nutzt die Milvus-Integration in den SambaNova AI Starter Kits, um ein Enterprise Knowledge Retrieval System, ähnlich wie RAG (Retrieval-Augmented Generation), für das Retrieval und die Beantwortung von Fragen auf Basis der privaten Dokumente des Unternehmens zu erstellen.

+
+

Dieses Tutorial bezieht sich hauptsächlich auf das offizielle SambaNova AI Starter Kits Handbuch. Wenn Sie feststellen, dass dieses Tutorial veraltete Teile enthält, können Sie sich vorrangig an die offizielle Anleitung halten und eine Anfrage an uns stellen.

+
+

Voraussetzungen

Wir empfehlen die Verwendung von Python >= 3.10 und < 3.12.

+

Besuchen Sie die SambaNova Cloud, um einen SambaNova API Schlüssel zu erhalten.

+

Klonen Sie das Repository

$ git clone https://github.com/sambanova/ai-starter-kit.git
+$ d ai-starter-kit/enterprise_knowledge_retriever
+
+

Ändern Sie den Typ des Vektorspeichers

Ändern Sie den Vektorspeicher, indem Sie db_type='milvus' in den Funktionen create_vector_store() und load_vdb() in src/document_retrieval.py einstellen.

+
...
+vectorstore = self.vectordb.create_vector_store(
+    ..., db_type='milvus'
+)
+...
+vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
+
+

Installieren Sie Abhängigkeiten

Installieren Sie die erforderlichen Abhängigkeiten, indem Sie den folgenden Befehl ausführen:

+
python3 -m venv enterprise_knowledge_env
+source enterprise_knowledge_env/bin/activate
+pip install -r requirements.txt
+
+

Starten Sie die Anwendung

Verwenden Sie den folgenden Befehl, um die Anwendung zu starten:

+
$ streamlit run streamlit/app.py --browser.gatherUsageStats false 
+
+

Danach sehen Sie die Benutzeroberfläche in Ihrem Browser:http://localhost:8501/

+

+ + + + +

+

Nachdem Sie Ihren SambaNova-API-Schlüssel in der Benutzeroberfläche festgelegt haben, können Sie mit der Benutzeroberfläche spielen und Fragen zu Ihren Dokumenten stellen.

+

Weitere Details finden Sie in der offiziellen Dokumentation zum Enterprise Knowledge Retrieval des SambaNova AI Starter Kits.

diff --git a/localization/v2.4.x/site/de/menuStructure/de.json b/localization/v2.4.x/site/de/menuStructure/de.json index b02513a73..5731de6fa 100644 --- a/localization/v2.4.x/site/de/menuStructure/de.json +++ b/localization/v2.4.x/site/de/menuStructure/de.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "Benutzer und Rollen", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "In-Memory-Replik", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "Benutzer, Privilegien und Rollen", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "RBAC einschalten", "id": "rbac.md", @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivatGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Wissenstabelle", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Trichtersuche mit Matrjoschka-Einbettungen", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "Mehr erforschen", "id": "explore-more", diff --git a/localization/v2.4.x/site/de/reference/disk_index.md b/localization/v2.4.x/site/de/reference/disk_index.md index 331d2abb8..40d86ca11 100644 --- a/localization/v2.4.x/site/de/reference/disk_index.md +++ b/localization/v2.4.x/site/de/reference/disk_index.md @@ -47,7 +47,7 @@ Derzeit unterstützt ein Vektorfeld nur einen Index-Typ. Milvus löscht automati
  • Die Milvus-Instanz läuft auf Ubuntu 18.04.6 oder einer späteren Version.
  • Der Milvus-Datenpfad sollte auf eine NVMe-SSD gemountet werden, um die volle Leistung zu erreichen:
    • Bei einer Milvus-Einzelinstanz sollte der Datenpfad /var/lib/milvus/data in dem Container sein, in dem die Instanz läuft.
    • -
    • Für eine Milvus-Cluster-Instanz sollte der Datenpfad /var/lib/milvus/data in den Containern sein, in denen die QueryNodes und IndexNodes laufen.
    • +
    • Für eine Milvus-Cluster-Instanz sollte der Datenpfad /var/lib/milvus/data in den Containern sein, in denen die QueryNodes und IndexNodes ausgeführt werden.
  • Begrenzungen

    Im Folgenden werden die Vorteile von Knowhere gegenüber Faiss beschrieben.

    +

    Im Folgenden sind die Vorteile von Knowhere gegenüber Faiss aufgeführt.

    Unterstützung für BitsetView

    Milvus führt einen Bitset-Mechanismus ein, um "soft deletion" zu realisieren. Ein sanft gelöschter Vektor existiert noch in der Datenbank, wird aber bei einer Vektorähnlichkeitssuche oder -abfrage nicht berechnet.

    Jedes Bit in einem Bitset entspricht einem indizierten Vektor. Wenn ein Vektor im Bitset mit "1" markiert ist, bedeutet dies, dass dieser Vektor "soft-deleted" ist und bei einer Vektorsuche nicht berücksichtigt wird. Der Bitset-Parameter wird auf alle exponierten Faiss-Indexabfrage-APIs in Knowhere angewendet, einschließlich CPU- und GPU-Indizes.

    Weitere Informationen über den Bitset-Mechanismus finden Sie unter Bitset.

    Unterstützung für mehrere Ähnlichkeitsmetriken zur Indizierung binärer Vektoren

    Knowhere unterstützt Hamming, Jaccard, Tanimoto, Superstructure, und Substructure. Jaccard und Tanimoto können verwendet werden, um die Ähnlichkeit zwischen zwei Mustersätzen zu messen, während Superstructure und Substructure verwendet werden können, um die Ähnlichkeit von chemischen Strukturen zu messen.

    Unterstützung für AVX512-Befehlssatz

    Neben AArch64, SSE4.2 und AVX2, den bereits von Faiss unterstützten Befehlssätzen, unterstützt Knowhere auch AVX512, was die Leistung der Indexerstellung und -abfrage um 20 bis 30 % im Vergleich zu AVX2 verbessern kann.

    Automatische SIMD-Befehlsauswahl

    Knowhere unterstützt den automatischen Aufruf der geeigneten SIMD-Befehle (z. B. SIMD SSE, AVX, AVX2 und AVX512) auf jedem CPU-Prozessor (sowohl vor Ort als auch auf Cloud-Plattformen), so dass die Benutzer das SIMD-Flag (z. B. "-msse4") während der Kompilierung nicht manuell angeben müssen.

    -

    Knowhere wird durch Refactoring der Codebasis von Faiss erstellt. Gängige Funktionen (z. B. Ähnlichkeitsberechnungen), die auf SIMD-Beschleunigung angewiesen sind, werden ausgegliedert. Dann werden für jede Funktion vier Versionen (d.h. SSE, AVX, AVX2, AVX512) implementiert und jeweils in eine separate Quelldatei geschrieben. Anschließend werden die Quelldateien einzeln mit dem entsprechenden SIMD-Flag weiter kompiliert. Daher kann Knowhere zur Laufzeit automatisch die am besten geeigneten SIMD-Anweisungen auf der Grundlage der aktuellen CPU-Flags auswählen und dann die richtigen Funktionszeiger mit Hooking verknüpfen.

    +

    Knowhere wird durch Refactoring der Codebasis von Faiss erstellt. Gängige Funktionen (z. B. Ähnlichkeitsberechnungen), die auf SIMD-Beschleunigung angewiesen sind, werden ausgegliedert. Dann werden für jede Funktion vier Versionen (d.h. SSE, AVX, AVX2, AVX512) implementiert und jede in eine separate Quelldatei gestellt. Anschließend werden die Quelldateien einzeln mit dem entsprechenden SIMD-Flag weiter kompiliert. Daher kann Knowhere zur Laufzeit automatisch die am besten geeigneten SIMD-Anweisungen auf der Grundlage der aktuellen CPU-Flags auswählen und dann die richtigen Funktionszeiger mit Hooking verknüpfen.

    Andere Leistungsoptimierungen

    Lesen Sie Milvus: A Purpose-Built Vector Data Management System für weitere Informationen über die Leistungsoptimierung von Knowhere.

    Knowhere-Code-Struktur

    • Automatische Indizierung: Milvus entscheidet automatisch über den Indextyp, basierend auf dem Datentyp des skalaren Feldes. Dies ist geeignet, wenn Sie den spezifischen Indextyp nicht kontrollieren müssen.

    • -
    • Benutzerdefinierte Indizierung: Sie geben den genauen Indextyp an, z. B. einen invertierten Index. Damit haben Sie mehr Kontrolle über die Auswahl des Indextyps.

    • +
    • Benutzerdefinierte Indizierung: Sie geben den genauen Indextyp an, z. B. einen invertierten Index. Dadurch haben Sie mehr Kontrolle über die Auswahl des Indextyps.

    Automatische Indizierung

    Nachdem Sie AnnSearchRequest Instanzen erstellt haben, konfigurieren Sie eine Reranking-Strategie, um die Ergebnisse zu kombinieren und neu zu ordnen. Derzeit gibt es zwei Optionen: WeightedRanker und RRFRanker. Weitere Informationen zu Ranking-Strategien finden Sie unter Reranking.

    • Gewichtetes Scoring verwenden

      -

      Die WeightedRanker wird verwendet, um den Ergebnissen aus jeder Vektorfeldsuche mit bestimmten Gewichtungen Bedeutung zuzuweisen. Wenn Sie einige Vektorfelder gegenüber anderen bevorzugen, kann WeightedRanker(value1, value2, ..., valueN) dies in den kombinierten Suchergebnissen widerspiegeln.

      +

      Die WeightedRanker wird verwendet, um den Ergebnissen aus jeder Vektorfeldsuche mit bestimmten Gewichten eine Bedeutung zuzuweisen. Wenn Sie einige Vektorfelder gegenüber anderen bevorzugen, kann WeightedRanker(value1, value2, ..., valueN) dies in den kombinierten Suchergebnissen widerspiegeln.

      from pymilvus import WeightedRanker
       # Use WeightedRanker to combine results with specified weights
       # Assign weights of 0.8 to text search and 0.2 to image search
      @@ -276,11 +276,11 @@ res = collection.hybrid_search(
             
           
      • In welchem Szenario ist die hybride Suche zu empfehlen?

        -

        Die hybride Suche ist ideal für komplexe Situationen, die eine hohe Genauigkeit erfordern, insbesondere wenn eine Entität durch mehrere, unterschiedliche Vektoren dargestellt werden kann. Dies gilt für Fälle, in denen dieselben Daten, wie z. B. ein Satz, durch verschiedene Einbettungsmodelle verarbeitet werden oder wenn multimodale Informationen (wie Bilder, Fingerabdrücke und Stimmabdrücke einer Person) in verschiedene Vektorformate umgewandelt werden. Durch die Zuweisung von Gewichten zu diesen Vektoren kann ihr kombinierter Einfluss die Wiederauffindbarkeit deutlich erhöhen und die Effizienz der Suchergebnisse verbessern.

      • +

        Die hybride Suche ist ideal für komplexe Situationen, die eine hohe Genauigkeit erfordern, insbesondere wenn eine Entität durch mehrere, unterschiedliche Vektoren dargestellt werden kann. Dies gilt für Fälle, in denen dieselben Daten, wie z. B. ein Satz, durch verschiedene Einbettungsmodelle verarbeitet werden oder wenn multimodale Informationen (wie Bilder, Fingerabdrücke und Stimmabdrücke einer Person) in verschiedene Vektorformate umgewandelt werden. Durch die Zuweisung von Gewichtungen für diese Vektoren kann ihr kombinierter Einfluss die Wiederauffindbarkeit erheblich steigern und die Effizienz der Suchergebnisse verbessern.

      • Wie normalisiert ein gewichteter Ranker die Abstände zwischen verschiedenen Vektorfeldern?

        Ein gewichteter Ranker normalisiert die Abstände zwischen Vektorfeldern anhand der jedem Feld zugewiesenen Gewichte. Er berechnet die Wichtigkeit jedes Vektorfeldes entsprechend seiner Gewichtung und gibt den Feldern mit höherer Gewichtung den Vorrang. Es ist ratsam, für alle ANN-Suchanfragen denselben metrischen Typ zu verwenden, um Konsistenz zu gewährleisten. Diese Methode stellt sicher, dass Vektoren, die als wichtiger eingestuft werden, einen größeren Einfluss auf das Gesamtranking haben.

      • Ist es möglich, alternative Ranker wie Cohere Ranker oder BGE Ranker zu verwenden?

        -

        Derzeit werden nur die angebotenen Ranker unterstützt. Es ist geplant, in zukünftigen Updates weitere Ranker einzubeziehen.

      • +

        Derzeit werden nur die angebotenen Ranker unterstützt. Für künftige Updates ist die Aufnahme weiterer Ranker geplant.

      • Ist es möglich, mehrere hybride Suchvorgänge gleichzeitig auszuführen?

        Ja, die gleichzeitige Ausführung von mehreren hybriden Suchoperationen wird unterstützt.

      • Kann ich das gleiche Vektorfeld in mehreren AnnSearchRequest-Objekten verwenden, um hybride Suchvorgänge durchzuführen?

        diff --git a/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.json index af3d69f7f..5bf9c03b8 100644 --- a/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Einzelvektor-Suche","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Überblick","href":"Overview","type":2,"isActive":false},{"label":"Vorbereitungen","href":"Preparations","type":2,"isActive":false},{"label":"Einfache Suche","href":"Basic-search","type":2,"isActive":false},{"label":"Gefilterte Suche","href":"Filtered-search","type":2,"isActive":false},{"label":"Bereichssuche","href":"Range-search","type":2,"isActive":false},{"label":"Gruppierungssuche","href":"Grouping-search","type":2,"isActive":false},{"label":"Suchparameter","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Einzelvektor-Suche","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Überblick","href":"Overview","type":2,"isActive":false},{"label":"Vorbereitungen","href":"Preparations","type":2,"isActive":false},{"label":"Einfache Suche","href":"Basic-search","type":2,"isActive":false},{"label":"Gefilterte Suche","href":"Filtered-search","type":2,"isActive":false},{"label":"Bereichssuche","href":"Range-search","type":2,"isActive":false},{"label":"Gruppierungssuche","href":"Grouping-search","type":2,"isActive":false},{"label":"Suchparameter","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.md index 9e870c1de..912c675e4 100644 --- a/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/de/userGuide/search-query-get/single-vector-search.md @@ -68,10 +68,12 @@ title: Einzelvektor-Suche

        Das folgende Codeschnipsel verwendet den bestehenden Code weiter, um eine Verbindung zu Milvus herzustellen und eine Sammlung schnell einzurichten.

        -
        # 1. Set up a Milvus client
        +
        from pymilvus import MilvusClient
        +import random
        +
        +# 1. Set up a Milvus client
         client = MilvusClient(
        -    uri=CLUSTER_ENDPOINT,
        -    token=TOKEN 
        +    uri="http://localhost:19530"
         )
         
         # 2. Create a collection
        @@ -449,7 +451,7 @@ res = await client.Python  Java Node.js
         
        # Single vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             # Replace with your query vector
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
        @@ -643,7 +645,7 @@ res = await client.Python  Java Node.js
         
        # Bulk-vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[
                 [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
                 [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
        @@ -1228,7 +1230,7 @@ searchResp = client.search(searchReq);
            Python  Java Node.js
         
        # Search with output fields
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1365,7 +1367,7 @@ res = await client.'like "%suffix"'.

      Bei der Suche nach einzelnen Zeichen dient der Unterstrich (_) als Platzhalter für ein Zeichen, z. B. 'like "y_llow"'.

      -

      Sonderzeichen in Suchzeichenfolgen

      Wenn Sie nach einer Zeichenkette suchen wollen, die Sonderzeichen wie Unterstriche (_) oder Prozentzeichen (%) enthält, die normalerweise als Platzhalter in Suchmustern verwendet werden (_ für ein einzelnes Zeichen und % für eine beliebige Folge von Zeichen), müssen Sie diese Zeichen mit einem Escapezeichen versehen, um sie als literale Zeichen zu behandeln. Verwenden Sie einen Backslash (\), um Sonderzeichen zu entschlüsseln, und denken Sie daran, den Backslash selbst zu entschlüsseln. Ein Beispiel:

      +

      Sonderzeichen in Suchzeichenketten

      Wenn Sie nach einer Zeichenkette suchen wollen, die Sonderzeichen wie Unterstriche (_) oder Prozentzeichen (%) enthält, die normalerweise als Platzhalter in Suchmustern verwendet werden (_ für ein einzelnes Zeichen und % für eine beliebige Folge von Zeichen), müssen Sie diese Zeichen mit einem Escapezeichen versehen, um sie als literale Zeichen zu behandeln. Verwenden Sie einen Backslash (\), um Sonderzeichen zu entschlüsseln, und denken Sie daran, den Backslash selbst zu entschlüsseln. Ein Beispiel:

      • Um nach einem buchstäblichen Unterstrich zu suchen, verwenden Sie \\_.
      • Um nach einem wörtlichen Prozentzeichen zu suchen, verwenden Sie \\%.
      • @@ -1376,7 +1378,7 @@ res = await client.Python Java Node.js
        # Search with filter
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1483,7 +1485,7 @@ res = await client.Python  Java Node.js
         
        # Infix match on color field
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1567,7 +1569,7 @@ res = await client.radius und optional range_filter einstellen, können Sie die Breite Ihrer Suche so anpassen, dass auch Vektoren einbezogen werden, die dem Abfragevektor einigermaßen ähnlich sind, und so eine umfassendere Übersicht über potenzielle Übereinstimmungen erhalten.

        +

        Durch Einstellen von radius und optional range_filter können Sie die Breite Ihrer Suche so anpassen, dass auch Vektoren einbezogen werden, die dem Abfragevektor einigermaßen ähnlich sind, und so eine umfassendere Übersicht über mögliche Übereinstimmungen erhalten.

        • radius: Legt die äußere Grenze des Suchraums fest. Nur Vektoren, die innerhalb dieses Abstands zum Abfragevektor liegen, werden als potenzielle Übereinstimmungen betrachtet.

        • range_filter: Während radius die äußere Grenze der Suche festlegt, kann range_filter optional verwendet werden, um eine innere Grenze zu definieren und einen Abstandsbereich zu schaffen, in den Vektoren fallen müssen, um als Treffer zu gelten.

        • @@ -1584,7 +1586,7 @@ search_params = { } res = client.search( - collection_name="test_collection", # Replace with the actual name of your collection + collection_name="quick_setup", # Replace with the actual name of your collection data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]], limit=3, # Max. number of search results to return search_params=search_params, # Search parameters @@ -1696,7 +1698,7 @@ res = await client.L2
          Kleinere L2-Distanzen zeigen eine höhere Ähnlichkeit an.Um die nächstgelegenen Vektoren von den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          range_filter <= distance < radius IPGrößere IP-Distanzen weisen auf eine höhere Ähnlichkeit hin.Um die nächstgelegenen Vektoren von den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          radius <= distance <= range_filter -COSINEEin größerer Kosinuswert deutet auf eine größere Ähnlichkeit hin.Um die nächstgelegenen Vektoren aus den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          radius < Abstand <= range_filter +COSINEEin größerer Kosinuswert deutet auf eine größere Ähnlichkeit hin.Um die engsten Vektoren von den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          radius < Abstand <= range_filter JACCARDKleinere Jaccard-Distanzen weisen auf eine höhere Ähnlichkeit hin.Um die nächstgelegenen Vektoren aus den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          range_filter <= distance < radius HAMMINGKleinere Hamming-Distanzen weisen auf eine höhere Ähnlichkeit hin.Um die nächstgelegenen Vektoren aus den Ergebnissen auszuschließen, stellen Sie sicher, dass:
          range_filter <= distance < radius @@ -1718,7 +1720,7 @@ res = await client.# Connect to Milvus @@ -1834,7 +1836,7 @@ search_parameters = { metric_typeWie wird die Ähnlichkeit zwischen Vektoreinbettungen gemessen.
          Mögliche Werte sind IP, L2, COSINE, JACCARD und HAMMING, und sind standardmäßig die der geladenen Indexdatei. params.nprobeAnzahl der Einheiten, die während der Suche abgefragt werden.
          Der Wert fällt in den Bereich [1, nlist[1]]. params.levelGenauigkeitsgrad der Suche.
          Mögliche Werte sind 1, 2 und 3, der Standardwert ist 1. Höhere Werte liefern genauere Ergebnisse, aber eine langsamere Leistung. -params.radiusLegt die äußere Begrenzung des Suchraums fest. Nur Vektoren, die innerhalb dieses Abstands zum Abfragevektor liegen, werden als potenzielle Übereinstimmungen betrachtet.
          Der Wertebereich wird durch den Parameter metric_type bestimmt. Wenn beispielsweise metric_type auf L2 eingestellt ist, ist der gültige Wertebereich [0, ∞]. Wenn metric_type auf COSINE eingestellt ist, ist der gültige Wertebereich [-1, 1]. Weitere Informationen finden Sie unter Ähnlichkeitsmetriken. +params.radiusLegt die äußere Begrenzung des Suchraums fest. Nur Vektoren, die innerhalb dieses Abstands zum Abfragevektor liegen, werden als potenzielle Übereinstimmungen betrachtet.
          Der Wertebereich wird durch den Parameter metric_type bestimmt. Wenn metric_type beispielsweise auf L2 eingestellt ist, ist der gültige Wertebereich [0, ∞]. Wenn metric_type auf COSINE eingestellt ist, ist der gültige Wertebereich [-1, 1]. Weitere Informationen finden Sie unter Ähnlichkeitsmetriken. params.range_filterWährend radius die äußere Grenze der Suche festlegt, kann range_filter optional verwendet werden, um eine innere Grenze zu definieren und einen Abstandsbereich zu schaffen, in den Vektoren fallen müssen, um als übereinstimmend zu gelten.
          Der Wertebereich wird durch den Parameter metric_type bestimmt. Wenn beispielsweise metric_type auf L2 gesetzt ist, ist der gültige Wertebereich [0, ∞]. Wenn metric_type auf COSINE gesetzt ist, ist der gültige Wertebereich [-1, 1]. Weitere Informationen finden Sie unter Ähnlichkeitsmetriken. diff --git a/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.json b/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.json index 17849a029..e843edaea 100644 --- a/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.json +++ b/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Mit Iteratoren","href":"With-Iterators","type":1,"isActive":false},{"label":"Überblick","href":"Overview","type":2,"isActive":false},{"label":"Vorbereitungen","href":"Preparations","type":2,"isActive":false},{"label":"Suche mit Iterator","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Abfrage mit einem Iterator","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection,connections\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Mit Iteratoren","href":"With-Iterators","type":1,"isActive":false},{"label":"Überblick","href":"Overview","type":2,"isActive":false},{"label":"Vorbereitungen","href":"Preparations","type":2,"isActive":false},{"label":"Suche mit Iterator","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Abfrage mit einem Iterator","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.md b/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.md index 98e76b850..d11613b67 100644 --- a/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.md +++ b/localization/v2.4.x/site/de/userGuide/search-query-get/with-iterators.md @@ -248,7 +248,7 @@ System.out.println(wrapper.getInsertCount()); -
          from pymilvus import Collection
          +
          from pymilvus import Collection,connections
           
           # 4. Search with iterator
           connections.connect(host="127.0.0.1", port=19530)
          @@ -401,7 +401,7 @@ System.out.println(results.size());
               
               
                 withVectors
          -      Legen Sie die Zielvektoren fest. Bis zu 16384 Vektoren sind zulässig.
          +      Legen Sie die Zielvektoren fest. Bis zu 16384 Vektoren sind erlaubt.
               
               
                 withBatchSize
          diff --git a/localization/v2.4.x/site/en/integrations/integrations_overview.md b/localization/v2.4.x/site/en/integrations/integrations_overview.md
          index 20a9bae4b..bb6580886 100644
          --- a/localization/v2.4.x/site/en/integrations/integrations_overview.md
          +++ b/localization/v2.4.x/site/en/integrations/integrations_overview.md
          @@ -67,5 +67,9 @@ title: Integrations Overview
           Build a RAG with Milvus and UnstructuredData SourcesMilvus, Unstructured
           Build RAG with Milvus + PII MaskerData SourcesMilvus, PII Masker
           Use Milvus in PrivateGPTOchestrationvector search
          +Getting Started with Mem0 and MilvusAgentsMem0, Milvus
          +Knowledge Table with MilvusKnowledge EngineeringKnowledge Table, Milvus
          +Use Milvus in DocsGPTOchestrationDocsGPT, Milvus
          +Use Milvus with SambaNovaOrchestrationMilvus, SambaNova
           
           
          diff --git a/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.json
          new file mode 100644
          index 000000000..94ddad105
          --- /dev/null
          +++ b/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.json
          @@ -0,0 +1 @@
          +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Knowledge Table with Milvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"Prerequisites","href":"Prerequisites","type":2,"isActive":false},{"label":"Cloning the project","href":"Cloning-the-project","type":2,"isActive":false},{"label":"Set up the environment","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"Starting the app","href":"Starting-the-app","type":2,"isActive":false},{"label":"Stopping the app","href":"Stopping-the-app","type":2,"isActive":false},{"label":"Accessing the project","href":"Accessing-the-project","type":2,"isActive":false}]}
          \ No newline at end of file
          diff --git a/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.md
          new file mode 100644
          index 000000000..0fc57f01d
          --- /dev/null
          +++ b/localization/v2.4.x/site/en/integrations/knowledge_table_with_milvus.md
          @@ -0,0 +1,145 @@
          +---
          +id: knowledge_table_with_milvus.md
          +summary: >-
          +  By default, Knowledge Table uses the Milvus database to store and retrieve the
          +  extracted data. This allows users to easily search, filter, and analyze the
          +  data using the powerful features of Milvus. In this tutorial, we will show how
          +  to get started with Knowledge Table and Milvus.
          +title: Knowledge Table with Milvus
          +---
          +

          Knowledge Table with Milvus

          Knowledge Table, developed by WhyHow AI, is an open-source package designed to facilitate the extraction and exploration of structured data from unstructured documents. It provides users with a spreadsheet-like interface and enables the creation of knowledge representations, such as tables and graphs, through a natural language query interface. The package includes customizable extraction rules, formatting options, and data traceability through provenance, making it adaptable for diverse applications. It supports seamless integration into RAG workflows, catering to both business users needing a user-friendly interface and developers requiring a flexible backend for efficient document processing.

          +

          By default, Knowledge Table uses the Milvus database to store and retrieve the extracted data. This allows users to easily search, filter, and analyze the data using the powerful features of Milvus. In this tutorial, we will show how to get started with Knowledge Table and Milvus.

          +

          Prerequisites

            +
          • Docker
          • +
          • Docker Compose
          • +
          +

          Cloning the project

          $ git clone https://github.com/whyhow-ai/knowledge-table.git
          +
          +

          Set up the environment

          You will find the .env.example file in the project root directory. Copy this file to .env and fill in the required environment variables.

          +

          For Milvus, you should set the MILVUS_DB_URI and MILVUS_DB_TOKEN environment variables. Here are some tips:

          +
          +
            +
          • Setting the MILVUS_DB_URI as a local file, e.g../milvus.db, is the most convenient method, as it automatically utilizes Milvus Lite to store all data in this file.
          • +
          • If you have large scale of data, say more than a million vectors, you can set up a more performant Milvus server on Docker or Kubernetes. In this setup, please use the server address and port as your uri, e.g.http://localhost:19530. If you enable the authentication feature on Milvus, use “<your_username>:<your_password>” as the token, otherwise don’t set the token.
          • +
          • If you want to use Zilliz Cloud, the fully managed cloud service for Milvus, adjust the MILVUS_DB_URI and MILVUS_DB_TOKEN, which correspond to the Public Endpoint and Api key in Zilliz Cloud.
          • +
          +
          +

          Besides Milvus, you should also set other environments, e.g. OPENAI_API_KEY. You can get each of these from the respective websites.

          +

          Starting the app

          $ docker-compose up -d --build
          +
          +

          Stopping the app

          $ docker-compose down
          +
          +

          Accessing the project

          The frontend can be accessed at http://localhost:3000, and the backend can be accessed at http://localhost:8000.

          +

          + + + + +

          +

          You can play around with the UI and try with your own documents.

          +

          For further demo usage, you can refer to the official Knowledge Table documentation.

          diff --git a/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..e8c54aa81 --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Getting Started with Mem0 and Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Preparation","href":"Preparation","type":2,"isActive":false},{"label":"Managing User Memories with Mem0 and Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..aa66cffc2 --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,217 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + In this tutorial, we’ll cover essential Mem0 memory management + operations—adding, retrieving, updating, searching, deleting, and tracking + memory history—using Milvus, a high-performance, open-source vector database + that powers efficient storage and retrieval. This hands-on introduction will + guide you through foundational memory operations to help you build + personalized AI interactions with Mem0 and Milvus. +title: Getting Started with Mem0 and Milvus +--- +

          Getting Started with Mem0 and Milvus

          +Open In Colab + + +GitHub Repository +

          +

          Mem0 is an intelligent memory layer for AI applications, designed to deliver personalized and efficient interactions by retaining user preferences and continuously adapting over time. Ideal for chatbots and AI-driven tools, Mem0 creates seamless, context-aware experiences.

          +

          In this tutorial, we’ll cover essential Mem0 memory management operations—adding, retrieving, updating, searching, deleting, and tracking memory history—using Milvus, a high-performance, open-source vector database that powers efficient storage and retrieval. This hands-on introduction will guide you through foundational memory operations to help you build personalized AI interactions with Mem0 and Milvus.

          +

          Preparation

          Download required libraries

          $ pip install mem0ai pymilvus
          +
          +
          +

          If you are using Google Colab, to enable dependencies just installed, you may need to restart the runtime (click on the “Runtime” menu at the top of the screen, and select “Restart session” from the dropdown menu).

          +
          +

          Configure Mem0 with Milvus

          We will use OpenAI as the LLM in this example. You should prepare the api key OPENAI_API_KEY as an environment variable.

          +
          import os
          +
          +os.environ["OPENAI_API_KEY"] = "sk-***********"
          +
          +

          Now, we can configure Mem0 to use Milvus as the vector store

          +
          # Define Config
          +from mem0 import Memory
          +
          +config = {
          +    "vector_store": {
          +        "provider": "milvus",
          +        "config": {
          +            "collection_name": "quickstart_mem0_with_milvus",
          +            "embedding_model_dims": "1536",
          +            "url": "./milvus.db",  # Use local vector database for demo purpose
          +        },
          +    },
          +    "version": "v1.1",
          +}
          +
          +m = Memory.from_config(config)
          +
          +
          +
          +
            +
          • If you only need a local vector database for small scale data or prototyping, setting the uri as a local file, e.g../milvus.db, is the most convenient method, as it automatically utilizes Milvus Lite to store all data in this file.
          • +
          • If you have large scale of data, say more than a million vectors, you can set up a more performant Milvus server on Docker or Kubernetes. In this setup, please use the server address and port as your uri, e.g.http://localhost:19530. If you enable the authentication feature on Milvus, use “<your_username>:<your_password>” as the token, otherwise don’t set the token.
          • +
          • If you use Zilliz Cloud, the fully managed cloud service for Milvus, adjust the uri and token, which correspond to the Public Endpoint and API key in Zilliz Cloud.
          • +
          +
          +
          +

          Managing User Memories with Mem0 and Milvus

          Adding a Memory

          The add function stores unstructured text in Milvus as a memory, associating it with a specific user and optional metadata.

          +

          Here, we’re adding Alice’s memory, “working on improving my tennis skills,” along with relevant metadata for context to Milvus.

          +
          # Add a memory to user: Working on improving tennis skills
          +res = m.add(
          +    messages="I am working on improving my tennis skills.",
          +    user_id="alice",
          +    metadata={"category": "hobbies"},
          +)
          +
          +res
          +
          +
          {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +   'memory': 'Working on improving tennis skills',
          +   'event': 'ADD'}],
          + 'relations': []}
          +
          +

          Update a Memory

          We can use the add function’s return value to retrieve the memory ID, allowing us to update this memory with new information via update.

          +
          # Get memory_id
          +memory_id = res["results"][0]["id"]
          +
          +# Update this memory with new information: Likes to play tennis on weekends
          +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
          +
          +
          {'message': 'Memory updated successfully!'}
          +
          +

          Get All Memory For a User

          We can use the get_all function to view all inserted memories or filter by user_id in Milvus.

          +

          Note that we can see the memory is now changed from “Working on impriving tennis skills” to "Likes to play tennis on weekends".

          +
          # Get all memory for the user Alice
          +m.get_all(user_id="alice")
          +
          +
          {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +   'memory': 'Likes to play tennis on weekends',
          +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
          +   'metadata': None,
          +   'created_at': '2024-11-01T19:33:44.116920-07:00',
          +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
          +   'user_id': 'alice'}]}
          +
          +

          View Memory Update History

          We can also view the memory update history by specifying which memory_id we are interested in via history function.

          +
          m.history(memory_id=memory_id)
          +
          +
          [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
          +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +  'old_memory': None,
          +  'new_memory': 'Working on improving tennis skills',
          +  'event': 'ADD',
          +  'created_at': '2024-11-01T19:33:44.116920-07:00',
          +  'updated_at': None},
          + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
          +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +  'old_memory': 'Working on improving tennis skills',
          +  'new_memory': 'Likes to play tennis on weekends',
          +  'event': 'UPDATE',
          +  'created_at': '2024-11-01T19:33:44.116920-07:00',
          +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
          +
          +

          Search Memory

          We can use search function to look for the most related memory for the user.

          +

          Let’s start by adding another memory for Alice.

          +
          new_mem = m.add(
          +    "I have a linear algebra midterm exam on November 20",
          +    user_id="alice",
          +    metadata={"category": "task"},
          +)
          +
          +

          Now, we call get_all specifying the user_id to verify that we have indeed 2 memory entries for user Alice.

          +
          m.get_all(user_id="alice")
          +
          +
          {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +   'memory': 'Likes to play tennis on weekends',
          +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
          +   'metadata': None,
          +   'created_at': '2024-11-01T19:33:44.116920-07:00',
          +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
          +   'user_id': 'alice'},
          +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
          +   'memory': 'Has a linear algebra midterm exam on November 20',
          +   'hash': '575182f46965111ca0a8279c44920ea2',
          +   'metadata': {'category': 'task'},
          +   'created_at': '2024-11-01T19:33:57.271657-07:00',
          +   'updated_at': None,
          +   'user_id': 'alice'}]}
          +
          +

          We can perform search now by providing query and user_id. Note that we are by default using L2 metric for similarity search, so a smaller score means greater similarity.

          +
          m.search(query="What are Alice's hobbies", user_id="alice")
          +
          +
          {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
          +   'memory': 'Likes to play tennis on weekends',
          +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
          +   'metadata': None,
          +   'score': 1.2807445526123047,
          +   'created_at': '2024-11-01T19:33:44.116920-07:00',
          +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
          +   'user_id': 'alice'},
          +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
          +   'memory': 'Has a linear algebra midterm exam on November 20',
          +   'hash': '575182f46965111ca0a8279c44920ea2',
          +   'metadata': {'category': 'task'},
          +   'score': 1.728922724723816,
          +   'created_at': '2024-11-01T19:33:57.271657-07:00',
          +   'updated_at': None,
          +   'user_id': 'alice'}]}
          +
          +

          Delete Memory

          We can also delete a memory by providing the corresponding memory_id.

          +

          We will delete the memory “Likes to play tennis on weekends” as its memory_id has already been retrieved, and call get_all to verify the deletion is successful.

          +
          m.delete(memory_id=memory_id)
          +
          +m.get_all("alice")
          +
          +
          {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
          +   'memory': 'Has a linear algebra midterm exam on November 20',
          +   'hash': '575182f46965111ca0a8279c44920ea2',
          +   'metadata': {'category': 'task'},
          +   'created_at': '2024-11-01T19:33:57.271657-07:00',
          +   'updated_at': None,
          +   'user_id': 'alice'}]}
          +
          diff --git a/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..a976aa489 --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Use Milvus in DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Requirements","href":"Requirements","type":2,"isActive":false},{"label":"Clone the repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Add dependency","href":"Add-dependency","type":2,"isActive":false},{"label":"Set environment variables","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Start the services","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..ca5cb6e5e --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,144 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + In this tutorial, we will show you how to use Milvus as the backend vector + database for DocsGPT. +title: Use Milvus in DocsGPT +--- +

          Use Milvus in DocsGPT

          DocsGPT is an advanced open-source solution that simplifies finding information in project documentation by integrating powerful GPT models. It enables developers to get accurate answers to their questions about a project easily, eliminating time-consuming manual searches.

          +

          In this tutorial, we will show you how to use Milvus as the backend vector database for DocsGPT.

          +
          +

          This tutorial is mainly referred to the DocsGPT official installation guide. If you find that this tutorial has outdated parts, you can prioritize following the official guide and create an issue to us.

          +
          +

          Requirements

          Make sure you have Docker installed

          +

          Clone the repository

          Clone the repository and navigate to it:

          +
          $ git clone https://github.com/arc53/DocsGPT.git
          +$ cd DocsGPT
          +
          +

          Add dependency

          Append langchain-milvus dependency to the requirements.txt file under the application folder:

          +
          $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
          +
          +

          Set environment variables

          Add VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... to the environment variables for both the backend and worker services in the docker-compose.yaml file, just like this:

          +
            backend:
          +    build: ./application
          +    environment:
          +      - VECTOR_STORE=milvus
          +      - MILVUS_URI=...
          +      - MILVUS_TOKEN=...
          +
          +
            worker:
          +    build: ./application
          +    command: celery -A application.app.celery worker -l INFO -B
          +    environment:
          +      - VECTOR_STORE=milvus
          +      - MILVUS_URI=...
          +      - MILVUS_TOKEN=...
          +
          +

          For the MILVUS_URI and MILVUS_TOKEN, you can either use fully managed Zilliz Cloud(Recommended) service or manually started Milvus service.

          +
            +
          • For fully managed Zillz Cloud service: We recommend using Zilliz Cloud service. You can sign up for a free trial account on Zilliz Cloud. After that, you will get the MILVUS_URI and MILVUS_TOKEN, which correspond to the Public Endpoint and API key.

          • +
          • For manually started Milvus service: If you want to set up a Milvus service, you can follow the official Milvus documentation to set up a Milvus server, and then get the MILVUS_URI and MILVUS_TOKEN from the server. The MILVUS_URI and MILVUS_TOKEN should be in the format of http://<your_server_ip>:19530 and <your_username>:<your_password> respectively.

          • +
          +

          Start the services

          Run: ./setup.sh

          +

          Then navigate to http://localhost:5173/.

          +

          You can play around with the UI and ask questions about your documents.

          +

          + + alt text + alt text + +

          +

          If you want to stop the services, run:

          +
          $ docker-compose down
          +
          +

          For further details and more advanced setups, please refer to the DocsGPT official documentation.

          diff --git a/localization/v2.4.x/site/en/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/en/integrations/use_milvus_in_private_gpt.md index def9b890e..6fccd70af 100644 --- a/localization/v2.4.x/site/en/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/en/integrations/use_milvus_in_private_gpt.md @@ -68,13 +68,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

          PrivateGPT allows customization of the setup. We need to specify some modules settings. In this tutorial, we will use the following modules:

          +

          PrivateGPT allows customization of the setup for some modules e.g. LLM, Embeddings, Vector Stores, UI.

          +

          In this tutorial, we will use the following modules:

          • LLM: Ollama
          • Embeddings: Ollama
          • Vector Stores: Milvus
          • UI: Gradio
          +

          Run the following command to use poetry to install the required module dependencies:

          $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
           

          Start Ollama service

          -

          Install the models to be used, the default settings-ollama.yaml is configured to user llama3.1 8b LLM (~4GB) and nomic-embed-text Embeddings (~275MB)

          +

          Install the models to be used, the default settings-ollama.yaml is configured to user llama3.1 8b LLM (~4GB) and nomic-embed-text Embeddings (~275MB)

          By default, PrivateGPT will automatically pull models as needed. This behavior can be changed by modifying the ollama.autopull_models property.

          In any case, if you want to manually pull models, run the following commands:

          $ ollama pull llama3.1
          @@ -135,7 +137,7 @@ Like this:

          Field OptionDescription -uriDefault is set to “local_data/private_gpt/milvus/milvus_local.db” as a local file; you can also set up a more performant Milvus server on docker or k8s e.g.http://localhost:19530, as your uri; To use Zilliz Cloud, adjust the uri and token to Endpoint and Api key in Zilliz Cloud. +uriDefault is set to “local_data/private_gpt/milvus/milvus_local.db” as a local file; you can also set up a more performant Milvus server on docker or k8s e.g.http://localhost:19530, as your uri; To use Zilliz Cloud, adjust the uri and token to Public Endpoint and API key in Zilliz Cloud. tokenPair with Milvus server on docker or k8s or zilliz cloud api key. collection_nameThe name of the collection, set to default “milvus_db”. overwriteOverwrite the data in collection if it existed, set to default as True. @@ -156,10 +158,10 @@ Like this:

          d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

          Once all settings are done, you can run PrivateGPT with a gradio UI.

          +

          Once all settings are done, you can run PrivateGPT with a Gradio UI.

          PGPT_PROFILES=ollama make run
           
          -

          The UI will be available athttp://0.0.0.0:8001.

          +

          The UI will be available at http://0.0.0.0:8001.

          @@ -167,3 +169,4 @@ Like this:

          You can play around with the UI and ask questions about your documents.

          +

          For further details, please refer to the PrivateGPT official documentation.

          diff --git a/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..f01c5cad1 --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Use Milvus with SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Prerequisites","href":"Prerequisites","type":2,"isActive":false},{"label":"Clone the repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Change the vector store type","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Install dependencies","href":"Install-dependencies","type":2,"isActive":false},{"label":"Start the application","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..f50175273 --- /dev/null +++ b/localization/v2.4.x/site/en/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,137 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + This tutorial leverages Milvus integration in SambaNova AI Starter Kits to + build an Enterprise Knowledge Retrieval system, similar to + RAG(Retrieval-Augmented Generation), for retrieval and answering based on the + enterprise private documents. +title: Use Milvus with SambaNova +--- +

          Use Milvus with SambaNova

          SambaNova is an innovative AI technology platform that accelerates the deployment of advanced AI and deep learning capabilities. Designed for enterprise use, it empowers organizations to leverage generative AI for enhanced performance and efficiency. By providing cutting-edge solutions like the SambaNova Suite and DataScale, the platform enables businesses to extract valuable insights from their data, driving operational improvements and fostering new opportunities in the AI landscape.

          +

          SambaNova AI Starter Kits are a collection of open-source resources designed to assist developers and enterprises in deploying AI-driven applications with SambaNova. These kits provide practical examples and guides that facilitate the implementation of various AI use cases, making it easier for users to leverage SambaNova’s advanced technology.

          +

          This tutorial leverages Milvus integration in SambaNova AI Starter Kits to build an Enterprise Knowledge Retrieval system, similar to RAG(Retrieval-Augmented Generation), for retrieval and answering based on the enterprise private documents.

          +
          +

          This tutorial is mainly referred to the SambaNova AI Starter Kits official guide. If you find that this tutorial has outdated parts, you can prioritize following the official guide and create an issue to us.

          +
          +

          Prerequisites

          We recommend using Python >= 3.10 and < 3.12.

          +

          Visit the SambaNova Cloud to get an SambaNova API key.

          +

          Clone the repository

          $ git clone https://github.com/sambanova/ai-starter-kit.git
          +$ d ai-starter-kit/enterprise_knowledge_retriever
          +
          +

          Change the vector store type

          Change the vector store by setting db_type='milvus' in the create_vector_store() and load_vdb() functions in src/document_retrieval.py.

          +
          ...
          +vectorstore = self.vectordb.create_vector_store(
          +    ..., db_type='milvus'
          +)
          +...
          +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
          +
          +

          Install dependencies

          Install the required dependencies by running the following command:

          +
          python3 -m venv enterprise_knowledge_env
          +source enterprise_knowledge_env/bin/activate
          +pip install -r requirements.txt
          +
          +

          Start the application

          Use the following command to start the application:

          +
          $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
          +
          +

          After that, you see the user interface in your browser: +http://localhost:8501/

          +

          + + + + +

          +

          After set your SambaNova API key in the UI, you can play around with the UI and ask questions about your documents.

          +

          For further details, please refer to the Enterprise Knowledge Retrieval +of SambaNova AI Starter Kits official documentation.

          diff --git a/localization/v2.4.x/site/en/menuStructure/en.json b/localization/v2.4.x/site/en/menuStructure/en.json index 28ecf5c3d..b4499f65b 100644 --- a/localization/v2.4.x/site/en/menuStructure/en.json +++ b/localization/v2.4.x/site/en/menuStructure/en.json @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivateGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Knowledge Table", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Funnel Search with Matryoshka Embeddings", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "Explore More", "id": "explore-more", diff --git a/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..a7dc436a6 --- /dev/null +++ b/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"Funnel Search with Matryoshka Embeddings","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"Load Matryoshka Embedding Model","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"Loading Dataset, Embedding Items, and Building Vector Database","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"Performing Funnel Search","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"Comparing Funnel Search to Regular Search","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"Investigating Funnel Search Recall Failure for Ferris Bueller's Day Off","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"Does the order matter? Prefix vs suffix embeddings.","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"Summary","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..ec68dc280 --- /dev/null +++ b/localization/v2.4.x/site/en/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,570 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + In this notebook, we examine how to use Matryoshka embeddings with Milvus for + semantic search. We illustrate an algorithm called "funnel search" that allows + us to perform similarity search over a small subset of our embedding + dimensions without a drastic drop in recall. +title: Funnel Search with Matryoshka Embeddings +--- +

          Funnel Search with Matryoshka Embeddings

          When building efficient vector search systems, one key challenge is managing storage costs while maintaining acceptable latency and recall. Modern embedding models output vectors with hundreds or thousands of dimensions, creating significant storage and computational overhead for the raw vector and index.

          +

          Traditionally, the storage requirements are reduced by applying a quantization or dimensionality reduction method just before building the index. For instance, we can save storage by lowering the precision using Product Quantization (PQ) or the number of dimensions using Principal Component Analysis (PCA). These methods analyze the entire vector set to find a more compact one that maintains the semantic relationships between vectors.

          +

          While effective, these standard approaches reduce precision or dimensionality only once and at a single scale. But what if we could maintain multiple layers of detail simultaneously, like a pyramid of increasingly precise representations?

          +

          Enter Matryoshka embeddings. Named after Russian nesting dolls (see illustration), these clever constructs embed multiple scales of representation within a single vector. Unlike traditional post-processing methods, Matryoshka embeddings learn this multi-scale structure during the initial training process. The result is remarkable: not only does the full embedding capture input semantics, but each nested subset prefix (first half, first quarter, etc.) provides a coherent, if less detailed, representation.

          +
          +

          In this notebook, we examine how to use Matryoshka embeddings with Milvus for semantic search. We illustrate an algorithm called “funnel search” that allows us to perform similarity search over a small subset of our embedding dimensions without a drastic drop in recall.

          +
          import functools
          +
          +from datasets import load_dataset
          +import numpy as np
          +import pandas as pd
          +import pymilvus
          +from pymilvus import MilvusClient
          +from pymilvus import FieldSchema, CollectionSchema, DataType
          +from sentence_transformers import SentenceTransformer
          +import torch
          +import torch.nn.functional as F
          +from tqdm import tqdm
          +
          +

          Load Matryoshka Embedding Model

          Instead of using a standard embedding model such as sentence-transformers/all-MiniLM-L12-v2, we use a model from Nomic trained especially to produce Matryoshka embeddings.

          +
          model = SentenceTransformer(
          +    # Remove 'device='mps' if running on non-Mac device
          +    "nomic-ai/nomic-embed-text-v1.5",
          +    trust_remote_code=True,
          +    device="mps",
          +)
          +
          +
          <All keys matched successfully>
          +
          +

          Loading Dataset, Embedding Items, and Building Vector Database

          The following code is a modification of that from the documentation page “Movie Search with Sentence Transformers and Milvus”. First, we load the dataset from HuggingFace. It contains around 35k entries, each corresponding to a movie having a Wikipedia article. We will use the Title and PlotSummary fields in this example.

          +
          ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
          +print(ds)
          +
          +
          Dataset({
          +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
          +    num_rows: 34886
          +})
          +
          +

          Next, we connect to a Milvus Lite database, specify the data schema, and create a collection with this schema. We will store both the unnormalized embedding and the first sixth of the embedding in separate fields. The reason for this is that we need the first 1/6th of the Matryoshka embedding for performing a similarity search, and the remaining 5/6ths of the embeddings for reranking and improving the search results.

          +
          embedding_dim = 768
          +search_dim = 128
          +collection_name = "movie_embeddings"
          +
          +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
          +
          +fields = [
          +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
          +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
          +    # First sixth of unnormalized embedding vector
          +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
          +    # Entire unnormalized embedding vector
          +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
          +]
          +
          +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
          +client.create_collection(collection_name=collection_name, schema=schema)
          +
          +

          Milvus does not currently support searching over subsets of embeddings, so we break the embeddings into two parts: the head represents the initial subset of the vector to index and search, and the tail is the remainder. The model is trained for cosine distance similarity search, so we normalize the head embeddings. However, in order to calculate similarities for larger subsets later on, we need to store the norm of the head embedding, so we can unnormalize it before joining to the tail.

          +

          To perform search via the first 1/6th of the embedding, we will need to create a vector search index over the head_embedding field. Later on, we will compare the results of “funnel search” with a regular vector search, and so build a search index over the full embedding also.

          +

          Importantly, we use the COSINE rather than the IP distance metric, because otherwise we would need to keep track of the embedding norms, which would complicate the implementation (this will make more sense once the funnel search algorithm has been described).

          +
          index_params = client.prepare_index_params()
          +index_params.add_index(
          +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
          +)
          +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
          +client.create_index(collection_name, index_params)
          +
          +

          Finally, we encode the plot summaries for all 35k movies and enter the corresponding embeddings in to the database.

          +
          for batch in tqdm(ds.batch(batch_size=512)):
          +    # This particular model requires us to prefix 'search_document:' to stored entities
          +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
          +
          +    # Output of embedding model is unnormalized
          +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
          +    head_embeddings = embeddings[:, :search_dim]
          +
          +    data = [
          +        {
          +            "title": title,
          +            "head_embedding": head.cpu().numpy(),
          +            "embedding": embedding.cpu().numpy(),
          +        }
          +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
          +    ]
          +    res = client.insert(collection_name=collection_name, data=data)
          +
          +
          100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
          +
          +

          Let’s now implement a “funnel search” using the first 1/6th of the Matryoshka embedding dimensions. I have three movies in mind for retrieval and have produced my own plot summary for querying the database. We embed the queries, then perform a vector search on the head_embedding field, retrieving 128 result candidates.

          +
          queries = [
          +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
          +    "A teenager fakes illness to get off school and have adventures with two friends.",
          +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
          +]
          +
          +
          +# Search the database based on input text
          +def embed_search(data):
          +    embeds = model.encode(data)
          +    return [x for x in embeds]
          +
          +
          +# This particular model requires us to prefix 'search_query:' to queries
          +instruct_queries = ["search_query: " + q.strip() for q in queries]
          +search_data = embed_search(instruct_queries)
          +
          +# Normalize head embeddings
          +head_search = [x[:search_dim] for x in search_data]
          +
          +# Perform standard vector search on first sixth of embedding dimensions
          +res = client.search(
          +    collection_name=collection_name,
          +    data=head_search,
          +    anns_field="head_embedding",
          +    limit=128,
          +    output_fields=["title", "head_embedding", "embedding"],
          +)
          +
          +

          At this point, we have performed search over a much smaller vector space, and are therefore likely to have lowered latency and lessened storage requirements for the index relative to search over the full space. Let’s examine the top 5 matches for each query:

          +
          for query, hits in zip(queries, res):
          +    rows = [x["entity"] for x in hits][:5]
          +
          +    print("Query:", query)
          +    print("Results:")
          +    for row in rows:
          +        print(row["title"].strip())
          +    print()
          +
          +
          Query: An archaeologist searches for ancient artifacts while fighting Nazis.
          +Results:
          +"Pimpernel" Smith
          +Black Hunters
          +The Passage
          +Counterblast
          +Dominion: Prequel to the Exorcist
          +
          +Query: A teenager fakes illness to get off school and have adventures with two friends.
          +Results:
          +How to Deal
          +Shorts
          +Blackbird
          +Valentine
          +Unfriended
          +
          +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
          +Results:
          +Ghostkeeper
          +Our Vines Have Tender Grapes
          +The Ref
          +Impact
          +The House in Marsh Road
          +
          +

          As we can see, recall has suffered as a consequence of truncating the embeddings during search. Funnel search fixes this with a clever trick: we can use the remainder of the embedding dimensions to rerank and prune our candidate list to recover retrieval performance without running any additional expensive vector searches.

          +

          For ease of exposition of the funnel search algorithm, we convert the Milvus search hits for each query into a Pandas dataframe.

          +
          def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
          +    """
          +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
          +
          +    """
          +    rows = [x["entity"] for x in hits]
          +    rows_dict = [
          +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
          +    ]
          +    return pd.DataFrame.from_records(rows_dict)
          +
          +
          +dfs = [hits_to_dataframe(hits) for hits in res]
          +
          +

          Now, to perform funnel search we iterate over the increasingly larger subsets of the embeddings. At each iteration, we rerank the candidates according to the new similarities and prune some fraction of the lowest ranked ones.

          +

          To make this concrete, from the previous step we have retrieved 128 candidates using 1/6 of the embedding and query dimensions. The first step in performing funnel search is to recalculate the similarities between the queries and candidates using the first 1/3 of the dimensions. The bottom 64 candidates are pruned. Then we repeat this process with the first 2/3 of the dimensions, and then all of the dimensions, successively pruning to 32 and 16 candidates.

          +
          # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
          +def calculate_score(row, query_emb=None, dims=768):
          +    emb = F.normalize(row["embedding"][:dims], dim=-1)
          +    return (emb @ query_emb).item()
          +
          +
          +# You could also add a top-K parameter as a termination condition
          +def funnel_search(
          +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
          +) -> pd.DataFrame:
          +    # Loop over increasing prefixes of the embeddings
          +    for dims in scales:
          +        # Query vector must be normalized for each new dimensionality
          +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
          +
          +        # Score
          +        scores = df.apply(
          +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
          +        )
          +        df["scores"] = scores
          +
          +        # Re-rank
          +        df = df.sort_values(by="scores", ascending=False)
          +
          +        # Prune (in our case, remove half of candidates at each step)
          +        df = df.head(int(prune_ratio * len(df)))
          +
          +    return df
          +
          +
          +dfs_results = [
          +    {"query": query, "results": funnel_search(df, query_emb)}
          +    for query, df, query_emb in zip(queries, dfs, search_data)
          +]
          +
          +
          for d in dfs_results:
          +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
          +
          +
          An archaeologist searches for ancient artifacts while fighting Nazis. 
          + 0           "Pimpernel" Smith
          +1               Black Hunters
          +29    Raiders of the Lost Ark
          +34             The Master Key
          +51            My Gun Is Quick
          +Name: title, dtype: object 
          +
          +A teenager fakes illness to get off school and have adventures with two friends. 
          + 21               How I Live Now
          +32     On the Edge of Innocence
          +77             Bratz: The Movie
          +4                    Unfriended
          +108                  Simon Says
          +Name: title, dtype: object 
          +
          +A young couple with a kid look after a hotel during winter and the husband goes insane. 
          + 9         The Shining
          +0         Ghostkeeper
          +11     Fast and Loose
          +7      Killing Ground
          +12         Home Alone
          +Name: title, dtype: object 
          +
          +

          We have been able to restore recall without performing any additional vector searches! Qualitatively, these results seem to have higher recall for “Raiders of the Lost Ark” and “The Shining” than the standard vector search in the tutorial, “Movie Search using Milvus and Sentence Transformers”, which uses a different embedding model. However, it is unable to find "Ferris Bueller’s Day Off", which we will return to later in the notebook. (See the paper Matryoshka Representation Learning for more quantitative experiments and benchmarking.)

          +

          Let’s compare the results of our funnel search to a standard vector search on the same dataset with the same embedding model. We perform a search on the full embeddings.

          +
          # Search on entire embeddings
          +res = client.search(
          +    collection_name=collection_name,
          +    data=search_data,
          +    anns_field="embedding",
          +    limit=5,
          +    output_fields=["title", "embedding"],
          +)
          +
          +
          for query, hits in zip(queries, res):
          +    rows = [x["entity"] for x in hits]
          +
          +    print("Query:", query)
          +    print("Results:")
          +    for row in rows:
          +        print(row["title"].strip())
          +    print()
          +
          +
          Query: An archaeologist searches for ancient artifacts while fighting Nazis.
          +Results:
          +"Pimpernel" Smith
          +Black Hunters
          +Raiders of the Lost Ark
          +The Master Key
          +My Gun Is Quick
          +
          +Query: A teenager fakes illness to get off school and have adventures with two friends.
          +Results:
          +A Walk to Remember
          +Ferris Bueller's Day Off
          +How I Live Now
          +On the Edge of Innocence
          +Bratz: The Movie
          +
          +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
          +Results:
          +The Shining
          +Ghostkeeper
          +Fast and Loose
          +Killing Ground
          +Home Alone
          +
          +

          With the exception of the results for "A teenager fakes illness to get off school…", the results under funnel search are almost identical to the full search, even though the funnel search was performed on a search space of 128 dimensions vs 768 dimensions for the regular one.

          +

          Investigating Funnel Search Recall Failure for Ferris Bueller’s Day Off

          Why didn’t funnel search succeed in retrieving Ferris Bueller’s Day Off? Let’s examine whether or not it was in the original candidate list or was mistakenly filtered out.

          +
          queries2 = [
          +    "A teenager fakes illness to get off school and have adventures with two friends."
          +]
          +
          +
          +# Search the database based on input text
          +def embed_search(data):
          +    embeds = model.encode(data)
          +    return [x for x in embeds]
          +
          +
          +instruct_queries = ["search_query: " + q.strip() for q in queries2]
          +search_data2 = embed_search(instruct_queries)
          +head_search2 = [x[:search_dim] for x in search_data2]
          +
          +# Perform standard vector search on subset of embeddings
          +res = client.search(
          +    collection_name=collection_name,
          +    data=head_search2,
          +    anns_field="head_embedding",
          +    limit=256,
          +    output_fields=["title", "head_embedding", "embedding"],
          +)
          +
          +
          for query, hits in zip(queries, res):
          +    rows = [x["entity"] for x in hits]
          +
          +    print("Query:", queries2[0])
          +    for idx, row in enumerate(rows):
          +        if row["title"].strip() == "Ferris Bueller's Day Off":
          +            print(f"Row {idx}: Ferris Bueller's Day Off")
          +
          +
          Query: A teenager fakes illness to get off school and have adventures with two friends.
          +Row 228: Ferris Bueller's Day Off
          +
          +

          We see that the issue was that the initial candidate list was not large enough, or rather, the desired hit is not similar enough to the query at the highest level of granularity. Changing it from 128 to 256 results in successful retrieval. We should form a rule-of-thumb to set the number of candidates on a held-out set to empirically evaluate the trade-off between recall and latency.

          +
          dfs = [hits_to_dataframe(hits) for hits in res]
          +
          +dfs_results = [
          +    {"query": query, "results": funnel_search(df, query_emb)}
          +    for query, df, query_emb in zip(queries2, dfs, search_data2)
          +]
          +
          +for d in dfs_results:
          +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
          +
          +
          A teenager fakes illness to get off school and have adventures with two friends. 
          +       A Walk to Remember
          +Ferris Bueller's Day Off
          +          How I Live Now
          +On the Edge of Innocence
          +        Bratz: The Movie
          +              Unfriended
          +              Simon Says 
          +
          +

          Does the order matter? Prefix vs suffix embeddings.

          The model was trained to perform well matching recursively smaller prefixes of the embeddings. Does the order of the dimensions we use matter? For instance, could we also take subsets of the embeddings that are suffixes? In this experiment, we reverse the order of the dimensions in the Matryoshka embeddings and perform a funnel search.

          +
          client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
          +
          +fields = [
          +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
          +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
          +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
          +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
          +]
          +
          +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
          +client.create_collection(collection_name=collection_name, schema=schema)
          +
          +index_params = client.prepare_index_params()
          +index_params.add_index(
          +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
          +)
          +client.create_index(collection_name, index_params)
          +
          +
          huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
          +To disable this warning, you can either:
          +    - Avoid using `tokenizers` before the fork if possible
          +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
          +
          +
          for batch in tqdm(ds.batch(batch_size=512)):
          +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
          +
          +    # Encode and flip embeddings
          +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
          +    embeddings = torch.flip(embeddings, dims=[-1])
          +    head_embeddings = embeddings[:, :search_dim]
          +
          +    data = [
          +        {
          +            "title": title,
          +            "head_embedding": head.cpu().numpy(),
          +            "embedding": embedding.cpu().numpy(),
          +        }
          +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
          +    ]
          +    res = client.insert(collection_name=collection_name, data=data)
          +
          +
          100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
          +
          +
          # Normalize head embeddings
          +
          +flip_search_data = [
          +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
          +]
          +flip_head_search = [x[:search_dim] for x in flip_search_data]
          +
          +# Perform standard vector search on subset of embeddings
          +res = client.search(
          +    collection_name=collection_name,
          +    data=flip_head_search,
          +    anns_field="head_embedding",
          +    limit=128,
          +    output_fields=["title", "head_embedding", "embedding"],
          +)
          +
          +
          dfs = [hits_to_dataframe(hits) for hits in res]
          +
          +dfs_results = [
          +    {"query": query, "results": funnel_search(df, query_emb)}
          +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
          +]
          +
          +for d in dfs_results:
          +    print(
          +        d["query"],
          +        "\n",
          +        d["results"][:7]["title"].to_string(index=False, header=False),
          +        "\n",
          +    )
          +
          +
          An archaeologist searches for ancient artifacts while fighting Nazis. 
          +       "Pimpernel" Smith
          +          Black Hunters
          +Raiders of the Lost Ark
          +         The Master Key
          +        My Gun Is Quick
          +            The Passage
          +        The Mole People 
          +
          +A teenager fakes illness to get off school and have adventures with two friends. 
          +                       A Walk to Remember
          +                          How I Live Now
          +                              Unfriended
          +Cirque du Freak: The Vampire's Assistant
          +                             Last Summer
          +                                 Contest
          +                                 Day One 
          +
          +A young couple with a kid look after a hotel during winter and the husband goes insane. 
          +         Ghostkeeper
          +     Killing Ground
          +Leopard in the Snow
          +              Stone
          +          Afterglow
          +         Unfaithful
          +     Always a Bride 
          +
          +

          Recall is much poorer than funnel search or regular search as expected (the embedding model was trained by contrastive learning on prefixes of the embedding dimensions, not suffixes).

          +

          Summary

          Here is a comparison of our search results across methods:

          +
          +
          +
          +We have shown how to use Matryoshka embeddings with Milvus for performing a more efficient semantic search algorithm called "funnel search." We also explored the importance of the reranking and pruning steps of the algorithm, as well as a failure mode when the initial candidate list is too small. Finally, we discussed how the order of the dimensions is important when forming sub-embeddings - it must be in the same way for which the model was trained. Or rather, it is only because the model was trained in a certain way that prefixes of the embeddings are meaningful. Now you know how to implement Matryoshka embeddings and funnel search to reduce the storage costs of semantic search without sacrificing too much retrieval performance! diff --git a/localization/v2.4.x/site/en/tutorials/tutorials-overview.md b/localization/v2.4.x/site/en/tutorials/tutorials-overview.md index 7bfa735e0..aa0cb634f 100644 --- a/localization/v2.4.x/site/en/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/en/tutorials/tutorials-overview.md @@ -43,5 +43,6 @@ title: Tutorials Overview Use ColPali for Multi-Modal Retrieval with MilvusQuickstartvector search Vector VisualizationQuickstartvector search Movie Recommendation with MilvusRecommendation Systemvector search +Funnel Search with Matryoshka EmbeddingsQuickstartvector search diff --git a/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.json index 7502e6eb1..a5e8b578a 100644 --- a/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Actualizar Milvus Cluster con Helm Chart","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Comprobar Milvus Helm Chart","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Realizar una actualización continua","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Actualizar Milvus utilizando Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrar los metadatos","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Actualizar Milvus Cluster con Helm Chart","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Comprobar Milvus Helm Chart","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Realizar una actualización continua","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Actualizar Milvus utilizando Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrar los metadatos","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.md index 67e16a532..b5bd90e16 100644 --- a/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/es/adminGuide/upgrade_milvus_cluster-helm.md @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
        • Migre los metadatos de Milvus.
        • Inicie los componentes de Milvus con una nueva imagen.
        • -

          2. Actualizar Milvus de v2.1.x a 2.4.15

          Los siguientes comandos asumen que usted actualiza Milvus de v2.1.4 a 2.4.15. Cámbielos por las versiones que se ajusten a sus necesidades.

          +

          2. Actualizar Milvus de v2.1.x a 2.2.0

          Los siguientes comandos asumen que usted actualiza Milvus de v2.1.4 a 2.2.0. Cámbielos por las versiones que se ajusten a sus necesidades.

          1. Especifique el nombre de la instancia de Milvus, la versión de Milvus de origen y la versión de Milvus de destino.

            -
            ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
            +
            ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
             
          2. Especifique el espacio de nombres con -n si su Milvus no está instalado en el espacio de nombres predeterminado de K8s.

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
             
          3. Especifique la ruta raíz con -r si su Milvus está instalado con la costumbre rootpath.

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
             
          4. Especifique la etiqueta de imagen con -w si su Milvus está instalado con la personalizada image.

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
             
          5. Establezca -d true si desea eliminar automáticamente el pod de migración una vez finalizada la migración.

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
             
          6. Retroceda y migre de nuevo si la migración falla.

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
            -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
            +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
             
          diff --git a/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.json index 4b5dd2d92..ac7d6087d 100644 --- a/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"Ejecutar Milvus en Kubernetes con Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Requisitos previos","href":"Prerequisites","type":2,"isActive":false},{"label":"Instalar Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Instalación en línea","href":"Online-install","type":2,"isActive":false},{"label":"Instalación fuera de línea","href":"Offline-install","type":2,"isActive":false},{"label":"Actualice el cluster Milvus en ejecución","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Desinstalar Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Lo que sigue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"Ejecutar Milvus en Kubernetes con Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Requisitos previos","href":"Prerequisites","type":2,"isActive":false},{"label":"Instalar Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Instalación en línea","href":"Online-install","type":2,"isActive":false},{"label":"Instalación fuera de línea","href":"Offline-install","type":2,"isActive":false},{"label":"Actualice el cluster Milvus en ejecución","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Desinstalar Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Lo que sigue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.md index c69b0ea9e..45a676d9b 100644 --- a/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/es/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -62,7 +62,7 @@ NAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDI standard (default) k8s.io/minikube-hostpath Delete Immediate false
        • Compruebe los requisitos de hardware y software antes de la instalación.

        • -
        • Antes de instalar Milvus, se recomienda utilizar Milvus Sizing Tool para estimar los requisitos de hardware basándose en el tamaño de sus datos. Esto ayuda a garantizar un rendimiento y una asignación de recursos óptimos para su instalación de Milvus.

        • +
        • Antes de instalar Milvus, se recomienda utilizar Milvus Sizing Tool para estimar los requisitos de hardware basados en el tamaño de sus datos. Esto ayuda a garantizar un rendimiento y una asignación de recursos óptimos para su instalación de Milvus.

        Si encuentra algún problema al tirar de la imagen, póngase en contacto con nosotros en community@zilliz.com con detalles sobre el problema, y le proporcionaremos el soporte necesario.

        @@ -83,11 +83,11 @@ NAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDI >

        Antes de instalar Milvus Helm Charts, necesita añadir el repositorio Milvus Helm.

        -
        $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
        +
        $ helm repo add milvus https://github.com/zilliztech/milvus-helm
         
        -

        El repositorio de Milvus Helm Charts en https://milvus-io.github.io/milvus-helm/ ha sido archivado y puede obtener más actualizaciones en https://zilliztech.github.io/milvus-helm/ como se indica a continuación:

        -
        helm repo add zilliztech https://zilliztech.github.io/milvus-helm
        +

        El repositorio de Milvus Helm Charts en https://github.com/milvus-io/milvus-helm ha sido archivado y puede obtener más actualizaciones en https://github.com/zilliztech/milvus-helm como se indica a continuación:

        +
        helm repo add zilliztech https://github.com/zilliztech/milvus-helm
         helm repo update
         # upgrade existing helm release
         helm upgrade my-release zilliztech/milvus
        @@ -122,7 +122,7 @@ helm upgrade my-release zilliztech/milvus
           
        • El nombre de la versión sólo debe contener letras, números y guiones. Los puntos no están permitidos en el nombre de la versión.
        • La línea de comandos por defecto instala la versión cluster de Milvus cuando se instala Milvus con Helm. Se necesita una configuración adicional cuando se instala Milvus de forma independiente.
        • -
        • De acuerdo con la guía de migración de API obsoleta de Kubernetes, la versión de API policy/v1beta1 de PodDisruptionBudget ya no se sirve a partir de v1.25. Se recomienda migrar los manifiestos y clientes de API para utilizar la versión de API policy/v1 en su lugar.
          Como solución para los usuarios que aún utilizan la versión de la API policy/v1beta1 de PodDisruptionBudget en Kubernetes v1.25 y posteriores, puede ejecutar el siguiente comando para instalar Milvus:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • +
        • De acuerdo con la guía de migración de API obsoleta de Kubernetes, la versión de la API policy/v1beta1 de PodDisruptionBudget ya no se sirve a partir de v1.25. Se recomienda migrar los manifiestos y clientes de API para utilizar la versión de API policy/v1 en su lugar.
          Como solución para los usuarios que aún utilizan la versión de la API policy/v1beta1 de PodDisruptionBudget en Kubernetes v1.25 y posteriores, puede ejecutar el siguiente comando para instalar Milvus:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • Consulte Milvus Helm Chart y Helm para obtener más información.
        @@ -276,14 +276,14 @@ $ helm upgrade my-release zilliztech/milvus
    • Actualice Milvus utilizando Helm Chart.

    • Escale su cluster Milvus.

    • -
    • Despliegue su clúster Milvu en nubes:

      +
    • Despliegue su clúster Milvus en nubes:

    • Explore Milvus Backup, una herramienta de código abierto para realizar copias de seguridad de los datos de Milvus.

    • -
    • Explore Birdwatcher, una herramienta de código abierto para depurar Milvus y actualizaciones de configuración dinámicas.

    • +
    • Explore Birdwatcher, una herramienta de código abierto para depurar Milvus y actualizaciones dinámicas de configuración.

    • Explore Attu, una herramienta GUI de código abierto para la gestión intuitiva de Milvus.

    • Supervise Milvus con Prometheus.

    diff --git a/localization/v2.4.x/site/es/integrations/integrations_overview.md b/localization/v2.4.x/site/es/integrations/integrations_overview.md index 5d7a83bd0..a57a56e43 100644 --- a/localization/v2.4.x/site/es/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/es/integrations/integrations_overview.md @@ -67,5 +67,9 @@ title: Visión general de las integraciones Construir un GAR con Milvus y fuentes de datosde datos no estructuradosMilvus, no estructurados Construir un GAR con Milvus + PII MaskerFuentes de datosMilvus, Enmascarador PII Utilizar Milvus en PrivateGPTOrganizaciónBúsqueda vectorial +Introducción a Mem0 y MilvusAgentesMem0, Milvus +Tabla de conocimiento con MilvusIngeniería del conocimientoTabla de conocimiento, Milvus +Utilización de Milvus en DocsGPTOchestrationDocsGPT, Milvus +Utilización de Milvus con SambaNovaOrquestaciónMilvus, SambaNova diff --git a/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..909a55a83 --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Knowledge Table con Milvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"Requisitos previos","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonar el proyecto","href":"Cloning-the-project","type":2,"isActive":false},{"label":"Configurar el entorno","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"Iniciar la aplicación","href":"Starting-the-app","type":2,"isActive":false},{"label":"Detener la aplicación","href":"Stopping-the-app","type":2,"isActive":false},{"label":"Acceso al proyecto","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..a93de040d --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,145 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + Por defecto, Knowledge Table utiliza la base de datos Milvus para almacenar y + recuperar los datos extraídos. Esto permite a los usuarios buscar, filtrar y + analizar fácilmente los datos utilizando las potentes funciones de Milvus. En + este tutorial, mostraremos cómo empezar a utilizar Knowledge Table y Milvus. +title: Knowledge Table con Milvus +--- +

    Knowledge Table con Milvus

    Knowledge Table, desarrollado por WhyHow AI, es un paquete de código abierto diseñado para facilitar la extracción y exploración de datos estructurados a partir de documentos no estructurados. Proporciona a los usuarios una interfaz similar a la de una hoja de cálculo y permite crear representaciones del conocimiento, como tablas y gráficos, a través de una interfaz de consulta en lenguaje natural. El paquete incluye reglas de extracción personalizables, opciones de formato y trazabilidad de datos mediante procedencia, lo que lo hace adaptable a diversas aplicaciones. Se integra a la perfección en los flujos de trabajo de RAG, lo que satisface tanto a los usuarios empresariales que necesitan una interfaz fácil de usar como a los desarrolladores que precisan un backend flexible para procesar documentos con eficacia.

    +

    Por defecto, Knowledge Table utiliza la base de datos Milvus para almacenar y recuperar los datos extraídos. Esto permite a los usuarios buscar, filtrar y analizar fácilmente los datos utilizando las potentes funciones de Milvus. En este tutorial, mostraremos cómo empezar a utilizar Knowledge Table y Milvus.

    +

    Requisitos previos

      +
    • Docker
    • +
    • Docker Compose
    • +
    +

    Clonar el proyecto

    $ git clone https://github.com/whyhow-ai/knowledge-table.git
    +
    +

    Configurar el entorno

    Encontrarás el archivo .env.example en el directorio raíz del proyecto. Copie este archivo en .env y rellene las variables de entorno necesarias.

    +

    Para Milvus, debe establecer las variables de entorno MILVUS_DB_URI y MILVUS_DB_TOKEN. He aquí algunos consejos:

    +
    +
      +
    • Establecer el MILVUS_DB_URI como un archivo local, por ejemplo./milvus.db, es el método más conveniente, ya que utiliza automáticamente Milvus Lite para almacenar todos los datos en este archivo.
    • +
    • Si tiene una gran escala de datos, digamos más de un millón de vectores, puede configurar un servidor Milvus más eficiente en Docker o Kubernetes. En esta configuración, por favor utilice la dirección del servidor y el puerto como su uri, por ejemplohttp://localhost:19530. Si habilita la función de autenticación en Milvus, utilice "<su_nombre_de_usuario>:<su_contraseña>" como token, de lo contrario no establezca el token.
    • +
    • Si desea utilizar Zilliz Cloud, el servicio en la nube totalmente gestionado para Milvus, ajuste MILVUS_DB_URI y MILVUS_DB_TOKEN, que corresponden al punto final público y a la clave Api en Zilliz Cloud.
    • +
    +
    +

    Además de Milvus, también debe ajustar otros entornos, por ejemplo OPENAI_API_KEY. Puedes obtener cada uno de ellos en sus respectivos sitios web.

    +

    Iniciar la aplicación

    $ docker-compose up -d --build
    +
    +

    Detener la aplicación

    $ docker-compose down
    +
    +

    Acceso al proyecto

    Se puede acceder al frontend en http://localhost:3000, y al backend en http://localhost:8000.

    +

    + + + + +

    +

    Puedes jugar con la interfaz de usuario y probar con tus propios documentos.

    +

    Para más información, consulta la documentación oficial de Knowledge Table.

    diff --git a/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..d995c2d65 --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Primeros pasos con Mem0 y Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Preparación","href":"Preparation","type":2,"isActive":false},{"label":"Gestión de memorias de usuario con Mem0 y Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..08b651c69 --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,218 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + En este tutorial, cubriremos las operaciones esenciales de gestión de memoria + de Mem0 -añadir, recuperar, actualizar, buscar, borrar y rastrear el historial + de memoria- utilizando Milvus, una base de datos vectorial de alto rendimiento + y código abierto que potencia el almacenamiento y la recuperación eficientes. + Esta introducción práctica le guiará a través de las operaciones básicas de + memoria para ayudarle a crear interacciones de IA personalizadas con Mem0 y + Milvus. +title: Primeros pasos con Mem0 y Milvus +--- +

    Primeros pasos con Mem0 y Milvus

    +Open In Colab + + +GitHub Repository +

    +

    Mem0 es una capa de memoria inteligente para aplicaciones de IA, diseñada para ofrecer interacciones personalizadas y eficientes reteniendo las preferencias del usuario y adaptándose continuamente a lo largo del tiempo. Ideal para chatbots y herramientas basadas en IA, Mem0 crea experiencias fluidas y conscientes del contexto.

    +

    En este tutorial, cubriremos las operaciones esenciales de gestión de memoria de Mem0 (añadir, recuperar, actualizar, buscar, eliminar y realizar un seguimiento del historial de memoria) utilizando Milvus, una base de datos vectorial de código abierto y alto rendimiento que permite un almacenamiento y una recuperación eficientes. Esta introducción práctica le guiará a través de las operaciones de memoria básicas para ayudarle a crear interacciones de IA personalizadas con Mem0 y Milvus.

    +

    Preparación

    Descarga de las bibliotecas necesarias

    $ pip install mem0ai pymilvus
    +
    +
    +

    Si utilizas Google Colab, para habilitar las dependencias que acabas de instalar, es posible que tengas que reiniciar el tiempo de ejecución (haz clic en el menú "Tiempo de ejecución" en la parte superior de la pantalla y selecciona "Reiniciar sesión" en el menú desplegable).

    +
    +

    Configurar Mem0 con Milvus

    En este ejemplo utilizaremos OpenAI como LLM. Deberías preparar la clave api OPENAI_API_KEY como variable de entorno.

    +
    import os
    +
    +os.environ["OPENAI_API_KEY"] = "sk-***********"
    +
    +

    Ahora, podemos configurar Mem0 para utilizar Milvus como almacén de vectores

    +
    # Define Config
    +from mem0 import Memory
    +
    +config = {
    +    "vector_store": {
    +        "provider": "milvus",
    +        "config": {
    +            "collection_name": "quickstart_mem0_with_milvus",
    +            "embedding_model_dims": "1536",
    +            "url": "./milvus.db",  # Use local vector database for demo purpose
    +        },
    +    },
    +    "version": "v1.1",
    +}
    +
    +m = Memory.from_config(config)
    +
    +
    +
    +
      +
    • Si sólo necesitas una base de datos de vectores local para datos a pequeña escala o prototipado, configurar la uri como un archivo local, por ejemplo./milvus.db, es el método más conveniente, ya que automáticamente utiliza Milvus Lite para almacenar todos los datos en este archivo.
    • +
    • Si tiene una gran escala de datos, digamos más de un millón de vectores, puede configurar un servidor Milvus más eficiente en Docker o Kubernetes. En esta configuración, por favor utilice la dirección del servidor y el puerto como su uri, por ejemplohttp://localhost:19530. Si habilita la función de autenticación en Milvus, utilice "<su_nombre_de_usuario>:<su_contraseña>" como token, de lo contrario no configure el token.
    • +
    • Si utiliza Zilliz Cloud, el servicio en la nube totalmente gestionado para Milvus, ajuste uri y token, que se corresponden con el Public Endpoint y la clave API en Zilliz Cloud.
    • +
    +
    +
    +

    Gestión de memorias de usuario con Mem0 y Milvus

    Añadir una memoria

    La función add almacena texto no estructurado en Milvus como una memoria, asociándolo con un usuario específico y metadatos opcionales.

    +

    Aquí, estamos añadiendo la memoria de Alice, "trabajando en mejorar mis habilidades de tenis", junto con metadatos relevantes para el contexto de Milvus.

    +
    # Add a memory to user: Working on improving tennis skills
    +res = m.add(
    +    messages="I am working on improving my tennis skills.",
    +    user_id="alice",
    +    metadata={"category": "hobbies"},
    +)
    +
    +res
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Working on improving tennis skills',
    +   'event': 'ADD'}],
    + 'relations': []}
    +
    +

    Actualizar una memoria

    Podemos utilizar el valor de retorno de la función add para recuperar el ID de la memoria, lo que nos permite actualizar esta memoria con nueva información a través de update.

    +
    # Get memory_id
    +memory_id = res["results"][0]["id"]
    +
    +# Update this memory with new information: Likes to play tennis on weekends
    +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
    +
    +
    {'message': 'Memory updated successfully!'}
    +
    +

    Obtener todas las memorias de un usuario

    Podemos utilizar la función get_all para ver todas las memorias insertadas o filtrar por user_id en Milvus.

    +

    Observe que la memoria ha cambiado de "Trabajando para mejorar sus habilidades tenísticas" a "Le gusta jugar al tenis los fines de semana".

    +
    # Get all memory for the user Alice
    +m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'}]}
    +
    +

    Ver el historial de actualizaciones de la memoria

    También podemos ver el historial de actualización de la memoria especificando qué memory_id nos interesa a través de la función history.

    +
    m.history(memory_id=memory_id)
    +
    +
    [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': None,
    +  'new_memory': 'Working on improving tennis skills',
    +  'event': 'ADD',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': None},
    + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': 'Working on improving tennis skills',
    +  'new_memory': 'Likes to play tennis on weekends',
    +  'event': 'UPDATE',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
    +
    +

    Buscar memoria

    Podemos utilizar la función search para buscar la memoria más relacionada con el usuario.

    +

    Empecemos añadiendo otra memoria para Alice.

    +
    new_mem = m.add(
    +    "I have a linear algebra midterm exam on November 20",
    +    user_id="alice",
    +    metadata={"category": "task"},
    +)
    +
    +

    Ahora, llamamos a get_all especificando el user_id para verificar que efectivamente tenemos 2 entradas de memoria para el usuario Alice.

    +
    m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Ahora podemos realizar search proporcionando query y user_id. Ten en cuenta que por defecto estamos utilizando la métrica L2 para la búsqueda de similitud, por lo que un score más pequeño significa mayor similitud.

    +
    m.search(query="What are Alice's hobbies", user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'score': 1.2807445526123047,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'score': 1.728922724723816,
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Borrar memoria

    También podemos delete una memoria proporcionando la correspondiente memory_id.

    +

    Eliminaremos la memoria "Le gusta jugar al tenis los fines de semana", ya que su memory_id ya ha sido recuperada, y llamaremos a get_all para verificar que la eliminación se ha realizado correctamente.

    +
    m.delete(memory_id=memory_id)
    +
    +m.get_all("alice")
    +
    +
    {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    diff --git a/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..5f983ac22 --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Utilizar Milvus en DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Requisitos","href":"Requirements","type":2,"isActive":false},{"label":"Clonar el repositorio","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Añadir dependencia","href":"Add-dependency","type":2,"isActive":false},{"label":"Establecer variables de entorno","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Inicie los servicios","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..30fe9bdfb --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,142 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + En este tutorial, le mostraremos cómo utilizar Milvus como base de datos + vectorial backend para DocsGPT. +title: Utilizar Milvus en DocsGPT +--- +

    Utilizar Milvus en DocsGPT

    DocsGPT es una solución avanzada de código abierto que simplifica la búsqueda de información en la documentación de proyectos mediante la integración de potentes modelos GPT. Permite a los desarrolladores obtener fácilmente respuestas precisas a sus preguntas sobre un proyecto, eliminando las búsquedas manuales que tanto tiempo consumen.

    +

    En este tutorial, le mostraremos cómo utilizar Milvus como base de datos vectorial backend para DocsGPT.

    +
    +

    Este tutorial hace referencia principalmente a la guía de instalación oficial de DocsGPT. Si encuentra que este tutorial tiene partes desactualizadas, puede priorizar seguir la guía oficial y crearnos un issue.

    +
    +

    Requisitos

    Asegúrate de tener Docker instalado

    +

    Clonar el repositorio

    Clona el repositorio y navega hasta él:

    +
    $ git clone https://github.com/arc53/DocsGPT.git
    +$ cd DocsGPT
    +
    +

    Añadir dependencia

    Añade la dependencia langchain-milvus al archivo requirements.txt bajo la carpeta application:

    +
    $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
    +
    +

    Establecer variables de entorno

    Añade VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... a las variables de entorno para los servicios backend y worker en el archivo docker-compose.yaml, tal y como se muestra a continuación:

    +
      backend:
    +    build: ./application
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +
      worker:
    +    build: ./application
    +    command: celery -A application.app.celery worker -l INFO -B
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +

    Para los servicios MILVUS_URI y MILVUS_TOKEN, puede utilizar el servicio Zilliz Cloud(Recomendado) totalmente gestionado o el servicio Milvus iniciado manualmente.

    +
      +
    • Para el servicio Zillz Cloud totalmente gestionado: Recomendamos utilizar el servicio Zilliz Cloud. Puede registrarse para obtener una cuenta de prueba gratuita en Zilliz Cloud. Después, obtendrá MILVUS_URI y MILVUS_TOKEN, que corresponden al punto final público y a la clave API.

    • +
    • Para iniciar manualmente el servicio Milvus: Si desea configurar un servicio Milvus, puede seguir la documentación oficial de Milvus para configurar un servidor Milvus y, a continuación, obtener los MILVUS_URI y MILVUS_TOKEN del servidor. Los MILVUS_URI y MILVUS_TOKEN deben tener el formato http://<your_server_ip>:19530 y <your_username>:<your_password> respectivamente.

    • +
    +

    Inicie los servicios

    Ejecútalos: ./setup.sh

    +

    A continuación, vaya a http://localhost:5173/.

    +

    Puedes jugar con la interfaz de usuario y hacer preguntas sobre tus documentos.

    +

    + + alt text + texto alternativo

    +

    Si quieres parar los servicios, ejecuta:

    +
    $ docker-compose down
    +
    +

    Para más detalles y configuraciones más avanzadas, consulta la documentación oficial de DocsGPT.

    diff --git a/localization/v2.4.x/site/es/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/es/integrations/use_milvus_in_private_gpt.md index 345235a4a..21fc34ada 100644 --- a/localization/v2.4.x/site/es/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/es/integrations/use_milvus_in_private_gpt.md @@ -67,13 +67,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    PrivateGPT permite personalizar la configuración. Necesitamos especificar la configuración de algunos módulos. En este tutorial, utilizaremos los siguientes módulos:

    +

    PrivateGPT permite personalizar la configuración de algunos módulos, por ejemplo LLM, Embeddings, Vector Stores, UI.

    +

    En este tutorial, utilizaremos los siguientes módulos:

    • LLM: Ollama
    • Embeddings: Ollama
    • Almacenes vectoriales: Milvus
    • IU: Gradio
    +

    Ejecute el siguiente comando para utilizar la poesía para instalar las dependencias de los módulos necesarios:

    $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
     

    Iniciar el servicio Ollama

    Vaya a ollama.ai y siga las instrucciones para instalar Ollama en su máquina.

    -

    Tras la instalación, asegúrese de que la aplicación de escritorio de Ollama está cerrada.

    +

    Tras la instalación, asegúrate de que la aplicación de escritorio de Ollama está cerrada.

    Ahora, inicie el servicio Ollama (iniciará un servidor de inferencia local, sirviendo tanto al LLM como a los Embeddings):

    $ ollama serve
     
    -

    Instale los modelos que se van a utilizar, por defecto settings-ollama.yaml está configurado para el usuario llama3.1 8b LLM (~4GB) y nomic-embed-text Embeddings (~275MB)

    +

    Instale los modelos que se van a utilizar, por defecto settings-ollama.yaml está configurado para el usuario llama3.1 8b LLM (~4GB) y nomic-embed-text Embeddings (~275MB)

    Por defecto, PrivateGPT extraerá automáticamente los modelos según sea necesario. Este comportamiento puede cambiarse modificando la propiedad ollama.autopull_models.

    En cualquier caso, si desea extraer modelos manualmente, ejecute los siguientes comandos:

    $ ollama pull llama3.1
    @@ -133,7 +135,7 @@ $ ollama pull nomic-embed-text
     Campo OpciónDescripción
     
     
    -uriPor defecto se establece en "local_data/private_gpt/milvus/milvus_local.db" como un archivo local; también puede configurar un servidor Milvus de mayor rendimiento en docker o k8s, por ejemplo http://localhost:19530, como su uri; Para utilizar Zilliz Cloud, ajuste la uri y el token a Endpoint y Api key en Zilliz Cloud.
    +uriPor defecto se establece en "local_data/private_gpt/milvus/milvus_local.db" como archivo local; también puede configurar un servidor Milvus de mayor rendimiento en docker o k8s, por ejemplo http://localhost:19530, como su uri; Para utilizar Zilliz Cloud, ajuste la uri y el token a Public Endpoint y API key en Zilliz Cloud.
     tokenEmparejar con el servidor Milvus en docker o k8s o la clave api de Zilliz Cloud.
     nombre_colecciónEl nombre de la colección, establecido por defecto "milvus_db".
     sobrescribirSobrescribe los datos de la colección si ya existían, establecido por defecto como True.
    @@ -154,10 +156,10 @@ $ ollama pull nomic-embed-text
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    Una vez realizadas todas las configuraciones, puede ejecutar PrivateGPT con una gradio UI.

    +

    Una vez realizados todos los ajustes, puede ejecutar PrivateGPT con la interfaz de Gradio.

    PGPT_PROFILES=ollama make run
     
    -

    La interfaz de usuario estará disponible enhttp://0.0.0.0:8001.

    +

    La interfaz de usuario estará disponible en http://0.0.0.0:8001.

    @@ -165,3 +167,4 @@ $ ollama pull nomic-embed-text

    Puede jugar con la interfaz y hacer preguntas sobre sus documentos.

    +

    Para más información, consulte la documentación oficial de Private GPT.

    diff --git a/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..d1c22ab2b --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Utilice Milvus con SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Prerrequisitos","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonar el repositorio","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Cambiar el tipo de almacén vectorial","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Instalar dependencias","href":"Install-dependencies","type":2,"isActive":false},{"label":"Iniciar la aplicación","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..be125e16b --- /dev/null +++ b/localization/v2.4.x/site/es/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,135 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + Este tutorial aprovecha la integración de Milvus en SambaNova AI Starter Kits + para construir un sistema de recuperación de conocimiento empresarial, similar + a RAG (Retrieval-Augmented Generation), para la recuperación y respuesta + basada en los documentos privados de la empresa. +title: Utilice Milvus con SambaNova +--- +

    Utilice Milvus con SambaNova

    SambaNova es una innovadora plataforma tecnológica de IA que acelera el despliegue de capacidades avanzadas de IA y aprendizaje profundo. Diseñada para uso empresarial, permite a las organizaciones aprovechar la IA generativa para mejorar el rendimiento y la eficiencia. Al proporcionar soluciones de vanguardia como SambaNova Suite y DataScale, la plataforma permite a las empresas extraer información valiosa de sus datos, impulsando mejoras operativas y fomentando nuevas oportunidades en el panorama de la IA.

    +

    Los SambaNova AI Starter Kits son una colección de recursos de código abierto diseñados para ayudar a los desarrolladores y a las empresas a desplegar aplicaciones basadas en IA con SambaNova. Estos kits proporcionan ejemplos prácticos y guías que facilitan la implementación de varios casos de uso de IA, facilitando a los usuarios el aprovechamiento de la avanzada tecnología de SambaNova.

    +

    Este tutorial aprovecha la integración de Milvus en SambaNova AI Starter Kits para construir un sistema de recuperación de conocimiento empresarial, similar a RAG (Retrieval-Augmented Generation), para recuperar y responder basándose en los documentos privados de la empresa.

    +
    +

    Este tutorial se refiere principalmente a la guía oficial de SambaNova AI Starter Kits. Si usted encuentra que este tutorial tiene partes obsoletas, puede dar prioridad a seguir la guía oficial y crear un problema para nosotros.

    +
    +

    Prerrequisitos

    Recomendamos usar Python >= 3.10 y < 3.12.

    +

    Visita SambaNova Cloud para obtener una clave API de SambaNova.

    +

    Clonar el repositorio

    $ git clone https://github.com/sambanova/ai-starter-kit.git
    +$ d ai-starter-kit/enterprise_knowledge_retriever
    +
    +

    Cambiar el tipo de almacén vectorial

    Cambie el almacén de vectores configurando db_type='milvus' en las funciones create_vector_store() y load_vdb() en src/document_retrieval.py.

    +
    ...
    +vectorstore = self.vectordb.create_vector_store(
    +    ..., db_type='milvus'
    +)
    +...
    +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
    +
    +

    Instalar dependencias

    Instale las dependencias necesarias ejecutando el siguiente comando:

    +
    python3 -m venv enterprise_knowledge_env
    +source enterprise_knowledge_env/bin/activate
    +pip install -r requirements.txt
    +
    +

    Iniciar la aplicación

    Utilice el siguiente comando para iniciar la aplicación:

    +
    $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
    +
    +

    Después de eso, verá la interfaz de usuario en su navegador:http://localhost:8501/

    +

    + + + + +

    +

    Después de establecer su clave API SambaNova en la interfaz de usuario, puede jugar con la interfaz de usuario y hacer preguntas acerca de sus documentos.

    +

    Para más detalles, consulte la documentación oficial de Enterprise Knowledge Retrieval of SambaNova AI Starter Kits.

    diff --git a/localization/v2.4.x/site/es/menuStructure/es.json b/localization/v2.4.x/site/es/menuStructure/es.json index 057cc8015..0a3ce1f2a 100644 --- a/localization/v2.4.x/site/es/menuStructure/es.json +++ b/localization/v2.4.x/site/es/menuStructure/es.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "Usuarios y funciones", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "Réplica en memoria", "id": "replica.md", @@ -839,7 +833,7 @@ "children": [] }, { - "label": "Configurar Chunk Cache", + "label": "Configurar la caché de trozos", "id": "chunk_cache.md", "order": 3, "children": [] @@ -1036,7 +1030,7 @@ "isMenu": true, "children": [ { - "label": "Rastreo de Jaeger", + "label": "Seguimiento de Jaeger", "id": "config_jaeger_tracing.md", "order": 0, "children": [] @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "Usuarios, privilegios y funciones", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "Activar RBAC", "id": "rbac.md", @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivadoGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Tabla de conocimientos", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Búsqueda en embudo con incrustaciones de matrioskas", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "Más información", "id": "explore-more", diff --git a/localization/v2.4.x/site/es/reference/knowhere.json b/localization/v2.4.x/site/es/reference/knowhere.json index b6e22f2b7..68694c97f 100644 --- a/localization/v2.4.x/site/es/reference/knowhere.json +++ b/localization/v2.4.x/site/es/reference/knowhere.json @@ -1 +1 @@ -{"codeList":[],"headingContent":"","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Visión General","href":"Overview","type":2,"isActive":false},{"label":"Knowhere en la arquitectura Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Ventajas de Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Estructura del código Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Añadir índices a Knowhere","href":"Adding-indexes-to-Knowhere","type":2,"isActive":false},{"label":"Lo que sigue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":[],"headingContent":"Knowhere","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Knowhere en la arquitectura Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Ventajas de Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Estructura del código Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Añadir índices a Knowhere","href":"Adding-indices-to-Knowhere","type":2,"isActive":false},{"label":"Lo que sigue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/reference/knowhere.md b/localization/v2.4.x/site/es/reference/knowhere.md index e1091f7a0..ba967bc2e 100644 --- a/localization/v2.4.x/site/es/reference/knowhere.md +++ b/localization/v2.4.x/site/es/reference/knowhere.md @@ -19,7 +19,7 @@ title: Knowhere >

    Este tema presenta Knowhere, el motor central de ejecución vectorial de Milvus.

    -

    Visión General

    Knowhere es el motor central de ejecución vectorial de Milvus que incorpora varias bibliotecas de búsqueda de similitud vectorial incluyendo Faiss, Hnswlib y Annoy. Knowhere también está diseñado para soportar computación heterogénea. Controla en qué hardware (CPU o GPU) ejecutar la construcción de índices y las peticiones de búsqueda. Así es como Knowhere obtiene su nombre - sabiendo dónde ejecutar las operaciones. Más tipos de hardware incluyendo DPU y TPU serán soportados en futuras versiones.

    +

    Knowhere es el motor central de ejecución vectorial de Milvus, que incorpora varias bibliotecas de búsqueda de similitud vectorial, incluyendo Faiss, Hnswlib y Annoy. Knowhere también está diseñado para soportar computación heterogénea. Controla en qué hardware (CPU o GPU) ejecutar la creación de índices y las peticiones de búsqueda. Así es como Knowhere obtiene su nombre - sabiendo dónde ejecutar las operaciones. Más tipos de hardware incluyendo DPU y TPU serán soportados en futuras versiones.

    Knowhere en la arquitectura Milvus

    Las siguientes son las ventajas de Knowhere sobre Faiss.

    Soporte para BitsetView

    Milvus introduce un mecanismo de conjunto de bits para realizar el "borrado suave". Un vector borrado suavemente aún existe en la base de datos pero no será computado durante una búsqueda o consulta de similitud de vectores.

    -

    Cada bit de un conjunto de bits corresponde a un vector indexado. Si un vector está marcado como "1" en el conjunto de bits, significa que se ha eliminado de forma suave y que no participará en la búsqueda de vectores. El parámetro bitset se aplica a todas las API de consulta de índice Faiss expuestas en Knowhere, incluidos los índices de CPU y GPU.

    +

    Cada bit de un conjunto de bits corresponde a un vector indexado. Si un vector está marcado con un "1" en el conjunto de bits, significa que se ha eliminado de forma suave y no participará en la búsqueda de vectores. El parámetro bitset se aplica a todas las API de consulta de índice Faiss expuestas en Knowhere, incluidos los índices de CPU y GPU.

    Para obtener más información sobre el mecanismo de bitset, consulte bitset.

    Soporte para múltiples métricas de similitud para indexar vectores binarios

    Knowhere soporta Hamming, Jaccard, Tanimoto, Superestructura y Subestructura. Jaccard y Tanimoto pueden utilizarse para medir la similitud entre dos conjuntos de muestras mientras que Superstructure y Substructure pueden utilizarse para medir la similitud de estructuras químicas.

    Compatibilidad con el conjunto de instrucciones AVX512

    Además de AArch64, SSE4.2 y AVX2, los conjuntos de instrucciones ya soportados por Faiss, Knowhere también soporta AVX512, que puede mejorar el rendimiento de la creación de índices y consultas entre un 20% y un 30% en comparación con AVX2.

    @@ -107,7 +107,7 @@ title: Knowhere
    • El índice Faiss tiene dos clases base: FaissBaseIndex para todos los índices sobre vectores en coma flotante, y FaissBaseBinaryIndex para todos los índices sobre vectores binarios.

    • GPUIndex es la clase base para todos los índices GPU de Faiss.

    • -
    • OffsetBaseIndex es la clase base para todos los índices de desarrollo propio. Dado que en un fichero de índices sólo se almacenan los ID de los vectores, el tamaño del fichero para vectores de 128 dimensiones puede reducirse en 2 órdenes de magnitud.

    • +
    • OffsetBaseIndex es la clase base para todos los índices de desarrollo propio. Dado que en un archivo de índice sólo se almacenan los ID de los vectores, el tamaño del archivo para vectores de 128 dimensiones puede reducirse en 2 órdenes de magnitud.

    @@ -115,19 +115,19 @@ title: Knowhere IDMAP

    Técnicamente hablando, IDMAP no es un índice, sino que se utiliza para la búsqueda por fuerza bruta. Cuando se insertan vectores en la base de datos, no es necesario ni el entrenamiento de los datos ni la construcción de índices. Las búsquedas se realizarán directamente sobre los datos vectoriales insertados.

    Sin embargo, por coherencia del código, IDMAP también hereda de la clase VecIndex con todas sus interfaces virtuales. El uso de IDMAP es el mismo que el de otros índices.

    -

    Índices IVF

    +

    Índices IVF

    IVF IVF

    -

    Los índices IVF (archivo invertido) son los más utilizados. La clase IVF deriva de VecIndex y FaissBaseIndex, y se extiende a IVFSQ y IVFPQ. GPUIVF deriva de GPUIndex y IVF. A continuación, GPUIVF se amplía a GPUIVFSQ y GPUIVFPQ.

    -

    IVFSQHybrid es un índice híbrido de desarrollo propio. El cuantificador grueso se ejecuta en la GPU mientras que la búsqueda en el cubo se realiza en la CPU. Este tipo de índice puede reducir el número de copias de memoria entre la CPU y la GPU aprovechando la potencia de cálculo de la GPU. IVFSQHybrid tiene la misma tasa de recuperación que GPUIVFSQ pero ofrece un mejor rendimiento.

    -

    La estructura de la clase base de los índices binarios es relativamente más sencilla. BinaryIDMAP y BinaryIVF derivan de FaissBaseBinaryIndex y VecIndex.

    -

    Índices de terceros

    +

    Los índices IVF (archivo invertido) son los más utilizados. La clase IVF se deriva de VecIndex y FaissBaseIndex, y se extiende a IVFSQ y IVFPQ. GPUIVF se deriva de GPUIndex y IVF. A continuación, GPUIVF se amplía a GPUIVFSQ y GPUIVFPQ.

    +

    IVFSQHybrid es un índice híbrido de desarrollo propio. Un cuantificador grueso se ejecuta en la GPU mientras que la búsqueda en el cubo se realiza en la CPU. Este tipo de índice puede reducir el número de copias de memoria entre la CPU y la GPU aprovechando la potencia de cálculo de la GPU. IVFSQHybrid tiene la misma tasa de recuperación que GPUIVFSQ pero ofrece un mejor rendimiento.

    +

    La estructura de clases base de los índices binarios es relativamente más sencilla. BinaryIDMAP y BinaryIVF derivan de FaissBaseBinaryIndex y VecIndex.

    +

    Índices de terceros

    - third-party indexes + third-party indices índices de terceros

    -

    Actualmente, sólo se admiten dos tipos de índices de terceros aparte de Faiss: el índice basado en árboles Annoy, y el índice basado en gráficos HNSW. Estos dos índices de terceros, comunes y de uso frecuente, derivan de VecIndex.

    -

    Añadir índices a Knowhere

    Después de aprender cómo funciona Knowhere en Milvus, es posible que también desee:

    diff --git a/localization/v2.4.x/site/es/reference/schema.json b/localization/v2.4.x/site/es/reference/schema.json index bb176dc31..e303e9d0e 100644 --- a/localization/v2.4.x/site/es/reference/schema.json +++ b/localization/v2.4.x/site/es/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gestionar esquema","href":"Manage-Schema","type":1,"isActive":false},{"label":"Esquema de campo","href":"Field-schema","type":2,"isActive":false},{"label":"Esquema de colección","href":"Collection-schema","type":2,"isActive":false},{"label":"A continuación","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gestionar esquema","href":"Manage-Schema","type":1,"isActive":false},{"label":"Esquema de campo","href":"Field-schema","type":2,"isActive":false},{"label":"Esquema de colección","href":"Collection-schema","type":2,"isActive":false},{"label":"A continuación","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/reference/schema.md b/localization/v2.4.x/site/es/reference/schema.md index 6036110fa..00aaf59d7 100644 --- a/localization/v2.4.x/site/es/reference/schema.md +++ b/localization/v2.4.x/site/es/reference/schema.md @@ -39,12 +39,15 @@ title: Gestionar esquema

    Propiedades del esquema de campo

    - + + + + - + @@ -75,7 +78,7 @@ title: Gestionar esquema - + @@ -129,7 +132,7 @@ fields = [
    • BINARY_VECTOR: Almacena datos binarios como una secuencia de 0 y 1. Se utiliza para la representación compacta de características en el procesamiento de imágenes y la recuperación de información.
    • FLOAT_VECTOR: Almacena números de coma flotante de 32 bits, utilizados habitualmente en computación científica y aprendizaje automático para representar números reales.
    • -
    • FLOAT16_VECTOR: Almacena números de coma flotante de 16 bits y media precisión, utilizados en el aprendizaje profundo y los cálculos de GPU para la eficiencia de la memoria y el ancho de banda.
    • +
    • FLOAT16_VECTOR: Almacena números de coma flotante de 16 bits de media precisión, utilizados en el aprendizaje profundo y los cálculos de GPU para la eficiencia de la memoria y el ancho de banda.
    • BFLOAT16_VECTOR: Almacena números de punto flotante de 16 bits con precisión reducida pero el mismo rango de exponentes que Float32, popular en el aprendizaje profundo para reducir los requisitos de memoria y computación sin afectar significativamente a la precisión.
    • SPARSE_FLOAT_VECTOR: Almacena una lista de elementos distintos de cero y sus índices correspondientes, utilizados para representar vectores dispersos. Para más información, consulte Vectores dispersos.
    @@ -151,10 +154,13 @@ fields = [ >

    Un esquema de colección es la definición lógica de una colección. Normalmente es necesario definir el esquema de campo antes de definir un esquema de colección y gestionar colecciones.

    -

    Propiedades del esquema de colección

    PropiedadesDescripción Nota
    PropiedadesDescripciónNota
    nameNombre del campo en la colección a crearNombre del campo de la colección que se va a crear Tipo de datos: Cadena.
    Obligatorio
    dim Dimensión del vectorTipo de datos: Integer ∈[1, 32768].
    Obligatorio para un campo vectorial denso. Omitir para un campo vectorial disperso.
    Tipo de datos: Entero ∈[1, 32768].
    Obligatorio para un campo vectorial denso. Omitir para un campo vectorial disperso.
    is_partition_key
    +

    Propiedades del esquema de la colección

    - + + + + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

    Cree una colección con el esquema especificado:

    -
    from pymilvus import Collection
    +
    from pymilvus import Collection,connections
    +conn = connections.connect(host="127.0.0.1", port=19530)
     collection_name1 = "tutorial_1"
     collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
     
    diff --git a/localization/v2.4.x/site/es/reference/users_and_roles.json b/localization/v2.4.x/site/es/reference/users_and_roles.json index da2992fe0..1b0d04cee 100644 --- a/localization/v2.4.x/site/es/reference/users_and_roles.json +++ b/localization/v2.4.x/site/es/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"Usuarios y Roles","href":"Users-and-Roles","type":1,"isActive":false},{"label":"Conceptos clave","href":"Key-concepts","type":2,"isActive":false},{"label":"Ejemplo: Concesión de privilegios","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Usuarios y roles por defecto","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Lista de tipos de objeto y privilegios","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"A continuación","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"Usuarios, Privilegios y Roles","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"Conceptos clave","href":"Key-concepts","type":2,"isActive":false},{"label":"Ejemplo: Concesión de privilegios","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Usuarios y roles por defecto","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Lista de tipos de objeto y privilegios","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"A continuación","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/reference/users_and_roles.md b/localization/v2.4.x/site/es/reference/users_and_roles.md index 30289b937..94e3b1d78 100644 --- a/localization/v2.4.x/site/es/reference/users_and_roles.md +++ b/localization/v2.4.x/site/es/reference/users_and_roles.md @@ -4,9 +4,9 @@ related_key: 'users, roles' summary: >- Conozca la definición de usuarios, roles, objetos y privilegios en el control de acceso basado en roles (RBAC). -title: Usuarios y funciones +title: 'Usuarios, Privilegios y Roles' --- -

    Usuarios y Roles

    Para gestionar el control de acceso a los recursos de Milvus, es importante comprender los componentes clave de RBAC: tipos de objetos, nombres de objetos, usuarios, roles y privilegios.

    +

    Para gestionar el control de acceso a los recursos de Milvus, es importante comprender los componentes clave de RBAC: tipos de objeto, nombres de objeto, usuarios, roles y privilegios.

      -
    • Tipo de objeto: la categoría del objeto al que se asigna un privilegio. El tipo de objeto puede ser:

      +
    • Tipo de objeto: la categoría del objeto al que se asigna un privilegio. El tipo de objeto puede ser:

      • Global: Objetos de todo el sistema, que permiten al usuario realizar acciones que afectan a todas las colecciones, usuarios o configuraciones de todo el sistema.
      • Collection: Objetos específicos de la colección, que permiten al usuario realizar acciones como crear índices, cargar datos, insertar o eliminar datos y consultar datos dentro de una colección específica.
      • @@ -193,12 +193,12 @@ client.grantPrivilege(grantPrivilegeReq);
    - + - +
    PropiedadesDescripción Nota
    PropiedadesDescripciónNota
    GlobalRéplica de transferenciaRéplica de transferencia
    GlobalCrearBaseDeDatosCrearBaseDeDatos
    GlobalDropDatabaseDropDatabase
    GlobalListDatabasesListDatabases
    GlobalListDatabasesBasesDeDatosDeLista
    GlobalCrear aliasCrear alias
    GlobalDropAliasDropAlias
    GlobalDescribeAliasDescribeAlias
    GlobalListAliasesLista de alias
    UsuarioActualizarUsuarioUpdateCredential
    UsuarioUpdateUserUpdateCredential
    UsuarioSeleccionarUsuarioSeleccionarUsuario
    diff --git a/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..0e5ac6c1c --- /dev/null +++ b/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"Búsqueda en embudo con incrustaciones Matryoshka","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"Cargar el modelo de incrustación Matryoshka","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"Carga del conjunto de datos, incrustación de elementos y creación de la base de datos vectorial","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"Búsqueda en embudo","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"Comparación de la búsqueda en embudo con la búsqueda normal","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"Investigación del fracaso de la búsqueda en embudo en Ferris Bueller's Day Off","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"¿Importa el orden? Incrustaciones de prefijos y sufijos.","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"Resumen","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..3bd70f23e --- /dev/null +++ b/localization/v2.4.x/site/es/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,571 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + En este cuaderno, examinamos cómo utilizar las incrustaciones Matryoshka con + Milvus para la búsqueda semántica. Ilustramos un algoritmo llamado "búsqueda + de embudo" que nos permite realizar búsquedas de similitud en un pequeño + subconjunto de nuestras dimensiones de incrustación sin una caída drástica en + la recuperación. +title: Búsqueda en embudo con incrustaciones Matryoshka +--- +

    Búsqueda en embudo con incrustaciones Matryoshka

    A la hora de crear sistemas de búsqueda vectorial eficientes, uno de los principales retos es gestionar los costes de almacenamiento manteniendo una latencia y una recuperación aceptables. Los modelos de incrustación modernos producen vectores con cientos o miles de dimensiones, lo que genera una importante sobrecarga computacional y de almacenamiento para el vector en bruto y el índice.

    +

    Tradicionalmente, los requisitos de almacenamiento se reducen aplicando un método de cuantificación o reducción de la dimensionalidad justo antes de construir el índice. Por ejemplo, podemos ahorrar almacenamiento reduciendo la precisión mediante la cuantificación de productos (PQ) o el número de dimensiones mediante el análisis de componentes principales (PCA). Estos métodos analizan todo el conjunto de vectores para encontrar uno más compacto que mantenga las relaciones semánticas entre vectores.

    +

    Aunque eficaces, estos enfoques estándar reducen la precisión o la dimensionalidad una sola vez y a una sola escala. Pero, ¿y si pudiéramos mantener varias capas de detalle simultáneamente, como una pirámide de representaciones cada vez más precisas?

    +

    He aquí las incrustaciones Matryoshka. Estas ingeniosas construcciones, que deben su nombre a las muñecas rusas (véase la ilustración), integran múltiples escalas de representación en un único vector. A diferencia de los métodos tradicionales de posprocesamiento, las incrustaciones Matryoshka aprenden esta estructura multiescala durante el proceso de entrenamiento inicial. El resultado es notable: no sólo la incrustación completa capta la semántica de entrada, sino que cada prefijo de subconjunto anidado (primera mitad, primer cuarto, etc.) proporciona una representación coherente, aunque menos detallada.

    +
    +

    En este cuaderno, examinamos cómo utilizar las incrustaciones Matryoshka con Milvus para la búsqueda semántica. Ilustramos un algoritmo llamado "búsqueda en embudo" que nos permite realizar búsquedas de similitud en un pequeño subconjunto de nuestras dimensiones de incrustación sin que se produzca una caída drástica de la recuperación.

    +
    import functools
    +
    +from datasets import load_dataset
    +import numpy as np
    +import pandas as pd
    +import pymilvus
    +from pymilvus import MilvusClient
    +from pymilvus import FieldSchema, CollectionSchema, DataType
    +from sentence_transformers import SentenceTransformer
    +import torch
    +import torch.nn.functional as F
    +from tqdm import tqdm
    +
    +

    Cargar el modelo de incrustación Matryoshka

    En lugar de utilizar un modelo de incrustación estándar como sentence-transformers/all-MiniLM-L12-v2utilizamos un modelo de Nomic entrenado especialmente para producir incrustaciones Matryoshka.

    +
    model = SentenceTransformer(
    +    # Remove 'device='mps' if running on non-Mac device
    +    "nomic-ai/nomic-embed-text-v1.5",
    +    trust_remote_code=True,
    +    device="mps",
    +)
    +
    +
    <All keys matched successfully>
    +
    +

    Carga del conjunto de datos, incrustación de elementos y creación de la base de datos vectorial

    El siguiente código es una modificación del de la página de documentación "Movie Search with Sentence Transformers and Milvus". En primer lugar, cargamos el conjunto de datos de HuggingFace. Contiene unas 35.000 entradas, cada una de las cuales corresponde a una película que tiene un artículo en Wikipedia. En este ejemplo utilizaremos los campos Title y PlotSummary.

    +
    ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
    +print(ds)
    +
    +
    Dataset({
    +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
    +    num_rows: 34886
    +})
    +
    +

    A continuación, nos conectamos a una base de datos Milvus Lite, especificamos el esquema de datos y creamos una colección con este esquema. Almacenaremos tanto la incrustación no normalizada como la primera sexta parte de la incrustación en campos separados. La razón es que necesitamos la primera sexta parte de la Matryoshka para realizar una búsqueda de similitudes, y las 5/6 partes restantes de las incrustaciones para volver a clasificar y mejorar los resultados de la búsqueda.

    +
    embedding_dim = 768
    +search_dim = 128
    +collection_name = "movie_embeddings"
    +
    +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    # First sixth of unnormalized embedding vector
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    # Entire unnormalized embedding vector
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +

    Milvus no admite actualmente la búsqueda en subconjuntos de incrustaciones, por lo que dividimos las incrustaciones en dos partes: la cabeza representa el subconjunto inicial del vector para indexar y buscar, y la cola es el resto. El modelo está entrenado para la búsqueda de similitudes por distancia coseno, por lo que normalizamos las incrustaciones de la cabeza. Sin embargo, para poder calcular posteriormente las similitudes de subconjuntos más grandes, necesitamos almacenar la norma de la incrustación de la cabeza, de modo que podamos desnormalizarla antes de unirla a la cola.

    +

    Para realizar la búsqueda a través del primer 1/6 de la incrustación, necesitaremos crear un índice de búsqueda vectorial sobre el campo head_embedding. Más adelante, compararemos los resultados de la "búsqueda en embudo" con una búsqueda vectorial normal, por lo que también crearemos un índice de búsqueda sobre la incrustación completa.

    +

    Es importante destacar que utilizamos la métrica de distancia COSINE en lugar de IP, porque de lo contrario tendríamos que realizar un seguimiento de las normas de incrustación, lo que complicaría la implementación (esto tendrá más sentido una vez que se haya descrito el algoritmo de búsqueda de embudo).

    +
    index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
    +client.create_index(collection_name, index_params)
    +
    +

    Por último, codificamos los resúmenes argumentales de las 35.000 películas e introducimos las incrustaciones correspondientes en la base de datos.

    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    # This particular model requires us to prefix 'search_document:' to stored entities
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Output of embedding model is unnormalized
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
    +
    +

    Hagamos ahora una "búsqueda en embudo" utilizando el primer 1/6 de las dimensiones de la Matrioska. Tengo tres películas en mente para recuperar y he elaborado mi propio resumen de trama para consultar la base de datos. Incrustamos las consultas y, a continuación, realizamos una búsqueda vectorial en el campo head_embedding, recuperando 128 candidatos a resultado.

    +
    queries = [
    +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
    +    "A teenager fakes illness to get off school and have adventures with two friends.",
    +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +# This particular model requires us to prefix 'search_query:' to queries
    +instruct_queries = ["search_query: " + q.strip() for q in queries]
    +search_data = embed_search(instruct_queries)
    +
    +# Normalize head embeddings
    +head_search = [x[:search_dim] for x in search_data]
    +
    +# Perform standard vector search on first sixth of embedding dimensions
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +

    En este punto, hemos realizado la búsqueda en un espacio vectorial mucho más pequeño y, por tanto, es probable que hayamos reducido la latencia y los requisitos de almacenamiento del índice en relación con la búsqueda en el espacio completo. Examinemos las 5 primeras coincidencias para cada consulta:

    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits][:5]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +The Passage
    +Counterblast
    +Dominion: Prequel to the Exorcist
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +How to Deal
    +Shorts
    +Blackbird
    +Valentine
    +Unfriended
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +Ghostkeeper
    +Our Vines Have Tender Grapes
    +The Ref
    +Impact
    +The House in Marsh Road
    +
    +

    Como vemos, la recuperación se ha visto afectada por el truncamiento de las incrustaciones durante la búsqueda. La búsqueda en embudo soluciona este problema con un truco inteligente: podemos utilizar el resto de las dimensiones de la incrustación para volver a clasificar y podar nuestra lista de candidatos y recuperar el rendimiento de la recuperación sin necesidad de realizar costosas búsquedas vectoriales adicionales.

    +

    Para facilitar la exposición del algoritmo de búsqueda en embudo, convertimos los resultados de la búsqueda Milvus para cada consulta en un marco de datos Pandas.

    +
    def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
    +    """
    +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
    +
    +    """
    +    rows = [x["entity"] for x in hits]
    +    rows_dict = [
    +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
    +    ]
    +    return pd.DataFrame.from_records(rows_dict)
    +
    +
    +dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +

    Ahora, para realizar la búsqueda en embudo, iteramos sobre subconjuntos cada vez mayores de las incrustaciones. En cada iteración, volvemos a clasificar los candidatos según las nuevas similitudes y eliminamos una fracción de los peor clasificados.

    +

    Para concretar, en el paso anterior hemos recuperado 128 candidatos utilizando 1/6 de las dimensiones de la incrustación y la consulta. El primer paso para realizar la búsqueda en embudo es recalcular las similitudes entre las consultas y los candidatos utilizando el primer tercio de las dimensiones. Se eliminan los 64 candidatos inferiores. A continuación, se repite el proceso con los primeros 2/3 de las dimensiones y, después, con todas las dimensiones, eliminando sucesivamente 32 y 16 candidatos.

    +
    # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
    +def calculate_score(row, query_emb=None, dims=768):
    +    emb = F.normalize(row["embedding"][:dims], dim=-1)
    +    return (emb @ query_emb).item()
    +
    +
    +# You could also add a top-K parameter as a termination condition
    +def funnel_search(
    +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
    +) -> pd.DataFrame:
    +    # Loop over increasing prefixes of the embeddings
    +    for dims in scales:
    +        # Query vector must be normalized for each new dimensionality
    +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
    +
    +        # Score
    +        scores = df.apply(
    +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
    +        )
    +        df["scores"] = scores
    +
    +        # Re-rank
    +        df = df.sort_values(by="scores", ascending=False)
    +
    +        # Prune (in our case, remove half of candidates at each step)
    +        df = df.head(int(prune_ratio * len(df)))
    +
    +    return df
    +
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, search_data)
    +]
    +
    +
    for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    + 0           "Pimpernel" Smith
    +1               Black Hunters
    +29    Raiders of the Lost Ark
    +34             The Master Key
    +51            My Gun Is Quick
    +Name: title, dtype: object 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    + 21               How I Live Now
    +32     On the Edge of Innocence
    +77             Bratz: The Movie
    +4                    Unfriended
    +108                  Simon Says
    +Name: title, dtype: object 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    + 9         The Shining
    +0         Ghostkeeper
    +11     Fast and Loose
    +7      Killing Ground
    +12         Home Alone
    +Name: title, dtype: object 
    +
    +

    Hemos conseguido recuperar la memoria sin realizar ninguna búsqueda vectorial adicional. Cualitativamente, estos resultados parecen ser más eficaces para "En busca del arca perdida" y "El resplandor" que la búsqueda vectorial estándar del tutorial "Búsqueda de películas con Milvus y transformadores de frases", que utiliza un modelo de incrustación diferente. Sin embargo, no es capaz de encontrar "Ferris Bueller's Day Off", a la que volveremos más adelante en el cuaderno. (Véase el artículo Matryoshka Representation Learning para más experimentos cuantitativos y evaluaciones comparativas).

    +

    Comparemos los resultados de nuestra búsqueda en embudo con una búsqueda vectorial estándar en el mismo conjunto de datos con el mismo modelo de incrustación. Realizamos una búsqueda en las incrustaciones completas.

    +
    # Search on entire embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=search_data,
    +    anns_field="embedding",
    +    limit=5,
    +    output_fields=["title", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +Raiders of the Lost Ark
    +The Master Key
    +My Gun Is Quick
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +A Walk to Remember
    +Ferris Bueller's Day Off
    +How I Live Now
    +On the Edge of Innocence
    +Bratz: The Movie
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +The Shining
    +Ghostkeeper
    +Fast and Loose
    +Killing Ground
    +Home Alone
    +
    +

    A excepción de los resultados de "Un adolescente finge una enfermedad para no ir al colegio...", los resultados de la búsqueda en embudo son casi idénticos a los de la búsqueda completa, a pesar de que la búsqueda en embudo se realizó en un espacio de búsqueda de 128 dimensiones frente a las 768 dimensiones de la búsqueda normal.

    +

    Investigación del fracaso de la búsqueda en embudo en Ferris Bueller's Day Off

    ¿Por qué la búsqueda en embudo no consiguió recuperar Ferris Bueller's Day Off? Examinemos si estaba o no en la lista original de candidatos o si se filtró por error.

    +
    queries2 = [
    +    "A teenager fakes illness to get off school and have adventures with two friends."
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +instruct_queries = ["search_query: " + q.strip() for q in queries2]
    +search_data2 = embed_search(instruct_queries)
    +head_search2 = [x[:search_dim] for x in search_data2]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search2,
    +    anns_field="head_embedding",
    +    limit=256,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", queries2[0])
    +    for idx, row in enumerate(rows):
    +        if row["title"].strip() == "Ferris Bueller's Day Off":
    +            print(f"Row {idx}: Ferris Bueller's Day Off")
    +
    +
    Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Row 228: Ferris Bueller's Day Off
    +
    +

    Vemos que el problema era que la lista inicial de candidatos no era lo suficientemente grande, o más bien, el resultado deseado no es lo suficientemente similar a la consulta en el nivel más alto de granularidad. Si se cambia de 128 a 256, la recuperación es satisfactoria. Deberíamos establecer una regla empírica para determinar el número de candidatos de un conjunto retenido a fin de evaluar empíricamente la relación entre recuperación y latencia.

    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries2, dfs, search_data2)
    +]
    +
    +for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
    +
    +
    A teenager fakes illness to get off school and have adventures with two friends. 
    +       A Walk to Remember
    +Ferris Bueller's Day Off
    +          How I Live Now
    +On the Edge of Innocence
    +        Bratz: The Movie
    +              Unfriended
    +              Simon Says 
    +
    +

    ¿Importa el orden? Incrustaciones de prefijos y sufijos.

    El modelo se entrenó para que funcionara bien al emparejar prefijos recursivamente más pequeños de las incrustaciones. ¿Importa el orden de las dimensiones que utilicemos? Por ejemplo, ¿podríamos tomar subconjuntos de las incrustaciones que sean sufijos? En este experimento, invertimos el orden de las dimensiones en las incrustaciones Matryoshka y realizamos una búsqueda en embudo.

    +
    client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +client.create_index(collection_name, index_params)
    +
    +
    huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
    +To disable this warning, you can either:
    +    - Avoid using `tokenizers` before the fork if possible
    +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
    +
    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Encode and flip embeddings
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    embeddings = torch.flip(embeddings, dims=[-1])
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
    +
    +
    # Normalize head embeddings
    +
    +flip_search_data = [
    +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
    +]
    +flip_head_search = [x[:search_dim] for x in flip_search_data]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=flip_head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
    +]
    +
    +for d in dfs_results:
    +    print(
    +        d["query"],
    +        "\n",
    +        d["results"][:7]["title"].to_string(index=False, header=False),
    +        "\n",
    +    )
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    +       "Pimpernel" Smith
    +          Black Hunters
    +Raiders of the Lost Ark
    +         The Master Key
    +        My Gun Is Quick
    +            The Passage
    +        The Mole People 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    +                       A Walk to Remember
    +                          How I Live Now
    +                              Unfriended
    +Cirque du Freak: The Vampire's Assistant
    +                             Last Summer
    +                                 Contest
    +                                 Day One 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    +         Ghostkeeper
    +     Killing Ground
    +Leopard in the Snow
    +              Stone
    +          Afterglow
    +         Unfaithful
    +     Always a Bride 
    +
    +

    La recuperación es mucho peor que la búsqueda en embudo o la búsqueda normal, como era de esperar (el modelo de incrustación se entrenó mediante aprendizaje contrastivo en prefijos de las dimensiones de incrustación, no en sufijos).

    +

    Resumen

    He aquí una comparación de los resultados de búsqueda de los distintos métodos:

    +
    +
    +
    +Hemos mostrado cómo utilizar incrustaciones Matryoshka con Milvus para realizar un algoritmo de búsqueda semántica más eficiente llamado "búsqueda embudo". También hemos explorado la importancia de los pasos de reordenación y poda del algoritmo, así como un modo de fallo cuando la lista inicial de candidatos es demasiado pequeña. Por último, discutimos cómo el orden de las dimensiones es importante a la hora de formar sub-embeddings - debe ser de la misma forma para la que se entrenó el modelo. O mejor dicho, los prefijos de las incrustaciones sólo tienen sentido porque el modelo se entrenó de una determinada manera. Ahora ya sabe cómo implementar las incrustaciones Matryoshka y la búsqueda embudo para reducir los costes de almacenamiento de la búsqueda semántica sin sacrificar demasiado el rendimiento de la recuperación. diff --git a/localization/v2.4.x/site/es/tutorials/tutorials-overview.md b/localization/v2.4.x/site/es/tutorials/tutorials-overview.md index 36a51d39f..fc3f86162 100644 --- a/localization/v2.4.x/site/es/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/es/tutorials/tutorials-overview.md @@ -43,5 +43,6 @@ title: Visión general de los tutoriales Utilizar ColPali para la recuperación multimodal con MilvusInicio rápidoBúsqueda vectorial Visualización de vectoresInicio rápidobúsqueda vectorial Recomendación de películas con MilvusSistema de recomendaciónBúsqueda vectorial +Búsqueda en embudo con Matryoshka EmbeddingsInicio rápidobúsqueda vectorial diff --git a/localization/v2.4.x/site/es/userGuide/manage-collections.json b/localization/v2.4.x/site/es/userGuide/manage-collections.json index 06b8ae653..897e35a15 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/es/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gestionar colecciones","href":"Manage-Collections","type":1,"isActive":false},{"label":"Antes de empezar","href":"Before-you-start","type":2,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Crear colección","href":"Create-Collection","type":2,"isActive":false},{"label":"Ver colecciones","href":"View-Collections","type":2,"isActive":false},{"label":"Cargar y liberar colección","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Establecer alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Establecer propiedades","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonar una colecta","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gestionar colecciones","href":"Manage-Collections","type":1,"isActive":false},{"label":"Antes de empezar","href":"Before-you-start","type":2,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Crear colección","href":"Create-Collection","type":2,"isActive":false},{"label":"Ver colecciones","href":"View-Collections","type":2,"isActive":false},{"label":"Cargar y liberar colección","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Establecer alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Establecer propiedades","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonar una colecta","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/userGuide/manage-collections.md b/localization/v2.4.x/site/es/userGuide/manage-collections.md index 26bf1da82..85002fc0c 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/es/userGuide/manage-collections.md @@ -74,7 +74,7 @@ title: Gestionar colecciones

    Puede crear una colección de cualquiera de las siguientes maneras:

    • Configuración rápida

      -

      De esta manera, puede crear una colección simplemente dándole un nombre y especificando el número de dimensiones de las incrustaciones vectoriales que se almacenarán en esta colección. Para más información, consulte Configuración rápida.

    • +

      De esta manera, puede crear una colección simplemente dándole un nombre y especificando el número de dimensiones de las incrustaciones vectoriales que se almacenarán en esta colección. Para más detalles, consulte Configuración rápida.

    • Configuración personalizada

      En lugar de dejar que In Milvus decida casi todo para su colección, puede determinar el esquema y los parámetros de índice de la colección por su cuenta. Para obtener más información, consulte Configuración personalizada.

    @@ -220,7 +220,7 @@ $ curl -X POST "http://id
    (como clave primaria) y vector (como campo vectorial), con las opciones auto_id y enable_dynamic_field activadas por defecto.

    • auto_id

      -

      La activación de esta configuración garantiza que la clave primaria se incremente automáticamente. No es necesario proporcionar manualmente claves primarias durante la inserción de datos.

    • +

      Activar esta configuración garantiza que la clave primaria se incremente automáticamente. No es necesario proporcionar manualmente claves primarias durante la inserción de datos.

    • enable_dynamic_field

      Cuando está activada, todos los campos, excepto id y vector en los datos que se van a insertar, se tratan como campos dinámicos. Estos campos adicionales se guardan como pares clave-valor dentro de un campo especial denominado $meta. Esta función permite incluir campos adicionales durante la inserción de datos.

    @@ -394,7 +394,7 @@ schema.addField(AddFieldReq.builder() dim - Dimensionalidad del campo de la colección que contiene las incrustaciones vectoriales.
    El valor debe ser un número entero mayor que 1 y suele estar determinado por el modelo que se utiliza para generar incrustaciones vectoriales. + La dimensionalidad del campo de la colección que contiene las incrustaciones vectoriales.
    El valor debe ser un número entero mayor que 1 y suele estar determinado por el modelo que se utiliza para generar incrustaciones vectoriales. @@ -527,7 +527,7 @@ indexParams.add(indexParamForVectorField); params - Los parámetros de ajuste para el tipo de índice especificado. Para más información sobre posibles claves y rangos de valores, consulte Índice en memoria. + Los parámetros de ajuste fino para el tipo de índice especificado. Para más información sobre posibles claves y rangos de valores, consulte Índice en memoria. @@ -579,7 +579,7 @@ indexParams.add(indexParamForVectorField); params - Los parámetros de ajuste para el tipo de índice especificado. Para más información sobre posibles claves y rangos de valores, consulte Índice en memoria. + Los parámetros de ajuste fino para el tipo de índice especificado. Para más información sobre posibles claves y rangos de valores, consulte Índice en memoria. @@ -605,7 +605,7 @@ indexParams.add(indexParamForVectorField); params - El tipo de índice y los ajustes relacionados. Para más detalles, consulte Índice en memoria. + El tipo de índice y los ajustes relacionados. Para más información, consulte Índice en memoria. params.index_type @@ -1210,7 +1210,7 @@ $ curl -X POST "http://describeCollection().

    -

    Para comprobar los detalles de una colección existente, utilice describeCollection().

    +

    Para consultar los detalles de una colección existente, utilice describe_collection().

    Para ver la definición de una colección, puede utilizar los botones POST /v2/vectordb/collections/describe y el POST /v2/vectordb/collections/list puntos finales de la API.

    @@ -1601,7 +1601,7 @@ $ curl -X POST "http://# 7. Load the collection client.load_collection( collection_name="customized_setup_2", - load_fields=["my_id", "my_vector"] # Load only the specified fields + load_fields=["my_id", "my_vector"], # Load only the specified fields skip_load_dynamic_field=True # Skip loading the dynamic field ) @@ -1617,7 +1617,7 @@ res = client.get_load_state( # "state": "<LoadState: Loaded>" # }
    -

    Tenga en cuenta que sólo los campos enumerados en load_fields pueden utilizarse como condiciones de filtrado y campos de salida en búsquedas y consultas. Siempre debe incluir la clave primaria en la lista. Los nombres de campo excluidos de la carga no estarán disponibles para el filtrado o la salida.

    +

    Tenga en cuenta que sólo los campos enumerados en load_fields pueden utilizarse como condiciones de filtrado y campos de salida en búsquedas y consultas. Debe incluir siempre la clave primaria en la lista. Los nombres de campo excluidos de la carga no estarán disponibles para el filtrado o la salida.

    Puede utilizar skip_load_dynamic_field=True para omitir la carga del campo dinámico. Milvus trata el campo dinámico como un único campo, por lo que todas las claves del campo dinámico se incluirán o excluirán juntas.

    Liberar una colección

    diff --git a/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.json index 43d490233..e4af56832 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.json +++ b/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.json @@ -1 +1 @@ -{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"","anchorList":[{"label":"Índice de campos escalares","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Tipos de indexación escalar","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexación automática","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexación personalizada","href":"Custom-indexing","type":2,"isActive":false},{"label":"Verificación del resultado","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Límites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"Índice de campos escalares","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Tipos de indexación escalar","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexación automática","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexación personalizada","href":"Custom-indexing","type":2,"isActive":false},{"label":"Verificación del resultado","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Límites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.md index 01189f752..49449d71d 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.md +++ b/localization/v2.4.x/site/es/userGuide/manage-indexes/index-scalar-fields.md @@ -4,7 +4,7 @@ order: 2 summary: >- Esta guía le guiará a través de la creación y configuración de índices escalares para campos como enteros, cadenas, etc. -title: Índice Campos escalares +title: Índice de campos escalares ---

    Índice de campos escalares

    -

    Para utilizar la indexación personalizada, especifique un tipo de índice concreto mediante el parámetro index_type en el archivo add_index().

    +

    Para utilizar la indexación personalizada, especifique un tipo de índice concreto utilizando el parámetro index_type en el archivo add_index().

    Para utilizar la indexación personalizada, especifique un tipo de índice concreto utilizando el parámetro indexType en IndexParam.

    @@ -139,7 +139,7 @@ client.createIndex(createIndexReq);

    El siguiente ejemplo crea un índice invertido para el campo escalar scalar_2.

    -
    index_params = client.create_index_params() #  Prepare an IndexParams object
    +
    index_params = MilvusClient.prepare_index_params() #  Prepare an IndexParams object
     
     index_params.add_index(
         field_name="scalar_2", # Name of the scalar field to be indexed
    @@ -181,7 +181,7 @@ client.createIndex(createIndexReq);
     

    Métodos y parámetros

      -
    • crear_parametros_de_índice()

      +
    • preparar_parametros_de_índice()

      Prepara un objeto IndexParams.

    • add_index()

      Añade configuraciones de índice al objeto IndexParams.

      diff --git a/localization/v2.4.x/site/es/userGuide/manage-partitions.json b/localization/v2.4.x/site/es/userGuide/manage-partitions.json index 742755f94..16c4cdeda 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-partitions.json +++ b/localization/v2.4.x/site/es/userGuide/manage-partitions.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"Gestionar particiones","href":"Manage-Partitions","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Listar particiones","href":"List-Partitions","type":2,"isActive":false},{"label":"Crear particiones","href":"Create-Partitions","type":2,"isActive":false},{"label":"Comprobar la existencia de una partición específica","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"Cargar y liberar particiones","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"Liberar particiones","href":"Drop-Partitions","type":2,"isActive":false},{"label":"PREGUNTAS FRECUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"Gestionar particiones","href":"Manage-Partitions","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Listar particiones","href":"List-Partitions","type":2,"isActive":false},{"label":"Crear particiones","href":"Create-Partitions","type":2,"isActive":false},{"label":"Comprobar la existencia de una partición específica","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"Cargar y liberar particiones","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"Liberar particiones","href":"Drop-Partitions","type":2,"isActive":false},{"label":"PREGUNTAS FRECUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/userGuide/manage-partitions.md b/localization/v2.4.x/site/es/userGuide/manage-partitions.md index 06e0c9854..95327a0ea 100644 --- a/localization/v2.4.x/site/es/userGuide/manage-partitions.md +++ b/localization/v2.4.x/site/es/userGuide/manage-partitions.md @@ -37,7 +37,7 @@ title: Gestionar particiones

      Al crear una colección, se crea automáticamente al menos una partición por defecto denominada _default. Puede crear un máximo de 1.024 particiones dentro de una colección.

      notas

      -

      Milvus introduce una característica llamada Partition Key, que aprovecha las particiones subyacentes para almacenar entidades basadas en los valores hash de un campo específico. Esta característica facilita la implementación de multi-tenancy, mejorando el rendimiento de la búsqueda. Para más detalles, lea Utilizar clave de partición.

      +

      Milvus introduce una característica llamada Partition Key, que aprovecha las particiones subyacentes para almacenar entidades basadas en los valores hash de un campo específico. Esta característica facilita la implementación de multi-tenancy, mejorando el rendimiento de la búsqueda. Para más información, consulte Utilizar la clave de partición.

      Si la función Partition Key está activada en una colección, Milvus se encarga de gestionar todas las particiones, liberándole a usted de esta responsabilidad.

      Preparativos

    -

    Para las preparaciones, utilice MilvusClient para conectarse a Milvus y createCollection() para crear una colección en modo de configuración rápida.

    +

    Para los preparativos, utilice MilvusClient para conectarse a Milvus y createCollection() para crear una colección en modo de configuración rápida.

    @@ -652,7 +652,7 @@ res = await client."partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionA" ) @@ -663,7 +663,7 @@ res = client.get_load_status( # "state": "<LoadState: Loaded>" # } -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionB" ) @@ -820,7 +820,7 @@ res = await client."_default", "partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", ) diff --git a/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.json b/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.json index 93b54baa6..c4710754a 100644 --- a/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.json +++ b/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.json @@ -1 +1 @@ -{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"10.102.7.3\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"","anchorList":[{"label":"Búsqueda híbrida","href":"Hybrid-Search","type":1,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Paso 1: Crear varias instancias de AnnSearchRequest","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"Paso 2: Configurar una estrategia de reordenación","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"Paso 3: Realizar una búsqueda híbrida","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"Límites","href":"Limits","type":2,"isActive":false},{"label":"PREGUNTAS FRECUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"127.0.0.1\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"Hybrid Search","anchorList":[{"label":"Búsqueda híbrida","href":"Hybrid-Search","type":1,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Paso 1: Crear varias instancias de AnnSearchRequest","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"Paso 2: Configurar una estrategia de reordenación","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"Paso 3: Realizar una búsqueda híbrida","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"Límites","href":"Limits","type":2,"isActive":false},{"label":"PREGUNTAS FRECUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.md b/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.md index bc9c88ade..662aab4a2 100644 --- a/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.md +++ b/localization/v2.4.x/site/es/userGuide/search-query-get/multi-vector-search.md @@ -54,7 +54,7 @@ title: Búsqueda híbrida # Connect to Milvus connections.connect( - host="10.102.7.3", # Replace with your Milvus server IP + host="127.0.0.1", # Replace with your Milvus server IP port="19530" ) @@ -232,7 +232,7 @@ res = collection.hybrid_search(

    Una lista de peticiones de búsqueda, donde cada petición es un objeto ANNSearchRequest. Cada petición puede corresponder a un campo vectorial diferente y a un conjunto diferente de parámetros de búsqueda.

  • rerank (objeto)

    La estrategia de reordenación que se utilizará para la búsqueda híbrida. Valores posibles: WeightedRanker(value1, value2, ..., valueN) y RRFRanker().

    -

    Para más información sobre las estrategias de reordenación, consulte Reordenación.

  • +

    Para más información sobre las estrategias de reordenación, consulte Reordenación.

  • limit (int)

    El número máximo de resultados finales a devolver en la búsqueda híbrida.

  • diff --git a/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.json index 2345e33c6..ed44a3ff9 100644 --- a/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Búsqueda de un solo vector","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Búsqueda básica","href":"Basic-search","type":2,"isActive":false},{"label":"Búsqueda filtrada","href":"Filtered-search","type":2,"isActive":false},{"label":"Búsqueda por rango","href":"Range-search","type":2,"isActive":false},{"label":"Búsqueda por agrupación","href":"Grouping-search","type":2,"isActive":false},{"label":"Parámetros de búsqueda","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Búsqueda de un solo vector","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Visión general","href":"Overview","type":2,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Búsqueda básica","href":"Basic-search","type":2,"isActive":false},{"label":"Búsqueda filtrada","href":"Filtered-search","type":2,"isActive":false},{"label":"Búsqueda por rango","href":"Range-search","type":2,"isActive":false},{"label":"Búsqueda por agrupación","href":"Grouping-search","type":2,"isActive":false},{"label":"Parámetros de búsqueda","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.md index e23d822b6..df7ac354c 100644 --- a/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/es/userGuide/search-query-get/single-vector-search.md @@ -24,7 +24,7 @@ title: Búsqueda de un solo vector

    Una vez que haya insertado sus datos, el siguiente paso es realizar búsquedas de similitud en su colección en Milvus.

    Milvus le permite realizar dos tipos de búsquedas, dependiendo del número de campos vectoriales de su colección:

      -
    • Búsqueda de un solo vector: Si su colección sólo tiene un campo vectorial, utilice el método search() para encontrar las entidades más similares. Este método compara su vector de consulta con los vectores existentes en su colección y devuelve los ID de las coincidencias más cercanas junto con las distancias entre ellos. Opcionalmente, también puede devolver los valores del vector y los metadatos de los resultados.
    • +
    • Búsqueda de un solo vector: Si su colección sólo tiene un campo vectorial, utilice el método search() para encontrar las entidades más similares. Este método compara su vector de consulta con los vectores existentes en su colección y devuelve los ID de las coincidencias más cercanas junto con las distancias entre ellos. Opcionalmente, también puede devolver los valores vectoriales y los metadatos de los resultados.
    • Búsqueda híbrida: Para colecciones con dos o más campos vectoriales, utilice el método hybrid_search() método. Este método realiza múltiples peticiones de búsqueda de Vecino más próximo aproximado (RNA) y combina los resultados para devolver las coincidencias más relevantes tras una nueva clasificación.

    Esta guía se centra en cómo realizar una búsqueda de un solo vector en Milvus. Para obtener más información sobre la búsqueda híbrida, consulte Búsqueda híbrida.

    @@ -68,10 +68,12 @@ title: Búsqueda de un solo vector

    El siguiente fragmento de código reutiliza el código existente para establecer una conexión con Milvus y configurar rápidamente una colección.

    -
    # 1. Set up a Milvus client
    +
    from pymilvus import MilvusClient
    +import random
    +
    +# 1. Set up a Milvus client
     client = MilvusClient(
    -    uri=CLUSTER_ENDPOINT,
    -    token=TOKEN 
    +    uri="http://localhost:19530"
     )
     
     # 2. Create a collection
    @@ -441,7 +443,7 @@ res = await client.search, puede proporcionar uno o varios valores vectoriales que representen sus incrustaciones de consulta y un valor limit que indique el número de resultados que se devolverán.

    -

    En función de los datos y del vector de consulta, es posible que obtenga menos resultados que limit. Esto ocurre cuando limit es mayor que el número de vectores que coinciden con la consulta.

    +

    Dependiendo de los datos y del vector de consulta, es posible que obtenga menos resultados que limit. Esto ocurre cuando limit es mayor que el número de vectores que coinciden con la consulta.

    La búsqueda monovectorial es la forma más sencilla de las operaciones search en Milvus, diseñada para encontrar los vectores más similares a un vector de consulta dado.

    Para realizar una búsqueda monovectorial, especifique el nombre de la colección de destino, el vector de consulta y el número de resultados deseado (limit). Esta operación devuelve un conjunto de resultados que incluye los vectores más similares, sus ID y las distancias desde el vector de consulta.

    A continuación se muestra un ejemplo de búsqueda de las 5 entidades más similares al vector de consulta:

    @@ -449,7 +451,7 @@ res = await client.Python Java Node.js
    # Single vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         # Replace with your query vector
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
    @@ -643,7 +645,7 @@ res = await client.Python  Java Node.js
    # Bulk-vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[
             [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
             [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
    @@ -1223,12 +1225,12 @@ searchResp = client.search(searchReq);
     

    Los datos de red difieren de los de blue. Por lo tanto, los resultados de la búsqueda se limitarán a la partición especificada, reflejando las características únicas y la distribución de datos de ese subconjunto.

    Búsqueda con campos de salida

    La búsqueda con campos de salida permite especificar qué atributos o campos de los vectores coincidentes deben incluirse en los resultados de la búsqueda.

    Puede especificar output_fields en una petición para devolver resultados con campos específicos.

    -

    A continuación se muestra un ejemplo de devolución de resultados con valores de atributo color:

    +

    A continuación se muestra un ejemplo de devolución de resultados con valores de atributos de color:

    # Search with output fields
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1341,7 +1343,7 @@ res = await client.2.916019916534424, id: '425', color: 'purple' }
     ]
     
    -

    Junto con los vecinos más próximos, los resultados de la búsqueda incluirán el campo especificado color, lo que proporciona un conjunto más rico de información para cada vector coincidente.

    +

    Junto a los vecinos más próximos, los resultados de la búsqueda incluirán el campo especificado color, proporcionando un conjunto más rico de información para cada vector coincidente.

    Depuis Milvus 2.2.3, vous pouvez configurer les coordinateurs Milvus pour qu'ils fonctionnent en mode actif-veille et activer la fonction de mise à niveau continue pour eux, afin que Milvus puisse répondre aux demandes entrantes pendant les mises à niveau des coordinateurs. Dans les versions précédentes, les coordinateurs doivent être supprimés puis créés lors d'une mise à niveau, ce qui peut entraîner certains temps d'arrêt du service.

    +

    Depuis Milvus 2.2.3, vous pouvez configurer les coordinateurs Milvus pour qu'ils fonctionnent en mode actif-veille et activer la fonction de mise à niveau continue pour eux, afin que Milvus puisse répondre aux demandes entrantes pendant les mises à niveau des coordinateurs. Dans les versions précédentes, les coordinateurs doivent être supprimés puis créés au cours d'une mise à niveau, ce qui peut entraîner certains temps d'arrêt du service.

    Les mises à niveau en continu exigent que les coordinateurs fonctionnent en mode actif-veille. Vous pouvez utiliser le script que nous fournissons pour configurer les coordinateurs afin qu'ils travaillent en mode veille active et lancer la mise à jour continue.

    Basé sur les capacités de mise à jour continue fournies par Kubernetes, le script ci-dessus applique une mise à jour ordonnée des déploiements en fonction de leurs dépendances. En outre, Milvus met en œuvre un mécanisme garantissant que ses composants restent compatibles avec ceux qui en dépendent pendant la mise à niveau, ce qui réduit considérablement les temps d'arrêt potentiels des services.

    Le script s'applique uniquement à la mise à niveau de Milvus installé avec Helm. Le tableau suivant répertorie les drapeaux de commande disponibles dans les scripts.

    @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
  • Migrer les métadonnées Milvus.
  • Démarrer les composants Milvus avec une nouvelle image.
  • -

    2. Mise à niveau de Milvus de la version 2.1.x à la version 2.4.15

    Les commandes suivantes supposent que vous mettez à niveau Milvus de la version 2.1.4 à la version 2.4.15. Modifiez-les pour obtenir les versions qui répondent à vos besoins.

    +

    2. Mise à niveau de Milvus de la version 2.1.x à la version 2.2.0

    Les commandes suivantes supposent que vous mettez à niveau Milvus de la version 2.1.4 à la version 2.2.0. Modifiez-les pour obtenir les versions qui répondent à vos besoins.

      -
    1. Spécifiez le nom de l'instance Milvus, la version source de Milvus et la version cible de Milvus.

      -
      ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
      +
    2. Spécifier le nom de l'instance Milvus, la version source de Milvus et la version cible de Milvus.

      +
      ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
       
    3. Spécifiez l'espace de noms avec -n si votre Milvus n'est pas installé dans l'espace de noms K8s par défaut.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
       
    4. Spécifiez le chemin d'accès à la racine avec -r si votre Milvus est installé avec le chemin d'accès personnalisé rootpath.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
       
    5. Spécifier la balise d'image avec -w si votre Milvus est installé avec une balise personnalisée image.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
       
    6. Définissez -d true si vous souhaitez supprimer automatiquement le pod de migration une fois la migration terminée.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
       
    7. Revenir en arrière et migrer à nouveau si la migration échoue.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
      -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
      +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
       
    diff --git a/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.json index 275a28f41..53e35dd73 100644 --- a/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"Exécuter Milvus dans Kubernetes avec Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Conditions préalables","href":"Prerequisites","type":2,"isActive":false},{"label":"Installer Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Installation en ligne","href":"Online-install","type":2,"isActive":false},{"label":"Installation hors ligne","href":"Offline-install","type":2,"isActive":false},{"label":"Mise à niveau du cluster Milvus en cours d'exécution","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Désinstaller Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"Exécuter Milvus dans Kubernetes avec Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Conditions préalables","href":"Prerequisites","type":2,"isActive":false},{"label":"Installer Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Installation en ligne","href":"Online-install","type":2,"isActive":false},{"label":"Installation hors ligne","href":"Offline-install","type":2,"isActive":false},{"label":"Mise à niveau du cluster Milvus en cours d'exécution","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Désinstaller Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.md index f5fa57f04..d14b9103e 100644 --- a/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/fr/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -20,7 +20,7 @@ title: Installer le cluster Milvus avec Helm d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    Cette page explique comment démarrer une instance Milvus dans Kubernetes à l'aide des cartes Milvus Helm.

    +

    Cette page explique comment démarrer une instance Milvus dans Kubernetes à l'aide des cartes Milvus Helm.

    Vue d'ensemble

    Avant d'installer Milvus Helm Charts, vous devez ajouter le référentiel Milvus Helm.

    -
    $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
    +
    $ helm repo add milvus https://github.com/zilliztech/milvus-helm
     
    -

    Le dépôt Milvus Helm Charts à l'adresse https://milvus-io.github.io/milvus-helm/ a été archivé et vous pouvez obtenir des mises à jour supplémentaires à l'adresse https://zilliztech.github.io/milvus-helm/ comme suit :

    -
    helm repo add zilliztech https://zilliztech.github.io/milvus-helm
    +

    Le dépôt Milvus Helm Charts à l'adresse https://github.com/milvus-io/milvus-helm a été archivé et vous pouvez obtenir des mises à jour supplémentaires à l'adresse https://github.com/zilliztech/milvus-helm comme suit :

    +
    helm repo add zilliztech https://github.com/zilliztech/milvus-helm
     helm repo update
     # upgrade existing helm release
     helm upgrade my-release zilliztech/milvus
    @@ -123,7 +123,7 @@ helm upgrade my-release zilliztech/milvus
         
  • Le nom de la version ne doit contenir que des lettres, des chiffres et des tirets. Les points ne sont pas autorisés dans le nom de la version.
  • La ligne de commande par défaut installe la version cluster de Milvus lors de l'installation de Milvus avec Helm. D'autres paramètres sont nécessaires lors de l'installation autonome de Milvus.
  • Selon le guide de migration des API obsolètes de Kubernetes, la version API policy/v1beta1 de PodDisruptionBudget n'est plus servie à partir de la version 1.25. Il vous est suggéré de migrer les manifestes et les clients API pour utiliser la version API policy/v1 à la place.
    En guise de solution de contournement pour les utilisateurs qui utilisent encore la version API policy/v1beta1 de PodDisruptionBudget sur Kubernetes v1.25 et ultérieures, vous pouvez exécuter la commande suivante pour installer Milvus :
    . helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
  • -
  • Voir Milvus Helm Chart et Helm pour plus d'informations.
  • +
  • Voir Milvus Helm Chart et Helm pour plus d'informations.
  • 2. Vérifier l'état du cluster Milvus

    Exécutez la commande suivante pour vérifier l'état de tous les pods de votre cluster Milvus.

    diff --git a/localization/v2.4.x/site/fr/integrations/integrations_overview.md b/localization/v2.4.x/site/fr/integrations/integrations_overview.md index 703d27fdb..e319a2631 100644 --- a/localization/v2.4.x/site/fr/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/fr/integrations/integrations_overview.md @@ -31,9 +31,9 @@ title: Vue d'ensemble des intégrations Milvus Hybrid Search Retriever dans LangChainRecherche hybrideMilvus, LangChain Recherche sémantique avec Milvus et OpenAIRecherche sémantiqueMilvus, OpenAI Réponse aux questions avec Milvus et CohereRecherche sémantiqueMilvus, Cohere -Réponse aux questions en utilisant Milvus et HuggingFaceRéponse aux questionsMilvus, HuggingFace +Réponse aux questions avec Milvus et HuggingFaceRéponse aux questionsMilvus, HuggingFace Recherche d'images avec Milvus et PytorchRecherche sémantiqueMilvus, Pytorch -Recherche de films utilisant Milvus et SentenceTransfromersRecherche sémantiqueMilvus, SentenceTransformers +Recherche de films avec Milvus et SentenceTransfromersRecherche sémantiqueMilvus, SentenceTransformers Utiliser Milvus comme magasin de vecteurs dans LangChainRecherche sémantiqueMilvus, LangChain RAG avec Milvus et HaystackRAGMilvus, Haystack Recherche de vision avec Milvus et FiftyOneRecherche sémantiqueMilvus, FiftyOne @@ -44,7 +44,7 @@ title: Vue d'ensemble des intégrations Milvus sur Snowpark Container ServicesConnexion de donnéesMilvus, Snowpark Recherche basée sur des règles avec Milvus et WhyHowRéponse aux questionsMilvus, WhyHow Milvus dans LangfuseObservabilitéMilvus, Langfuse -Évaluation RAG avec Ragas et MilvusÉvaluationMilvus, Ragas +Évaluation RAG avec Ragas et MilvusL'évaluationMilvus, Ragas Agent Chatbot avec Milvus et MemGPTAgentMilvus, MemGPT Comment déployer FastGPT avec MilvusRAGMilvus, FastGPT Ecrire du SQL avec Vanna et MilvusRAGMilvus, Vanna @@ -67,5 +67,9 @@ title: Vue d'ensemble des intégrations Construire un RAG avec Milvus et des sources de données non structuréesnon structuréesMilvus, non structuré Construire un RAG avec Milvus + PII MaskerSources de donnéesMilvus, PII Masker Utiliser Milvus dans PrivateGPTOchestrationrecherche vectorielle +Premiers pas avec Mem0 et MilvusAgentsMem0, Milvus +Tableau des connaissances avec MilvusIngénierie des connaissancesTableau des connaissances, Milvus +Utiliser Milvus dans DocsGPTOchestrationDocsGPT, Milvus +Utiliser Milvus avec SambaNovaOrchestrationMilvus, SambaNova diff --git a/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..3ef065077 --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Knowledge Table avec Milvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"Conditions préalables","href":"Prerequisites","type":2,"isActive":false},{"label":"Cloner le projet","href":"Cloning-the-project","type":2,"isActive":false},{"label":"Configurer l'environnement","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"Démarrer l'application","href":"Starting-the-app","type":2,"isActive":false},{"label":"Arrêt de l'application","href":"Stopping-the-app","type":2,"isActive":false},{"label":"Accès au projet","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..2159bd1ab --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,146 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + Par défaut, Knowledge Table utilise la base de données Milvus pour stocker et + récupérer les données extraites. Cela permet aux utilisateurs de rechercher, + filtrer et analyser facilement les données à l'aide des puissantes + fonctionnalités de Milvus. Dans ce tutoriel, nous allons montrer comment + démarrer avec Knowledge Table et Milvus. +title: Knowledge Table avec Milvus +--- +

    Knowledge Table avec Milvus

    Knowledge Table, développé par WhyHow AI, est un logiciel libre conçu pour faciliter l'extraction et l'exploration de données structurées à partir de documents non structurés. Il offre aux utilisateurs une interface de type tableur et permet la création de représentations de connaissances, telles que des tableaux et des graphiques, par le biais d'une interface d'interrogation en langage naturel. Le logiciel comprend des règles d'extraction personnalisables, des options de formatage et la traçabilité des données par leur provenance, ce qui le rend adaptable à diverses applications. Il permet une intégration transparente dans les flux de travail RAG et s'adresse à la fois aux utilisateurs professionnels qui ont besoin d'une interface conviviale et aux développeurs qui ont besoin d'un backend flexible pour un traitement efficace des documents.

    +

    Par défaut, Knowledge Table utilise la base de données Milvus pour stocker et récupérer les données extraites. Cela permet aux utilisateurs de rechercher, de filtrer et d'analyser facilement les données à l'aide des puissantes fonctionnalités de Milvus. Dans ce tutoriel, nous allons montrer comment démarrer avec Knowledge Table et Milvus.

    +

    Conditions préalables

      +
    • Docker
    • +
    • Docker Compose
    • +
    +

    Cloner le projet

    $ git clone https://github.com/whyhow-ai/knowledge-table.git
    +
    +

    Configurer l'environnement

    Vous trouverez le fichier .env.example dans le répertoire racine du projet. Copiez ce fichier sur .env et remplissez les variables d'environnement requises.

    +

    Pour Milvus, vous devez définir les variables d'environnement MILVUS_DB_URI et MILVUS_DB_TOKEN. Voici quelques conseils :

    +
    +
      +
    • Définir MILVUS_DB_URI comme un fichier local, par exemple./milvus.db, est la méthode la plus pratique, car elle utilise automatiquement Milvus Lite pour stocker toutes les données dans ce fichier.
    • +
    • Si vous avez des données à grande échelle, par exemple plus d'un million de vecteurs, vous pouvez configurer un serveur Milvus plus performant sur Docker ou Kubernetes. Dans cette configuration, veuillez utiliser l'adresse et le port du serveur comme uri, par exemplehttp://localhost:19530. Si vous activez la fonction d'authentification sur Milvus, utilisez "<votre_nom_d'utilisateur>:<votre_mot_de_passe>" comme jeton, sinon ne définissez pas le jeton.
    • +
    • Si vous souhaitez utiliser Zilliz Cloud, le service en nuage entièrement géré pour Milvus, réglez les paramètres MILVUS_DB_URI et MILVUS_DB_TOKEN, qui correspondent au point de terminaison public et à la clé Api dans Zilliz Cloud.
    • +
    +
    +

    Outre Milvus, vous devez également définir d'autres environnements, par exemple OPENAI_API_KEY. Vous pouvez obtenir chacun de ces environnements sur les sites web respectifs.

    +

    Démarrer l'application

    $ docker-compose up -d --build
    +
    +

    Arrêt de l'application

    $ docker-compose down
    +
    +

    Accès au projet

    Le frontend est accessible à l'adresse http://localhost:3000, et le backend à l'adresse http://localhost:8000.

    +

    + + + + +

    +

    Vous pouvez jouer avec l'interface utilisateur et essayer avec vos propres documents.

    +

    Pour plus de détails sur l'utilisation de la démonstration, vous pouvez vous référer à la documentation officielle de Knowledge Table.

    diff --git a/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..3827e2b2c --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Premiers pas avec Mem0 et Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Préparation","href":"Preparation","type":2,"isActive":false},{"label":"Gestion des mémoires d'utilisateur avec Mem0 et Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..75f25f19f --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,218 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + Dans ce tutoriel, nous aborderons les opérations essentielles de gestion de la + mémoire de Mem0 - ajout, récupération, mise à jour, recherche, suppression et + suivi de l'historique de la mémoire - en utilisant Milvus, une base de données + vectorielle haute performance et open-source qui permet un stockage et une + récupération efficaces. Cette introduction pratique vous guidera à travers les + opérations de mémoire fondamentales pour vous aider à créer des interactions + d'IA personnalisées avec Mem0 et Milvus. +title: Premiers pas avec Mem0 et Milvus +--- +

    Premiers pas avec Mem0 et Milvus

    +Open In Colab + + +GitHub Repository +

    +

    Mem0 est une couche de mémoire intelligente pour les applications d'IA, conçue pour offrir des interactions personnalisées et efficaces en conservant les préférences de l'utilisateur et en s'adaptant continuellement au fil du temps. Idéal pour les chatbots et les outils pilotés par l'IA, Mem0 crée des expériences transparentes et conscientes du contexte.

    +

    Dans ce tutoriel, nous aborderons les opérations essentielles de gestion de la mémoire de Mem0 - ajout, récupération, mise à jour, recherche, suppression et suivi de l'historique de la mémoire - en utilisant Milvus, une base de données vectorielle open-source haute performance qui permet un stockage et une récupération efficaces. Cette introduction pratique vous guidera à travers les opérations de mémoire fondamentales pour vous aider à créer des interactions d'IA personnalisées avec Mem0 et Milvus.

    +

    Préparation

    Télécharger les bibliothèques nécessaires

    $ pip install mem0ai pymilvus
    +
    +
    +

    Si vous utilisez Google Colab, pour activer les dépendances qui viennent d'être installées, vous devrez peut-être redémarrer le runtime (cliquez sur le menu "Runtime" en haut de l'écran, et sélectionnez "Restart session" dans le menu déroulant).

    +
    +

    Configurer Mem0 avec Milvus

    Nous utiliserons OpenAI comme LLM dans cet exemple. Vous devez préparer la clé api OPENAI_API_KEY en tant que variable d'environnement.

    +
    import os
    +
    +os.environ["OPENAI_API_KEY"] = "sk-***********"
    +
    +

    Maintenant, nous pouvons configurer Mem0 pour qu'il utilise Milvus comme magasin de vecteurs

    +
    # Define Config
    +from mem0 import Memory
    +
    +config = {
    +    "vector_store": {
    +        "provider": "milvus",
    +        "config": {
    +            "collection_name": "quickstart_mem0_with_milvus",
    +            "embedding_model_dims": "1536",
    +            "url": "./milvus.db",  # Use local vector database for demo purpose
    +        },
    +    },
    +    "version": "v1.1",
    +}
    +
    +m = Memory.from_config(config)
    +
    +
    +
    +
      +
    • Si vous n'avez besoin d'une base de données vectorielle locale que pour les données à petite échelle ou le prototypage, définir l'uri comme un fichier local, par exemple./milvus.db, est la méthode la plus pratique, car elle utilise automatiquement Milvus Lite pour stocker toutes les données dans ce fichier.
    • +
    • Si vous disposez de données à grande échelle, par exemple plus d'un million de vecteurs, vous pouvez configurer un serveur Milvus plus performant sur Docker ou Kubernetes. Dans cette configuration, veuillez utiliser l'adresse et le port du serveur comme uri, par exemplehttp://localhost:19530. Si vous activez la fonction d'authentification sur Milvus, utilisez "<votre_nom_d'utilisateur>:<votre_mot_de_passe>" comme jeton, sinon ne définissez pas le jeton.
    • +
    • Si vous utilisez Zilliz Cloud, le service en nuage entièrement géré pour Milvus, réglez les paramètres uri et token, qui correspondent au point de terminaison public et à la clé API dans Zilliz Cloud.
    • +
    +
    +
    +

    Gestion des mémoires d'utilisateur avec Mem0 et Milvus

    Ajout d'une mémoire

    La fonction add stocke du texte non structuré dans Milvus en tant que mémoire, en l'associant à un utilisateur spécifique et à des métadonnées facultatives.

    +

    Ici, nous ajoutons à Milvus le souvenir d'Alice, "Je travaille à améliorer mes compétences en tennis", ainsi que des métadonnées pertinentes pour le contexte.

    +
    # Add a memory to user: Working on improving tennis skills
    +res = m.add(
    +    messages="I am working on improving my tennis skills.",
    +    user_id="alice",
    +    metadata={"category": "hobbies"},
    +)
    +
    +res
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Working on improving tennis skills',
    +   'event': 'ADD'}],
    + 'relations': []}
    +
    +

    Mise à jour d'un souvenir

    Nous pouvons utiliser la valeur de retour de la fonction add pour récupérer l'ID de la mémoire, ce qui nous permet de mettre à jour cette mémoire avec de nouvelles informations via update.

    +
    # Get memory_id
    +memory_id = res["results"][0]["id"]
    +
    +# Update this memory with new information: Likes to play tennis on weekends
    +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
    +
    +
    {'message': 'Memory updated successfully!'}
    +
    +

    Obtenir toutes les mémoires d'un utilisateur

    La fonction get_all permet d'afficher toutes les mémoires insérées ou de les filtrer par user_id dans Milvus.

    +

    Notez que nous pouvons voir que la mémoire est passée de "Travailler à améliorer ses compétences en tennis" à "Aime jouer au tennis le week-end".

    +
    # Get all memory for the user Alice
    +m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'}]}
    +
    +

    Afficher l'historique des mises à jour des mémoires

    Nous pouvons également consulter l'historique des mises à jour de la mémoire en spécifiant l'identifiant de la mémoire qui nous intéresse via la fonction history.

    +
    m.history(memory_id=memory_id)
    +
    +
    [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': None,
    +  'new_memory': 'Working on improving tennis skills',
    +  'event': 'ADD',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': None},
    + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': 'Working on improving tennis skills',
    +  'new_memory': 'Likes to play tennis on weekends',
    +  'event': 'UPDATE',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
    +
    +

    Rechercher une mémoire

    Nous pouvons utiliser la fonction search pour rechercher la mémoire la plus proche de l'utilisateur.

    +

    Commençons par ajouter une nouvelle mémoire pour Alice.

    +
    new_mem = m.add(
    +    "I have a linear algebra midterm exam on November 20",
    +    user_id="alice",
    +    metadata={"category": "task"},
    +)
    +
    +

    Nous appelons maintenant get_all en spécifiant l'identifiant de l'utilisateur pour vérifier que nous avons bien deux entrées de mémoire pour l'utilisateur Alice.

    +
    m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Nous pouvons maintenant exécuter search en fournissant query et user_id. Notez que nous utilisons par défaut la métrique L2 pour la recherche de similarité, de sorte qu'une petite valeur de score signifie une plus grande similarité.

    +
    m.search(query="What are Alice's hobbies", user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'score': 1.2807445526123047,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'score': 1.728922724723816,
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Supprimer une mémoire

    Nous pouvons également delete un souvenir en fournissant le memory_id correspondant.

    +

    Nous allons supprimer le souvenir "Aime jouer au tennis le week-end" car son memory_id a déjà été récupéré, et appeler get_all pour vérifier que la suppression est réussie.

    +
    m.delete(memory_id=memory_id)
    +
    +m.get_all("alice")
    +
    +
    {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    diff --git a/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..a5574698c --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Utiliser Milvus dans DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Conditions requises","href":"Requirements","type":2,"isActive":false},{"label":"Clonez le dépôt","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Ajouter une dépendance","href":"Add-dependency","type":2,"isActive":false},{"label":"Définir les variables d'environnement","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Démarrez les services","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..51d272dbe --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,142 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + Dans ce tutoriel, nous allons vous montrer comment utiliser Milvus comme base + de données vectorielle pour DocsGPT. +title: Utiliser Milvus dans DocsGPT +--- +

    Utiliser Milvus dans DocsGPT

    DocsGPT est une solution open-source avancée qui simplifie la recherche d'informations dans la documentation d'un projet en intégrant de puissants modèles GPT. Il permet aux développeurs d'obtenir facilement des réponses précises à leurs questions sur un projet, en éliminant les recherches manuelles qui prennent du temps.

    +

    Dans ce tutoriel, nous allons vous montrer comment utiliser Milvus comme base de données vectorielle pour DocsGPT.

    +
    +

    Ce tutoriel se réfère principalement au guide d'installation officiel de DocsGPT. Si vous trouvez que ce tutoriel contient des parties obsolètes, vous pouvez suivre en priorité le guide officiel et créer un problème avec nous.

    +
    +

    Conditions requises

    Assurez-vous que Docker est installé

    +

    Clonez le dépôt

    Clonez le dépôt et naviguez jusqu'à lui :

    +
    $ git clone https://github.com/arc53/DocsGPT.git
    +$ cd DocsGPT
    +
    +

    Ajouter une dépendance

    Ajoutez la dépendance langchain-milvus au fichier requirements.txt dans le dossier application:

    +
    $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
    +
    +

    Définir les variables d'environnement

    Ajoutez VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... aux variables d'environnement pour les services backend et worker dans le fichier docker-compose.yaml, comme ceci :

    +
      backend:
    +    build: ./application
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +
      worker:
    +    build: ./application
    +    command: celery -A application.app.celery worker -l INFO -B
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +

    Pour les services MILVUS_URI et MILVUS_TOKEN, vous pouvez utiliser le service Zilliz Cloud(recommandé) entièrement géré ou le service Milvus démarré manuellement.

    +
      +
    • Pour le service Zillz Cloud entièrement géré : Nous recommandons d'utiliser le service Zilliz Cloud. Vous pouvez vous inscrire pour un compte d'essai gratuit sur Zilliz Cloud. Vous obtiendrez ensuite les adresses MILVUS_URI et MILVUS_TOKEN, qui correspondent au point de terminaison public et à la clé API.

    • +
    • Pour le service Milvus démarré manuellement : Si vous souhaitez configurer un service Milvus, vous pouvez suivre la documentation officielle Milvus pour configurer un serveur Milvus, puis obtenir les adresses MILVUS_URI et MILVUS_TOKEN du serveur. Les adresses MILVUS_URI et MILVUS_TOKEN doivent être au format http://<your_server_ip>:19530 et <your_username>:<your_password> respectivement.

    • +
    +

    Démarrez les services

    Exécutez : ./setup.sh

    +

    Naviguez ensuite jusqu'à http://localhost:5173/.

    +

    Vous pouvez jouer avec l'interface utilisateur et poser des questions sur vos documents.

    +

    + + alt text + texte alt

    +

    Si vous souhaitez arrêter les services, exécutez :

    +
    $ docker-compose down
    +
    +

    Pour plus de détails et des configurations plus avancées, veuillez vous référer à la documentation officielle de DocsGPT.

    diff --git a/localization/v2.4.x/site/fr/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/fr/integrations/use_milvus_in_private_gpt.md index e986355bb..d8096af09 100644 --- a/localization/v2.4.x/site/fr/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/fr/integrations/use_milvus_in_private_gpt.md @@ -67,13 +67,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    PrivateGPT permet de personnaliser l'installation. Nous devons spécifier les paramètres de certains modules. Dans ce tutoriel, nous utiliserons les modules suivants :

    +

    PrivateGPT permet de personnaliser la configuration de certains modules tels que LLM, Embeddings, Vector Stores, UI.

    +

    Dans ce tutoriel, nous utiliserons les modules suivants :

    • LLM: Ollama
    • Embeddings: Ollama
    • Vector Stores: Milvus
    • UI: Gradio
    +

    Exécutez la commande suivante pour utiliser la poésie afin d'installer les dépendances des modules requis :

    $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
     

    Démarrer le service Ollama

    -

    Installer les modèles à utiliser, le modèle par défaut settings-ollama.yaml est configuré pour l'utilisateur llama3.1 8b LLM (~4GB) et nomic-embed-text Embeddings (~275MB).

    -

    Par défaut, PrivateGPT extrait automatiquement les modèles en fonction des besoins. Ce comportement peut être changé en modifiant la propriété ollama.autopull_models.

    +

    Installer les modèles à utiliser, le modèle par défaut settings-ollama.yaml est configuré pour l'utilisateur llama3.1 8b LLM (~4GB) et nomic-embed-text Embeddings (~275MB).

    +

    Par défaut, PrivateGPT récupère automatiquement les modèles en fonction des besoins. Ce comportement peut être changé en modifiant la propriété ollama.autopull_models.

    Dans tous les cas, si vous souhaitez extraire manuellement des modèles, exécutez les commandes suivantes :

    $ ollama pull llama3.1
     $ ollama pull nomic-embed-text
    @@ -133,8 +135,8 @@ $ ollama pull nomic-embed-text
     Champ OptionDescription
     
     
    -uriLa valeur par défaut est "local_data/private_gpt/milvus/milvus_local.db" en tant que fichier local ; vous pouvez également configurer un serveur Milvus plus performant sur docker ou k8s, par exemple http://localhost:19530, en tant qu'uri ; pour utiliser Zilliz Cloud, adaptez l'uri et le token à Endpoint et à la clé Api dans Zilliz Cloud.
    -jetonPaire avec le serveur Milvus sur docker ou k8s ou la clé api de Zilliz Cloud.
    +uriLa valeur par défaut est "local_data/private_gpt/milvus/milvus_local.db" en tant que fichier local ; vous pouvez également configurer un serveur Milvus plus performant sur docker ou k8s, par exemple http://localhost:19530, en tant qu'uri ; pour utiliser Zilliz Cloud, adaptez l'uri et le token au Public Endpoint et à la clé API dans Zilliz Cloud.
    +jetonPaire avec le serveur Milvus sur docker ou k8s ou la clé d'API de Zilliz Cloud.
     nom_de_la_collectionLe nom de la collection, défini par défaut sur "milvus_db".
     overwriteEcraser les données de la collection si elles existent, défini par défaut comme True.
     
    @@ -154,10 +156,10 @@ $ ollama pull nomic-embed-text
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    Une fois tous les réglages effectués, vous pouvez lancer PrivateGPT avec une interface utilisateur gradio.

    +

    Une fois tous les réglages effectués, vous pouvez lancer PrivateGPT avec une interface utilisateur Gradio.

    PGPT_PROFILES=ollama make run
     
    -

    L'interface utilisateur sera disponible à l'adressehttp://0.0.0.0:8001.

    +

    L'interface utilisateur sera disponible à l'adresse http://0.0.0.0:8001.

    @@ -165,3 +167,4 @@ $ ollama pull nomic-embed-text

    Vous pouvez jouer avec l'interface et poser des questions sur vos documents.

    +

    Pour plus de détails, veuillez vous référer à la documentation officielle de PrivateGPT.

    diff --git a/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..a89915b8a --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Utiliser Milvus avec SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Pré-requis","href":"Prerequisites","type":2,"isActive":false},{"label":"Cloner le dépôt","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Changer le type de magasin de vecteurs","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Installer les dépendances","href":"Install-dependencies","type":2,"isActive":false},{"label":"Démarrer l'application","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..c11db29d9 --- /dev/null +++ b/localization/v2.4.x/site/fr/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,135 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + Ce tutoriel tire parti de l'intégration de Milvus dans les kits de démarrage + SambaNova AI pour construire un système de recherche de connaissances + d'entreprise, similaire à RAG (Retrieval-Augmented Generation), pour la + recherche et la réponse basées sur les documents privés de l'entreprise. +title: Utiliser Milvus avec SambaNova +--- +

    Utiliser Milvus avec SambaNova

    SambaNova est une plateforme technologique d'IA innovante qui accélère le déploiement de capacités avancées d'IA et d'apprentissage profond. Conçue pour une utilisation en entreprise, elle permet aux organisations d'exploiter l'IA générative pour améliorer les performances et l'efficacité. En fournissant des solutions de pointe telles que la suite SambaNova et DataScale, la plateforme permet aux entreprises d'extraire des informations précieuses de leurs données, entraînant des améliorations opérationnelles et favorisant de nouvelles opportunités dans le paysage de l'IA.

    +

    Leskits de démarrage SambaNova AI sont une collection de ressources open-source conçues pour aider les développeurs et les entreprises à déployer des applications axées sur l'IA avec SambaNova. Ces kits fournissent des exemples pratiques et des guides qui facilitent la mise en œuvre de divers cas d'utilisation de l'IA, ce qui permet aux utilisateurs d'exploiter plus facilement la technologie avancée de SambaNova.

    +

    Ce tutoriel tire parti de l'intégration de Milvus dans les kits de démarrage AI de SambaNova pour construire un système de recherche de connaissances d'entreprise, similaire à RAG (Retrieval-Augmented Generation), pour la recherche et la réponse basées sur les documents privés de l'entreprise.

    +
    +

    Ce tutoriel se réfère principalement au guide officiel de SambaNova AI Starter Kits. Si vous trouvez que ce tutoriel contient des parties obsolètes, vous pouvez suivre en priorité le guide officiel et créer un problème avec nous.

    +
    +

    Pré-requis

    Nous recommandons d'utiliser Python >= 3.10 et < 3.12.

    +

    Visitez le SambaNova Cloud pour obtenir une clé API SambaNova.

    +

    Cloner le dépôt

    $ git clone https://github.com/sambanova/ai-starter-kit.git
    +$ d ai-starter-kit/enterprise_knowledge_retriever
    +
    +

    Changer le type de magasin de vecteurs

    Changez le magasin de vecteurs en définissant db_type='milvus' dans les fonctions create_vector_store() et load_vdb() dans src/document_retrieval.py.

    +
    ...
    +vectorstore = self.vectordb.create_vector_store(
    +    ..., db_type='milvus'
    +)
    +...
    +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
    +
    +

    Installer les dépendances

    Installez les dépendances requises en exécutant la commande suivante :

    +
    python3 -m venv enterprise_knowledge_env
    +source enterprise_knowledge_env/bin/activate
    +pip install -r requirements.txt
    +
    +

    Démarrer l'application

    Utilisez la commande suivante pour démarrer l'application :

    +
    $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
    +
    +

    Ensuite, vous voyez l'interface utilisateur dans votre navigateur :http://localhost:8501/

    +

    + + + + +

    +

    Après avoir défini votre clé API SambaNova dans l'interface utilisateur, vous pouvez jouer avec l'interface utilisateur et poser des questions sur vos documents.

    +

    Pour plus de détails, veuillez vous référer à la documentation officielle de Enterprise Knowledge Retrieval of SambaNova AI Starter Kits.

    diff --git a/localization/v2.4.x/site/fr/menuStructure/fr.json b/localization/v2.4.x/site/fr/menuStructure/fr.json index 6c323b400..03f015122 100644 --- a/localization/v2.4.x/site/fr/menuStructure/fr.json +++ b/localization/v2.4.x/site/fr/menuStructure/fr.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "Utilisateurs et rôles", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "Réplique en mémoire", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "Utilisateurs, privilèges et rôles", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "Activer RBAC", "id": "rbac.md", @@ -1421,7 +1421,19 @@ "children": [] }, { - "label": "PrivateGPT", + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, + { + "label": "PrivéGPT", "id": "use_milvus_in_private_gpt.md", "order": 8, "children": [] @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Tableau des connaissances", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Recherche d'entonnoirs avec les emboîtements Matryoshka", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "En savoir plus", "id": "explore-more", diff --git a/localization/v2.4.x/site/fr/reference/knowhere.json b/localization/v2.4.x/site/fr/reference/knowhere.json index af2da7a34..556ea0002 100644 --- a/localization/v2.4.x/site/fr/reference/knowhere.json +++ b/localization/v2.4.x/site/fr/reference/knowhere.json @@ -1 +1 @@ -{"codeList":[],"headingContent":"","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Knowhere dans l'architecture Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Avantages de Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Structure du code de Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Ajout d'index à Knowhere","href":"Adding-indexes-to-Knowhere","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":[],"headingContent":"Knowhere","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Knowhere dans l'architecture Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Avantages de Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Structure du code de Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Ajout d'index à Knowhere","href":"Adding-indices-to-Knowhere","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/reference/knowhere.md b/localization/v2.4.x/site/fr/reference/knowhere.md index 4e6de40b2..8737a13f4 100644 --- a/localization/v2.4.x/site/fr/reference/knowhere.md +++ b/localization/v2.4.x/site/fr/reference/knowhere.md @@ -1,7 +1,7 @@ --- id: knowhere.md summary: En savoir plus sur Knowhere à Milvus. -title: Le lieu du savoir +title: Knowhere ---

    Knowhere

    Knowhere est le moteur d'exécution vectorielle central de Milvus qui intègre plusieurs bibliothèques de recherche de similarités vectorielles, notamment Faiss, Hnswlib et Annoy. Knowhere est également conçu pour prendre en charge l'informatique hétérogène. Il contrôle sur quel matériel (CPU ou GPU) exécuter la construction de l'index et les requêtes de recherche. C'est ainsi que Knowhere tire son nom : savoir où exécuter les opérations. D'autres types de matériel, notamment les DPU et TPU, seront pris en charge dans les prochaines versions.

    +

    Knowhere est le moteur d'exécution vectorielle central de Milvus, qui intègre plusieurs bibliothèques de recherche de similarités vectorielles, notamment Faiss, Hnswlib et Annoy. Knowhere est également conçu pour prendre en charge l'informatique hétérogène. Il contrôle sur quel matériel (CPU ou GPU) exécuter la construction de l'index et les requêtes de recherche. C'est ainsi que Knowhere tire son nom : savoir où exécuter les opérations. D'autres types de matériel, notamment les DPU et TPU, seront pris en charge dans les prochaines versions.

    Knowhere dans l'architecture Milvus

    Si vous souhaitez ajouter de nouveaux index à Knowhere, vous pouvez d'abord vous référer aux index existants :

    +

    Si vous souhaitez ajouter de nouveaux indices à Knowhere, vous pouvez d'abord vous référer aux indices existants :

      -
    • Pour ajouter des index basés sur la quantification, consultez IVF_FLAT.

    • -
    • Pour ajouter des index basés sur des graphes, consultez HNSW.

    • +
    • Pour ajouter des indices basés sur la quantification, consultez IVF_FLAT.

    • +
    • Pour ajouter des indices basés sur des graphes, consultez HNSW.

    • Pour ajouter des index basés sur des arbres, consultez Annoy.

    -

    Après avoir consulté l'index existant, vous pouvez suivre les étapes ci-dessous pour ajouter un nouvel index à Knowhere.

    +

    Après avoir fait référence à l'index existant, vous pouvez suivre les étapes ci-dessous pour ajouter un nouvel index à Knowhere.

    1. Ajoutez le nom du nouvel index dans IndexEnum. Le type de données est une chaîne.

    2. -
    3. Ajoutez un contrôle de validation des données sur le nouvel index dans le fichier ConfAdapter.cpp. Le contrôle de validation sert principalement à valider les paramètres pour la formation des données et la requête.

    4. +
    5. Ajoutez un contrôle de validation des données sur le nouvel index dans le fichier ConfAdapter.cpp. Le contrôle de validation sert principalement à valider les paramètres de formation des données et de requête.

    6. Créez un nouveau fichier pour le nouvel index. La classe de base du nouvel index doit inclure VecIndex et l'interface virtuelle nécessaire de VecIndex.

    7. Ajoutez la logique de construction de l'index pour le nouvel index dans VecIndexFactory::CreateVecIndex().

    8. Ajoutez le test unitaire dans le répertoire unittest.

    9. diff --git a/localization/v2.4.x/site/fr/reference/schema.json b/localization/v2.4.x/site/fr/reference/schema.json index 438455740..a3d6d2fbf 100644 --- a/localization/v2.4.x/site/fr/reference/schema.json +++ b/localization/v2.4.x/site/fr/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gérer les schémas","href":"Manage-Schema","type":1,"isActive":false},{"label":"Schéma de champ","href":"Field-schema","type":2,"isActive":false},{"label":"Schéma de collection","href":"Collection-schema","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gérer les schémas","href":"Manage-Schema","type":1,"isActive":false},{"label":"Schéma de champ","href":"Field-schema","type":2,"isActive":false},{"label":"Schéma de collection","href":"Collection-schema","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/reference/schema.md b/localization/v2.4.x/site/fr/reference/schema.md index a8b7c3f94..ae91cf315 100644 --- a/localization/v2.4.x/site/fr/reference/schema.md +++ b/localization/v2.4.x/site/fr/reference/schema.md @@ -39,12 +39,15 @@ title: Gérer les schémas

      Propriétés du schéma de champ

      - + + + + - + @@ -130,7 +133,7 @@ fields = [
    10. BINARY_VECTOR : stocke les données binaires sous la forme d'une séquence de 0 et de 1. Il est utilisé pour la représentation compacte des caractéristiques dans le traitement des images et la recherche d'informations.
    11. FLOAT_VECTOR : stocke les nombres à virgule flottante de 32 bits, couramment utilisés dans l'informatique scientifique et l'apprentissage automatique pour représenter les nombres réels.
    12. FLOAT16_VECTOR : stocke des nombres à virgule flottante de 16 bits en demi-précision, utilisés dans l'apprentissage profond et les calculs GPU pour l'efficacité de la mémoire et de la bande passante.
    13. -
    14. BFLOAT16_VECTOR : Stocke les nombres à virgule flottante de 16 bits avec une précision réduite mais la même plage d'exposants que Float32, populaire dans l'apprentissage profond pour réduire les exigences en matière de mémoire et de calcul sans avoir un impact significatif sur la précision.
    15. +
    16. BFLOAT16_VECTOR : Stocke les nombres à virgule flottante de 16 bits avec une précision réduite mais la même plage d'exposants que Float32, populaire dans l'apprentissage profond pour réduire les exigences de mémoire et de calcul sans avoir un impact significatif sur la précision.
    17. SPARSE_FLOAT_VECTOR : stocke une liste d'éléments non nuls et leurs indices correspondants, utilisés pour représenter des vecteurs épars. Pour plus d'informations, voir Vecteurs épars.
    18. Milvus prend en charge plusieurs champs de vecteurs dans une collection. Pour plus d'informations, voir Recherche hybride.

      @@ -154,7 +157,10 @@ fields = [

      Propriétés du schéma de collection

      PropriétésDescription Note
      PropriétésDescription du champRemarque
      nameNom du champ dans la collection à créerNom du champ à créer dans la collection Type de données : Chaîne.
      Obligatoire
      - + + + + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

      Créez une collection avec le schéma spécifié :

      -
      from pymilvus import Collection
      +
      from pymilvus import Collection,connections
      +conn = connections.connect(host="127.0.0.1", port=19530)
       collection_name1 = "tutorial_1"
       collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
       
      diff --git a/localization/v2.4.x/site/fr/reference/users_and_roles.json b/localization/v2.4.x/site/fr/reference/users_and_roles.json index 93d00d9f3..3357722d4 100644 --- a/localization/v2.4.x/site/fr/reference/users_and_roles.json +++ b/localization/v2.4.x/site/fr/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"Utilisateurs et rôles","href":"Users-and-Roles","type":1,"isActive":false},{"label":"Concepts clés","href":"Key-concepts","type":2,"isActive":false},{"label":"Exemple : Octroi de privilèges","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utilisateurs et rôles par défaut","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Liste des types d'objets et des privilèges","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"Utilisateurs, privilèges et rôles","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"Concepts clés","href":"Key-concepts","type":2,"isActive":false},{"label":"Exemple : Octroi de privilèges","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utilisateurs et rôles par défaut","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Liste des types d'objets et des privilèges","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"Prochaines étapes","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/reference/users_and_roles.md b/localization/v2.4.x/site/fr/reference/users_and_roles.md index d4dbfac9d..cbed4da40 100644 --- a/localization/v2.4.x/site/fr/reference/users_and_roles.md +++ b/localization/v2.4.x/site/fr/reference/users_and_roles.md @@ -4,9 +4,9 @@ related_key: 'users, roles' summary: >- Découvrez la définition des utilisateurs, des rôles, des objets et des privilèges dans le cadre du contrôle d'accès basé sur les rôles (RBAC). -title: Utilisateurs et rôles +title: 'Utilisateurs, privilèges et rôles' --- -

      Utilisateurs et rôles

      - + diff --git a/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..548f26a72 --- /dev/null +++ b/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"Recherche en entonnoir avec Matryoshka Embeddings","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"Modèle d'intégration Matryoshka","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"Chargement de l'ensemble de données, intégration des éléments et construction de la base de données vectorielle","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"Recherche en entonnoir","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"Comparaison entre la recherche en entonnoir et la recherche normale","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"Enquête sur l'échec du rappel de la recherche en entonnoir pour Ferris Bueller's Day Off","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"L'ordre a-t-il de l'importance ? Intégration des préfixes et des suffixes.","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"Résumé","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..31b8922c0 --- /dev/null +++ b/localization/v2.4.x/site/fr/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,571 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + Dans ce carnet, nous examinons comment utiliser les encastrements Matryoshka + avec Milvus pour la recherche sémantique. Nous illustrons un algorithme appelé + "funnel search" qui nous permet d'effectuer une recherche de similarité sur un + petit sous-ensemble de nos dimensions d'intégration sans baisse drastique du + rappel. +title: Recherche en entonnoir avec Matryoshka Embeddings +--- +

      Recherche en entonnoir avec Matryoshka Embeddings

      Lors de la construction de systèmes de recherche vectorielle efficaces, l'un des principaux défis consiste à gérer les coûts de stockage tout en maintenant une latence et un rappel acceptables. Les modèles d'intégration modernes produisent des vecteurs comportant des centaines ou des milliers de dimensions, ce qui entraîne une surcharge de stockage et de calcul importante pour le vecteur brut et l'index.

      +

      Traditionnellement, les besoins en stockage sont réduits par l'application d'une méthode de quantification ou de réduction de la dimensionnalité juste avant la construction de l'index. Par exemple, nous pouvons économiser de l'espace de stockage en réduisant la précision à l'aide de la quantification par produit (PQ) ou le nombre de dimensions à l'aide de l'analyse en composantes principales (ACP). Ces méthodes analysent l'ensemble des vecteurs pour en trouver un plus compact qui préserve les relations sémantiques entre les vecteurs.

      +

      Bien qu'efficaces, ces approches standard ne réduisent la précision ou la dimensionnalité qu'une seule fois et à une seule échelle. Mais que se passerait-il si nous pouvions maintenir simultanément plusieurs couches de détails, comme une pyramide de représentations de plus en plus précises ?

      +

      C'est là qu'interviennent les encastrements Matryoshka. Nommées d'après les poupées russes gigognes (voir illustration), ces constructions astucieuses intègrent plusieurs échelles de représentation dans un seul vecteur. Contrairement aux méthodes traditionnelles de post-traitement, les Matryoshka embeddings apprennent cette structure multi-échelle au cours du processus d'apprentissage initial. Le résultat est remarquable : non seulement l'intégration complète capture la sémantique de l'entrée, mais chaque préfixe de sous-ensemble imbriqué (première moitié, premier quart, etc.) fournit une représentation cohérente, bien que moins détaillée.

      +
      +

      Dans ce carnet, nous examinons comment utiliser les encastrements Matryoshka avec Milvus pour la recherche sémantique. Nous illustrons un algorithme appelé "funnel search" qui nous permet d'effectuer une recherche de similarité sur un petit sous-ensemble de nos dimensions d'encastrement sans baisse drastique du rappel.

      +
      import functools
      +
      +from datasets import load_dataset
      +import numpy as np
      +import pandas as pd
      +import pymilvus
      +from pymilvus import MilvusClient
      +from pymilvus import FieldSchema, CollectionSchema, DataType
      +from sentence_transformers import SentenceTransformer
      +import torch
      +import torch.nn.functional as F
      +from tqdm import tqdm
      +
      +

      Modèle d'intégration Matryoshka

      Au lieu d'utiliser un modèle d'intégration standard tel que sentence-transformers/all-MiniLM-L12-v2nous utilisons un modèle de Nomic entraîné spécialement pour produire des embeddings Matryoshka.

      +
      model = SentenceTransformer(
      +    # Remove 'device='mps' if running on non-Mac device
      +    "nomic-ai/nomic-embed-text-v1.5",
      +    trust_remote_code=True,
      +    device="mps",
      +)
      +
      +
      <All keys matched successfully>
      +
      +

      Chargement de l'ensemble de données, intégration des éléments et construction de la base de données vectorielle

      Le code suivant est une modification de celui de la page de documentation "Movie Search with Sentence Transformers and Milvus". Tout d'abord, nous chargeons le jeu de données de HuggingFace. Il contient environ 35k entrées, chacune correspondant à un film ayant un article Wikipédia. Nous utiliserons les champs Title et PlotSummary dans cet exemple.

      +
      ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
      +print(ds)
      +
      +
      Dataset({
      +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
      +    num_rows: 34886
      +})
      +
      +

      Ensuite, nous nous connectons à une base de données Milvus Lite, nous spécifions le schéma de données et nous créons une collection avec ce schéma. Nous stockerons à la fois l'intégration non normalisée et le premier sixième de l'intégration dans des champs distincts. La raison en est que nous avons besoin du premier 1/6e de l'intégration de Matryoshka pour effectuer une recherche de similarité, et des 5/6e restants de l'intégration pour le reclassement et l'amélioration des résultats de la recherche.

      +
      embedding_dim = 768
      +search_dim = 128
      +collection_name = "movie_embeddings"
      +
      +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
      +
      +fields = [
      +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
      +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
      +    # First sixth of unnormalized embedding vector
      +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
      +    # Entire unnormalized embedding vector
      +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
      +]
      +
      +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
      +client.create_collection(collection_name=collection_name, schema=schema)
      +
      +

      Milvus ne prend pas actuellement en charge la recherche sur des sous-ensembles d'enchâssements, c'est pourquoi nous divisons les enchâssements en deux parties : la tête représente le sous-ensemble initial du vecteur à indexer et à rechercher, et la queue est le reste. Le modèle est formé pour la recherche de similarité par distance cosinusoïdale, nous normalisons donc les intégrations de la tête. Cependant, afin de calculer ultérieurement les similarités pour des sous-ensembles plus importants, nous devons stocker la norme de l'intégration de la tête, afin de pouvoir la dé-normaliser avant de la joindre à la queue.

      +

      Pour effectuer une recherche via le premier 1/6e de l'intégration, nous devrons créer un index de recherche vectorielle sur le champ head_embedding. Plus tard, nous comparerons les résultats de la "recherche en entonnoir" à ceux d'une recherche vectorielle classique, et construirons donc également un index de recherche sur l'ensemble de l'intégration.

      +

      Il est important de noter que nous utilisons la métrique de distance COSINE plutôt que IP, car sinon nous devrions tenir compte des normes d'intégration, ce qui compliquerait la mise en œuvre (cela aura plus de sens une fois que l'algorithme de recherche en entonnoir aura été décrit).

      +
      index_params = client.prepare_index_params()
      +index_params.add_index(
      +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
      +)
      +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
      +client.create_index(collection_name, index_params)
      +
      +

      Enfin, nous codons les résumés de l'intrigue pour l'ensemble des 35 000 films et entrons les encastrements correspondants dans la base de données.

      +
      for batch in tqdm(ds.batch(batch_size=512)):
      +    # This particular model requires us to prefix 'search_document:' to stored entities
      +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
      +
      +    # Output of embedding model is unnormalized
      +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
      +    head_embeddings = embeddings[:, :search_dim]
      +
      +    data = [
      +        {
      +            "title": title,
      +            "head_embedding": head.cpu().numpy(),
      +            "embedding": embedding.cpu().numpy(),
      +        }
      +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
      +    ]
      +    res = client.insert(collection_name=collection_name, data=data)
      +
      +
      100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
      +
      +

      Mettons maintenant en œuvre une "recherche en entonnoir" en utilisant le premier 1/6e des dimensions de l'encastrement de Matryoshka. J'ai en tête trois films à récupérer et j'ai produit mon propre résumé de l'intrigue pour interroger la base de données. Nous intégrons les requêtes, puis nous effectuons une recherche vectorielle sur le champ head_embedding, ce qui nous permet d'obtenir 128 résultats.

      +
      queries = [
      +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
      +    "A teenager fakes illness to get off school and have adventures with two friends.",
      +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
      +]
      +
      +
      +# Search the database based on input text
      +def embed_search(data):
      +    embeds = model.encode(data)
      +    return [x for x in embeds]
      +
      +
      +# This particular model requires us to prefix 'search_query:' to queries
      +instruct_queries = ["search_query: " + q.strip() for q in queries]
      +search_data = embed_search(instruct_queries)
      +
      +# Normalize head embeddings
      +head_search = [x[:search_dim] for x in search_data]
      +
      +# Perform standard vector search on first sixth of embedding dimensions
      +res = client.search(
      +    collection_name=collection_name,
      +    data=head_search,
      +    anns_field="head_embedding",
      +    limit=128,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +

      À ce stade, nous avons effectué une recherche sur un espace vectoriel beaucoup plus petit et nous sommes donc susceptibles d'avoir réduit la latence et les besoins de stockage de l'index par rapport à une recherche sur l'espace complet. Examinons les 5 premiers résultats pour chaque requête :

      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits][:5]
      +
      +    print("Query:", query)
      +    print("Results:")
      +    for row in rows:
      +        print(row["title"].strip())
      +    print()
      +
      +
      Query: An archaeologist searches for ancient artifacts while fighting Nazis.
      +Results:
      +"Pimpernel" Smith
      +Black Hunters
      +The Passage
      +Counterblast
      +Dominion: Prequel to the Exorcist
      +
      +Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Results:
      +How to Deal
      +Shorts
      +Blackbird
      +Valentine
      +Unfriended
      +
      +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
      +Results:
      +Ghostkeeper
      +Our Vines Have Tender Grapes
      +The Ref
      +Impact
      +The House in Marsh Road
      +
      +

      Comme nous pouvons le constater, le rappel a souffert de la troncature des encastrements lors de la recherche. La recherche en entonnoir résout ce problème grâce à une astuce astucieuse : nous pouvons utiliser le reste des dimensions d'intégration pour reclasser et élaguer notre liste de candidats afin de récupérer les performances d'extraction sans effectuer de recherches vectorielles supplémentaires coûteuses.

      +

      Pour faciliter la présentation de l'algorithme de recherche en entonnoir, nous convertissons les résultats de la recherche Milvus pour chaque requête en un cadre de données Pandas.

      +
      def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
      +    """
      +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
      +
      +    """
      +    rows = [x["entity"] for x in hits]
      +    rows_dict = [
      +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
      +    ]
      +    return pd.DataFrame.from_records(rows_dict)
      +
      +
      +dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +

      Pour effectuer une recherche en entonnoir, nous itérons sur les sous-ensembles de plus en plus grands des encastrements. À chaque itération, nous classons les candidats en fonction des nouvelles similarités et nous éliminons une partie des candidats les moins bien classés.

      +

      Concrètement, à l'étape précédente, nous avons récupéré 128 candidats en utilisant 1/6 des dimensions de l'intégration et de la requête. La première étape de la recherche en entonnoir consiste à recalculer les similitudes entre les requêtes et les candidats en utilisant le premier tiers des dimensions. Les 64 candidats les plus bas sont éliminés. Nous répétons ensuite ce processus avec les deux premiers tiers des dimensions, puis avec toutes les dimensions, en réduisant successivement le nombre de candidats à 32 et à 16.

      +
      # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
      +def calculate_score(row, query_emb=None, dims=768):
      +    emb = F.normalize(row["embedding"][:dims], dim=-1)
      +    return (emb @ query_emb).item()
      +
      +
      +# You could also add a top-K parameter as a termination condition
      +def funnel_search(
      +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
      +) -> pd.DataFrame:
      +    # Loop over increasing prefixes of the embeddings
      +    for dims in scales:
      +        # Query vector must be normalized for each new dimensionality
      +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
      +
      +        # Score
      +        scores = df.apply(
      +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
      +        )
      +        df["scores"] = scores
      +
      +        # Re-rank
      +        df = df.sort_values(by="scores", ascending=False)
      +
      +        # Prune (in our case, remove half of candidates at each step)
      +        df = df.head(int(prune_ratio * len(df)))
      +
      +    return df
      +
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries, dfs, search_data)
      +]
      +
      +
      for d in dfs_results:
      +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
      +
      +
      An archaeologist searches for ancient artifacts while fighting Nazis. 
      + 0           "Pimpernel" Smith
      +1               Black Hunters
      +29    Raiders of the Lost Ark
      +34             The Master Key
      +51            My Gun Is Quick
      +Name: title, dtype: object 
      +
      +A teenager fakes illness to get off school and have adventures with two friends. 
      + 21               How I Live Now
      +32     On the Edge of Innocence
      +77             Bratz: The Movie
      +4                    Unfriended
      +108                  Simon Says
      +Name: title, dtype: object 
      +
      +A young couple with a kid look after a hotel during winter and the husband goes insane. 
      + 9         The Shining
      +0         Ghostkeeper
      +11     Fast and Loose
      +7      Killing Ground
      +12         Home Alone
      +Name: title, dtype: object 
      +
      +

      Nous avons pu rétablir le rappel sans effectuer de recherches vectorielles supplémentaires ! Qualitativement, ces résultats semblent avoir un meilleur rappel pour "Raiders of the Lost Ark" et "The Shining" que la recherche vectorielle standard du tutoriel, "Movie Search using Milvus and Sentence Transformers", qui utilise un modèle d'intégration différent. Cependant, elle ne parvient pas à trouver "Ferris Bueller's Day Off", sur lequel nous reviendrons plus loin dans le carnet. (Voir l'article Matryoshka Representation Learning pour plus d'expériences quantitatives et d'analyses comparatives).

      +

      Comparons les résultats de notre recherche en entonnoir à une recherche vectorielle standard sur le même ensemble de données avec le même modèle d'intégration. Nous effectuons une recherche sur les encastrements complets.

      +
      # Search on entire embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=search_data,
      +    anns_field="embedding",
      +    limit=5,
      +    output_fields=["title", "embedding"],
      +)
      +
      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits]
      +
      +    print("Query:", query)
      +    print("Results:")
      +    for row in rows:
      +        print(row["title"].strip())
      +    print()
      +
      +
      Query: An archaeologist searches for ancient artifacts while fighting Nazis.
      +Results:
      +"Pimpernel" Smith
      +Black Hunters
      +Raiders of the Lost Ark
      +The Master Key
      +My Gun Is Quick
      +
      +Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Results:
      +A Walk to Remember
      +Ferris Bueller's Day Off
      +How I Live Now
      +On the Edge of Innocence
      +Bratz: The Movie
      +
      +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
      +Results:
      +The Shining
      +Ghostkeeper
      +Fast and Loose
      +Killing Ground
      +Home Alone
      +
      +

      À l'exception des résultats pour "Un adolescent fait semblant d'être malade pour ne pas aller à l'école...", les résultats de la recherche en entonnoir sont presque identiques à ceux de la recherche complète, même si la recherche en entonnoir a été effectuée sur un espace de recherche de 128 dimensions contre 768 dimensions pour la recherche normale.

      +

      Enquête sur l'échec du rappel de la recherche en entonnoir pour Ferris Bueller's Day Off

      Pourquoi la recherche en entonnoir n'a-t-elle pas permis de retrouver Ferris Bueller's Day Off ? Examinons s'il figurait dans la liste originale des candidats ou s'il a été filtré par erreur.

      +
      queries2 = [
      +    "A teenager fakes illness to get off school and have adventures with two friends."
      +]
      +
      +
      +# Search the database based on input text
      +def embed_search(data):
      +    embeds = model.encode(data)
      +    return [x for x in embeds]
      +
      +
      +instruct_queries = ["search_query: " + q.strip() for q in queries2]
      +search_data2 = embed_search(instruct_queries)
      +head_search2 = [x[:search_dim] for x in search_data2]
      +
      +# Perform standard vector search on subset of embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=head_search2,
      +    anns_field="head_embedding",
      +    limit=256,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits]
      +
      +    print("Query:", queries2[0])
      +    for idx, row in enumerate(rows):
      +        if row["title"].strip() == "Ferris Bueller's Day Off":
      +            print(f"Row {idx}: Ferris Bueller's Day Off")
      +
      +
      Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Row 228: Ferris Bueller's Day Off
      +
      +

      Nous constatons que le problème réside dans le fait que la liste initiale des candidats n'était pas assez grande, ou plutôt que l'occurrence souhaitée n'était pas assez similaire à la requête au niveau de granularité le plus élevé. En passant de 128 à 256, la recherche est couronnée de succès. Nous devrions établir une règle empirique pour fixer le nombre de candidats sur un ensemble retenu afin d'évaluer empiriquement le compromis entre le rappel et la latence.

      +
      dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries2, dfs, search_data2)
      +]
      +
      +for d in dfs_results:
      +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
      +
      +
      A teenager fakes illness to get off school and have adventures with two friends. 
      +       A Walk to Remember
      +Ferris Bueller's Day Off
      +          How I Live Now
      +On the Edge of Innocence
      +        Bratz: The Movie
      +              Unfriended
      +              Simon Says 
      +
      +

      L'ordre a-t-il de l'importance ? Intégration des préfixes et des suffixes.

      Le modèle a été entraîné à bien faire correspondre les préfixes récursivement plus petits des enchâssements. L'ordre des dimensions que nous utilisons a-t-il une importance ? Par exemple, pourrions-nous également prendre des sous-ensembles d'enchâssements qui sont des suffixes ? Dans cette expérience, nous inversons l'ordre des dimensions dans les encastrements de Matryoshka et effectuons une recherche en entonnoir.

      +
      client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
      +
      +fields = [
      +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
      +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
      +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
      +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
      +]
      +
      +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
      +client.create_collection(collection_name=collection_name, schema=schema)
      +
      +index_params = client.prepare_index_params()
      +index_params.add_index(
      +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
      +)
      +client.create_index(collection_name, index_params)
      +
      +
      huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
      +To disable this warning, you can either:
      +    - Avoid using `tokenizers` before the fork if possible
      +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
      +
      +
      for batch in tqdm(ds.batch(batch_size=512)):
      +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
      +
      +    # Encode and flip embeddings
      +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
      +    embeddings = torch.flip(embeddings, dims=[-1])
      +    head_embeddings = embeddings[:, :search_dim]
      +
      +    data = [
      +        {
      +            "title": title,
      +            "head_embedding": head.cpu().numpy(),
      +            "embedding": embedding.cpu().numpy(),
      +        }
      +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
      +    ]
      +    res = client.insert(collection_name=collection_name, data=data)
      +
      +
      100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
      +
      +
      # Normalize head embeddings
      +
      +flip_search_data = [
      +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
      +]
      +flip_head_search = [x[:search_dim] for x in flip_search_data]
      +
      +# Perform standard vector search on subset of embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=flip_head_search,
      +    anns_field="head_embedding",
      +    limit=128,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +
      dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
      +]
      +
      +for d in dfs_results:
      +    print(
      +        d["query"],
      +        "\n",
      +        d["results"][:7]["title"].to_string(index=False, header=False),
      +        "\n",
      +    )
      +
      +
      An archaeologist searches for ancient artifacts while fighting Nazis. 
      +       "Pimpernel" Smith
      +          Black Hunters
      +Raiders of the Lost Ark
      +         The Master Key
      +        My Gun Is Quick
      +            The Passage
      +        The Mole People 
      +
      +A teenager fakes illness to get off school and have adventures with two friends. 
      +                       A Walk to Remember
      +                          How I Live Now
      +                              Unfriended
      +Cirque du Freak: The Vampire's Assistant
      +                             Last Summer
      +                                 Contest
      +                                 Day One 
      +
      +A young couple with a kid look after a hotel during winter and the husband goes insane. 
      +         Ghostkeeper
      +     Killing Ground
      +Leopard in the Snow
      +              Stone
      +          Afterglow
      +         Unfaithful
      +     Always a Bride 
      +
      +

      Le rappel est beaucoup plus faible que la recherche en entonnoir ou la recherche normale, comme prévu (le modèle d'intégration a été formé par apprentissage contrastif sur les préfixes des dimensions d'intégration, et non sur les suffixes).

      +

      Résumé

      Voici une comparaison des résultats de nos recherches entre les différentes méthodes :

      +
      +
      +
      +Nous avons montré comment utiliser les Matryoshka embeddings avec Milvus pour réaliser un algorithme de recherche sémantique plus efficace appelé "funnel search". Nous avons également exploré l'importance des étapes de reclassement et d'élagage de l'algorithme, ainsi qu'un mode d'échec lorsque la liste initiale de candidats est trop petite. Enfin, nous avons discuté de l'importance de l'ordre des dimensions lors de la formation des sous-embranchements - il doit être le même que celui pour lequel le modèle a été entraîné. Ou plutôt, ce n'est que parce que le modèle a été entraîné d'une certaine manière que les préfixes des encastrements sont significatifs. Vous savez maintenant comment mettre en œuvre les encastrements Matryoshka et la recherche en entonnoir pour réduire les coûts de stockage de la recherche sémantique sans trop sacrifier les performances de recherche ! diff --git a/localization/v2.4.x/site/fr/tutorials/tutorials-overview.md b/localization/v2.4.x/site/fr/tutorials/tutorials-overview.md index b0bd1605a..f15e8d8fc 100644 --- a/localization/v2.4.x/site/fr/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/fr/tutorials/tutorials-overview.md @@ -44,6 +44,7 @@ title: Vue d'ensemble des didacticiels
      - + +
      PropriétésDescription Note
      PropriétésDescription de la collectionRemarque
      GlobalAbandonner le propriétaireDeleteCredential DropRole
      GlobalSélectionner un propriétaireSelectRole/SelectGrant
      GlobalManageOwnershipOperateUserRole OperatePrivilege
      GlobalManageOwnershipExploiter le rôle de l'utilisateur Exploiter le privilège
      GlobalCréer un groupe de ressourcesCréer un groupe de ressources
      GlobalDropResourceGroupDropResourceGroup
      GlobalDescribeResourceGroupDescribeResourceGroup (Décrire le groupe de ressources)
      HDBSCAN Clustering avec MilvusDémarrage rapiderecherche vectorielle
      Utiliser ColPali pour la recherche multimodale avec MilvusDémarrage rapiderecherche vectorielle
      Visualisation vectorielleDémarrage rapiderecherche vectorielle
      Recommandation de films avec MilvusSystème de recommandationrecherche vectorielle
      Recommandation de films avec MilvusSystème de recommandationRecherche vectorielle
      Recherche en entonnoir avec Matryoshka EmbeddingsDémarrage rapiderecherche vectorielle
      diff --git a/localization/v2.4.x/site/fr/userGuide/manage-collections.json b/localization/v2.4.x/site/fr/userGuide/manage-collections.json index 7f513a1d4..2339a381a 100644 --- a/localization/v2.4.x/site/fr/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/fr/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gérer les collections","href":"Manage-Collections","type":1,"isActive":false},{"label":"Avant de commencer","href":"Before-you-start","type":2,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Créer une collection","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualiser les collections","href":"View-Collections","type":2,"isActive":false},{"label":"Charger et libérer une collection","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Définir des alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Définir des propriétés","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonner une collecte","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gérer les collections","href":"Manage-Collections","type":1,"isActive":false},{"label":"Avant de commencer","href":"Before-you-start","type":2,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Créer une collection","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualiser les collections","href":"View-Collections","type":2,"isActive":false},{"label":"Charger et libérer une collection","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Définir des alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Définir des propriétés","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonner une collecte","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/userGuide/manage-collections.md b/localization/v2.4.x/site/fr/userGuide/manage-collections.md index 6648b62c0..179b81ff5 100644 --- a/localization/v2.4.x/site/fr/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/fr/userGuide/manage-collections.md @@ -356,11 +356,11 @@ schema.addField(AddFieldReq.builder() isPrimaryKey - Indique si le champ actuel est le champ primaire d'une collection.
      Chaque collection ne possède qu'un seul champ primaire. Un champ primaire doit être de type DataType.Int64 ou DataType.VarChar. + Indique si le champ actuel est le champ primaire d'une collection.
      Chaque collection n'a qu'un seul champ primaire. Un champ primaire doit être de type DataType.Int64 ou DataType.VarChar. autoID - Indique si le champ primaire peut s'incrémenter automatiquement.
      La valeur true permet au champ primaire de s'incrémenter automatiquement. Dans ce cas, le champ primaire ne doit pas être inclus dans les données à insérer pour éviter les erreurs. + Permet au champ primaire de s'incrémenter automatiquement.
      La valeur true permet au champ primaire de s'incrémenter automatiquement. Dans ce cas, le champ primaire ne doit pas être inclus dans les données à insérer pour éviter les erreurs. dimension @@ -571,7 +571,7 @@ indexParams.add(indexParamForVectorField); index_type - Le nom de l'algorithme utilisé pour organiser les données dans le champ spécifique. Pour les algorithmes applicables, voir Index en mémoire et Index sur disque. + Nom de l'algorithme utilisé pour organiser les données dans le champ spécifique. Pour les algorithmes applicables, voir Index en mémoire et Index sur disque. metric_type @@ -1601,7 +1601,7 @@ $ curl -X POST "http://# 7. Load the collection client.load_collection( collection_name="customized_setup_2", - load_fields=["my_id", "my_vector"] # Load only the specified fields + load_fields=["my_id", "my_vector"], # Load only the specified fields skip_load_dynamic_field=True # Skip loading the dynamic field ) @@ -2076,7 +2076,7 @@ res = await client.alterAlias() en spécifiant le nom de la collection et l'alias.

      -

      Pour réaffecter des alias à d'autres collections, utilisez la méthode alterAlias() en précisant le nom de la collection et l'alias.

      +

      Pour réaffecter des alias à d'autres collections, utilisez la méthode alterAlias() en spécifiant le nom de la collection et l'alias.

      Pour réaffecter des alias à d'autres collections, vous pouvez utiliser le point de terminaison de l'API POST /v2/vectordb/aliases/alter pour réaffecter des alias à d'autres collections, vous pouvez utiliser le point de terminaison de l'API.

      diff --git a/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.json index 331f75d88..4a84d77de 100644 --- a/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.json +++ b/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.json @@ -1 +1 @@ -{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"","anchorList":[{"label":"Index des champs scalaires","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Types d'indexation scalaire","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexation automatique","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexation personnalisée","href":"Custom-indexing","type":2,"isActive":false},{"label":"Vérification du résultat","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"Index des champs scalaires","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Types d'indexation scalaire","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexation automatique","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexation personnalisée","href":"Custom-indexing","type":2,"isActive":false},{"label":"Vérification du résultat","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.md index b98aaf42e..ec10c5712 100644 --- a/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.md +++ b/localization/v2.4.x/site/fr/userGuide/manage-indexes/index-scalar-fields.md @@ -4,7 +4,7 @@ order: 2 summary: >- Ce guide vous aidera à créer et à configurer des index scalaires pour des champs tels que des nombres entiers, des chaînes de caractères, etc. -title: Champs scalaires indexés +title: Index des champs scalaires ---

      Index des champs scalaires

      Avant de lancer une recherche hybride, assurez-vous que vous disposez d'une collection comportant plusieurs champs vectoriels. Actuellement, Milvus introduit une valeur par défaut de quatre champs vectoriels par collection, qui peut être étendue à un maximum de dix en modifiant la configuration proxy.maxVectorFieldNum.

      +

      Avant de lancer une recherche hybride, assurez-vous que vous disposez d'une collection comportant plusieurs champs vectoriels. Actuellement, Milvus introduit une valeur par défaut de quatre champs vectoriels par collection, qui peut être étendue à un maximum de dix en modifiant la configuration proxy.maxVectorFieldNum.

      Voici un exemple de création d'une collection nommée test_collection avec deux champs vectoriels, filmVector et posterVector, et d'insertion d'entités aléatoires dans cette collection.

      from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType
       import random
       
       # Connect to Milvus
       connections.connect(
      -    host="10.102.7.3", # Replace with your Milvus server IP
      +    host="127.0.0.1", # Replace with your Milvus server IP
           port="19530"
       )
       
      @@ -234,7 +234,7 @@ res = collection.hybrid_search(
       

      La stratégie de reclassement à utiliser pour la recherche hybride. Valeurs possibles : WeightedRanker(value1, value2, ..., valueN) et RRFRanker().

      Pour plus d'informations sur les stratégies de reclassement, voir Reranking.

    19. limit (int)

      -

      Nombre maximal de résultats finaux à renvoyer dans la recherche hybride.

    20. +

      Le nombre maximum de résultats finaux à renvoyer dans la recherche hybride.

      La sortie est similaire à ce qui suit :

      ["['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']"]
      diff --git a/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.json
      index f5df4719c..e55ff6f12 100644
      --- a/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.json
      +++ b/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.json
      @@ -1 +1 @@
      -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n    uri=CLUSTER_ENDPOINT,\n    token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n    collection_name=\"quick_setup\",\n    dimension=5,\n    metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n    current_color = random.choice(colors)\n    data.append({\n        \"id\": i,\n        \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n        \"color\": current_color,\n        \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n    })\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 1000,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(990 more items hidden)\"\n#     ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n    collection_name=\"quick_setup\",\n    partition_name=\"red\"\n)\n\nclient.create_partition(\n    collection_name=\"quick_setup\",\n    partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=red_data,\n    partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 500,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(490 more items hidden)\"\n#     ]\n# }\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=blue_data,\n    partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 500,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(490 more items hidden)\"\n#     ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n    .uri(CLUSTER_ENDPOINT)\n    .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);  \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n    .collectionName(\"quick_setup\")\n    .dimension(5)\n    .metricType(\"IP\")\n    .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n    .collectionName(\"quick_setup\")\n    .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n    Random rand = new Random();\n    String current_color = colors.get(rand.nextInt(colors.size()-1));\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n    .collectionName(\"quick_setup\")\n    .partitionName(\"red\")\n    .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n    .collectionName(\"quick_setup\")\n    .partitionName(\"blue\")\n    .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n    Random rand = new Random();\n    String current_color = \"red\";\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color\", current_color);\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}     \n\ninsertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .partitionName(\"red\")\n    .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n    Random rand = new Random();\n    String current_color = \"blue\";\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color\", current_color);\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .partitionName(\"blue\")\n    .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n    collection_name: \"quick_setup\",\n    dimension: 5,\n    metric_type: \"IP\"\n});  \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n    current_color = colors[Math.floor(Math.random() * colors.length)]\n    data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: current_color,\n        color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nvar res = await client.insert({\n    collection_name: \"quick_setup\",\n    data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n    collection_name: \"quick_setup\",\n    partition_name: \"red\"\n})\n\nawait client.createPartition({\n    collection_name: \"quick_setup\",\n    partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n    red_data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: \"red\",\n        color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n    blue_data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: \"blue\",\n        color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nres = await client.insert({\n    collection_name: \"quick_setup\",\n    data: red_data,\n    partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n    collection_name: \"quick_setup\",\n    data: blue_data,\n    partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    # Replace with your query vector\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .topK(3) // The number of results to return\n    .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 0,\n            \"distance\": 1.4093276262283325,\n            \"entity\": {}\n        },\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {}\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {}\n        },\n        {\n            \"id\": 5,\n            \"distance\": 0.7972343564033508,\n            \"entity\": {}\n        },\n        {\n            \"id\": 2,\n            \"distance\": 0.5928734540939331,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [[\n    {\n        \"score\": 1.263043,\n        \"fields\": {\n            \"vector\": [\n                0.9533119,\n                0.02538395,\n                0.76714665,\n                0.35481733,\n                0.9845762\n            ],\n            \"id\": 740\n        }\n    },\n    {\n        \"score\": 1.2377806,\n        \"fields\": {\n            \"vector\": [\n                0.7411156,\n                0.08687937,\n                0.8254139,\n                0.08370924,\n                0.99095553\n            ],\n            \"id\": 640\n        }\n    },\n    {\n        \"score\": 1.1869997,\n        \"fields\": {\n            \"vector\": [\n                0.87928146,\n                0.05324632,\n                0.6312755,\n                0.28005534,\n                0.9542448\n            ],\n            \"id\": 455\n        }\n    }\n]]}\n","[\n  { score: 1.7463608980178833, id: '854' },\n  { score: 1.744946002960205, id: '425' },\n  { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    data=[\n        [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n        [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n    ], # Replace with your query vectors\n    limit=2, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n    Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n    Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .topK(2)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n    [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n    [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: query_vectors,\n    limit: 2,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 1,\n            \"distance\": 1.3017789125442505,\n            \"entity\": {}\n        },\n        {\n            \"id\": 7,\n            \"distance\": 1.2419954538345337,\n            \"entity\": {}\n        }\n    ], # Result set 1\n    [\n        {\n            \"id\": 3,\n            \"distance\": 2.3358664512634277,\n            \"entity\": {}\n        },\n        {\n            \"id\": 8,\n            \"distance\": 0.5642921924591064,\n            \"entity\": {}\n        }\n    ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {\n                \"vector\": [\n                    0.9533119,\n                    0.02538395,\n                    0.76714665,\n                    0.35481733,\n                    0.9845762\n                ],\n                \"id\": 740\n            }\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {\n                \"vector\": [\n                    0.7411156,\n                    0.08687937,\n                    0.8254139,\n                    0.08370924,\n                    0.99095553\n                ],\n                \"id\": 640\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8654699,\n            \"fields\": {\n                \"vector\": [\n                    0.4671427,\n                    0.8378432,\n                    0.98844475,\n                    0.82763994,\n                    0.9729997\n                ],\n                \"id\": 638\n            }\n        },\n        {\n            \"score\": 1.8581753,\n            \"fields\": {\n                \"vector\": [\n                    0.735541,\n                    0.60140246,\n                    0.86730254,\n                    0.93152493,\n                    0.98603314\n                ],\n                \"id\": 855\n            }\n        }\n    ]\n]}\n","[\n  [\n    { score: 2.3590476512908936, id: '854' },\n    { score: 2.2896690368652344, id: '59' }\n  [\n    { score: 2.664059638977051, id: '59' },\n    { score: 2.59483003616333, id: '854' }\n  ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n    collection_name=\"quick_setup\",\n    data=[query_vector],\n    limit=5,\n    search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n    partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .partitionNames(Arrays.asList(\"red\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    partition_names: [\"red\"],\n    limit: 5,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 16,\n            \"distance\": 0.9200337529182434,\n            \"entity\": {}\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.4505271911621094,\n            \"entity\": {}\n        },\n        {\n            \"id\": 15,\n            \"distance\": 0.19924677908420563,\n            \"entity\": {}\n        },\n        {\n            \"id\": 17,\n            \"distance\": 0.0075093843042850494,\n            \"entity\": {}\n        },\n        {\n            \"id\": 13,\n            \"distance\": -0.14609718322753906,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1677284,\n            \"fields\": {\n                \"vector\": [\n                    0.9986977,\n                    0.17964739,\n                    0.49086612,\n                    0.23155272,\n                    0.98438674\n                ],\n                \"id\": 1435\n            }\n        },\n        {\n            \"score\": 1.1476475,\n            \"fields\": {\n                \"vector\": [\n                    0.6952647,\n                    0.13417172,\n                    0.91045254,\n                    0.119336545,\n                    0.9338931\n                ],\n                \"id\": 1291\n            }\n        },\n        {\n            \"score\": 1.0969629,\n            \"fields\": {\n                \"vector\": [\n                    0.3363194,\n                    0.028906643,\n                    0.6675426,\n                    0.030419827,\n                    0.9735209\n                ],\n                \"id\": 1168\n            }\n        },\n        {\n            \"score\": 1.0741848,\n            \"fields\": {\n                \"vector\": [\n                    0.9980543,\n                    0.36063594,\n                    0.66427994,\n                    0.17359233,\n                    0.94954175\n                ],\n                \"id\": 1164\n            }\n        },\n        {\n            \"score\": 1.0584627,\n            \"fields\": {\n                \"vector\": [\n                    0.7187005,\n                    0.12674773,\n                    0.987718,\n                    0.3110777,\n                    0.86093885\n                ],\n                \"id\": 1085\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8030131,\n            \"fields\": {\n                \"vector\": [\n                    0.59726167,\n                    0.7054632,\n                    0.9573117,\n                    0.94529945,\n                    0.8664103\n                ],\n                \"id\": 1203\n            }\n        },\n        {\n            \"score\": 1.7728865,\n            \"fields\": {\n                \"vector\": [\n                    0.6672442,\n                    0.60448086,\n                    0.9325822,\n                    0.80272985,\n                    0.8861626\n                ],\n                \"id\": 1448\n            }\n        },\n        {\n            \"score\": 1.7536311,\n            \"fields\": {\n                \"vector\": [\n                    0.59663296,\n                    0.77831805,\n                    0.8578314,\n                    0.88818026,\n                    0.9030075\n                ],\n                \"id\": 1010\n            }\n        },\n        {\n            \"score\": 1.7520742,\n            \"fields\": {\n                \"vector\": [\n                    0.854198,\n                    0.72294194,\n                    0.9245805,\n                    0.86126596,\n                    0.7969224\n                ],\n                \"id\": 1219\n            }\n        },\n        {\n            \"score\": 1.7452049,\n            \"fields\": {\n                \"vector\": [\n                    0.96419,\n                    0.943535,\n                    0.87611496,\n                    0.8268136,\n                    0.79786557\n                ],\n                \"id\": 1149\n            }\n        }\n    ]\n]}\n","[\n  { score: 3.0258803367614746, id: '1201' },\n  { score: 3.004319190979004, id: '1458' },\n  { score: 2.880324363708496, id: '1187' },\n  { score: 2.8246407508850098, id: '1347' },\n  { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n    collection_name=\"quick_setup\",\n    data=[query_vector],\n    limit=5,\n    search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n    partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .partitionNames(Arrays.asList(\"blue\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    partition_names: [\"blue\"],\n    limit: 5,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 20,\n            \"distance\": 2.363696813583374,\n            \"entity\": {}\n        },\n        {\n            \"id\": 26,\n            \"distance\": 1.0665391683578491,\n            \"entity\": {}\n        },\n        {\n            \"id\": 23,\n            \"distance\": 1.066049575805664,\n            \"entity\": {}\n        },\n        {\n            \"id\": 29,\n            \"distance\": 0.8353596925735474,\n            \"entity\": {}\n        },\n        {\n            \"id\": 28,\n            \"distance\": 0.7484277486801147,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1628494,\n            \"fields\": {\n                \"vector\": [\n                    0.7442872,\n                    0.046407282,\n                    0.71031404,\n                    0.3544345,\n                    0.9819991\n                ],\n                \"id\": 1992\n            }\n        },\n        {\n            \"score\": 1.1470042,\n            \"fields\": {\n                \"vector\": [\n                    0.5505825,\n                    0.04367262,\n                    0.9985836,\n                    0.18922359,\n                    0.93255126\n                ],\n                \"id\": 1977\n            }\n        },\n        {\n            \"score\": 1.1450152,\n            \"fields\": {\n                \"vector\": [\n                    0.89994013,\n                    0.052991092,\n                    0.8645576,\n                    0.6406729,\n                    0.95679337\n                ],\n                \"id\": 1573\n            }\n        },\n        {\n            \"score\": 1.1439825,\n            \"fields\": {\n                \"vector\": [\n                    0.9253267,\n                    0.15890503,\n                    0.7999555,\n                    0.19126713,\n                    0.898583\n                ],\n                \"id\": 1552\n            }\n        },\n        {\n            \"score\": 1.1029172,\n            \"fields\": {\n                \"vector\": [\n                    0.95661926,\n                    0.18777144,\n                    0.38115507,\n                    0.14323527,\n                    0.93137646\n                ],\n                \"id\": 1823\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8005109,\n            \"fields\": {\n                \"vector\": [\n                    0.5953582,\n                    0.7794224,\n                    0.9388869,\n                    0.79825854,\n                    0.9197286\n                ],\n                \"id\": 1888\n            }\n        },\n        {\n            \"score\": 1.7714822,\n            \"fields\": {\n                \"vector\": [\n                    0.56805456,\n                    0.89422905,\n                    0.88187534,\n                    0.914824,\n                    0.8944365\n                ],\n                \"id\": 1648\n            }\n        },\n        {\n            \"score\": 1.7561421,\n            \"fields\": {\n                \"vector\": [\n                    0.83421993,\n                    0.39865613,\n                    0.92319834,\n                    0.42695504,\n                    0.96633124\n                ],\n                \"id\": 1688\n            }\n        },\n        {\n            \"score\": 1.7553532,\n            \"fields\": {\n                \"vector\": [\n                    0.89994013,\n                    0.052991092,\n                    0.8645576,\n                    0.6406729,\n                    0.95679337\n                ],\n                \"id\": 1573\n            }\n        },\n        {\n            \"score\": 1.7543385,\n            \"fields\": {\n                \"vector\": [\n                    0.16542226,\n                    0.38248396,\n                    0.9888778,\n                    0.80913955,\n                    0.9501492\n                ],\n                \"id\": 1544\n            }\n        }\n    ]\n]}\n","[\n  { score: 2.8421106338500977, id: '1745' },\n  { score: 2.838560104370117, id: '1782' },\n  { score: 2.8134000301361084, id: '1511' },\n  { score: 2.718268871307373, id: '1679' },\n  { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 0,\n            \"distance\": 1.4093276262283325,\n            \"entity\": {\n                \"color\": \"pink_8682\"\n            }\n        },\n        {\n            \"id\": 16,\n            \"distance\": 1.0159327983856201,\n            \"entity\": {\n                \"color\": \"yellow_1496\"\n            }\n        },\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.9803846478462219,\n            \"entity\": {\n                \"color\": \"green_2899\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1869997,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1748955,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1720343,\n            \"fields\": {}\n        }\n    ]\n]}\n","\n[\n  { score: 3.036271572113037, id: '59', color: 'orange' },\n  { score: 3.0267879962921143, id: '1745', color: 'blue' },\n  { score: 3.0069446563720703, id: '854', color: 'black' },\n  { score: 2.984386682510376, id: '718', color: 'black' },\n  { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n    filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .filter(\"color_tag like \\\"red%\\\"\")\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    filters: \"color_tag like \\\"red%\\\"\",\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        },\n        {\n            \"id\": 6,\n            \"distance\": -0.4113418459892273,\n            \"entity\": {\n                \"color\": \"red_9392\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"red_3026\"}\n        },\n        {\n            \"score\": 1.1677284,\n            \"fields\": {\"color_tag\": \"red_9030\"}\n        },\n        {\n            \"score\": 1.1476475,\n            \"fields\": {\"color_tag\": \"red_3744\"}\n        },\n        {\n            \"score\": 1.0969629,\n            \"fields\": {\"color_tag\": \"red_4168\"}\n        },\n        {\n            \"score\": 1.0741848,\n            \"fields\": {\"color_tag\": \"red_9678\"}\n        }\n    ]\n]}\n","[\n  { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n  { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n  { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n  { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n  { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n    filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .filter(\"color like \\\"%ll%\\\"\")\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    filters: \"color_tag like \\\"%ll%\\\"\",\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 5,\n            \"distance\": 0.7972343564033508,\n            \"entity\": {\n                \"color\": \"yellow_4222\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"yellow_4222\"}\n        }\n    ]\n]}\n","[\n  { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n    \"metric_type\": \"IP\",\n    \"params\": {\n        \"radius\": 0.8, # Radius of the search circle\n        \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n    }\n}\n\nres = client.search(\n    collection_name=\"test_collection\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=3, # Max. number of search results to return\n    search_params=search_params, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    params: {\n        radius: 0.1,\n        range: 1.0\n    },\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.9803846478462219,\n            \"entity\": {\n                \"color\": \"green_2899\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {\"color_tag\": \"green_2052\"}\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {\"color_tag\": \"purple_3709\"}\n        },\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"red_3026\"}\n        },\n        {\n            \"score\": 1.1748955,\n            \"fields\": {\"color_tag\": \"black_1646\"}\n        },\n        {\n            \"score\": 1.1720343,\n            \"fields\": {\"color_tag\": \"green_4853\"}\n        }\n    ]\n]}\n","[\n  { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n  { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n  { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n  { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n  { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n    collection_name=\"group_search\", # Collection name\n    data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n    search_params={\n    \"metric_type\": \"L2\",\n    \"params\": {\"nprobe\": 10},\n    }, # Search parameters\n    limit=5, # Max. number of groups to return\n    group_by_field=\"doc_id\", # Group results by document ID\n    group_size=2, # returned at most 2 passages per document, the default value is 1\n    group_strict_size=True, # ensure every group contains exactly 3 passages\n    output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n    collection_name=\"group_search\", # Collection name\n    data=query_passage_vector, # Replace with your query vector\n    search_params={\n    \"metric_type\": \"L2\",\n    \"params\": {\"nprobe\": 10},\n    }, # Search parameters\n    limit=5, # Max. number of search results to return\n    # group_by_field=\"doc_id\", # Group results by document ID\n    # group_size=2, \n    # group_strict_size=True,\n    output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n    'metric_type': 'L2',\n    'params': {\n        'nprobe': 10,\n        'level': 1,\n        'radius': 1.0\n        'range_filter': 0.8\n    }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Recherche à vecteur unique","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Préparations","href":"Preparations","type":2,"isActive":false},{"label":"Recherche de base","href":"Basic-search","type":2,"isActive":false},{"label":"Recherche filtrée","href":"Filtered-search","type":2,"isActive":false},{"label":"Recherche par plage","href":"Range-search","type":2,"isActive":false},{"label":"Recherche par regroupement","href":"Grouping-search","type":2,"isActive":false},{"label":"Paramètres de recherche","href":"Search-parameters","type":2,"isActive":false}]}
      \ No newline at end of file
      +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n    uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n    collection_name=\"quick_setup\",\n    dimension=5,\n    metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n    current_color = random.choice(colors)\n    data.append({\n        \"id\": i,\n        \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n        \"color\": current_color,\n        \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n    })\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 1000,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(990 more items hidden)\"\n#     ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n    collection_name=\"quick_setup\",\n    partition_name=\"red\"\n)\n\nclient.create_partition(\n    collection_name=\"quick_setup\",\n    partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=red_data,\n    partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 500,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(490 more items hidden)\"\n#     ]\n# }\n\nres = client.insert(\n    collection_name=\"quick_setup\",\n    data=blue_data,\n    partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n#     \"insert_count\": 500,\n#     \"ids\": [\n#         0,\n#         1,\n#         2,\n#         3,\n#         4,\n#         5,\n#         6,\n#         7,\n#         8,\n#         9,\n#         \"(490 more items hidden)\"\n#     ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n    .uri(CLUSTER_ENDPOINT)\n    .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);  \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n    .collectionName(\"quick_setup\")\n    .dimension(5)\n    .metricType(\"IP\")\n    .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n    .collectionName(\"quick_setup\")\n    .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n    Random rand = new Random();\n    String current_color = colors.get(rand.nextInt(colors.size()-1));\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n    .collectionName(\"quick_setup\")\n    .partitionName(\"red\")\n    .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n    .collectionName(\"quick_setup\")\n    .partitionName(\"blue\")\n    .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n    Random rand = new Random();\n    String current_color = \"red\";\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color\", current_color);\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}     \n\ninsertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .partitionName(\"red\")\n    .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n    Random rand = new Random();\n    String current_color = \"blue\";\n    JSONObject row = new JSONObject();\n    row.put(\"id\", Long.valueOf(i));\n    row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n    row.put(\"color\", current_color);\n    row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n    data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(data)\n    .partitionName(\"blue\")\n    .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n    collection_name: \"quick_setup\",\n    dimension: 5,\n    metric_type: \"IP\"\n});  \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n    current_color = colors[Math.floor(Math.random() * colors.length)]\n    data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: current_color,\n        color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nvar res = await client.insert({\n    collection_name: \"quick_setup\",\n    data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n    collection_name: \"quick_setup\",\n    partition_name: \"red\"\n})\n\nawait client.createPartition({\n    collection_name: \"quick_setup\",\n    partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n    red_data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: \"red\",\n        color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n    blue_data.push({\n        id: i,\n        vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n        color: \"blue\",\n        color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n    })\n}\n\nres = await client.insert({\n    collection_name: \"quick_setup\",\n    data: red_data,\n    partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n    collection_name: \"quick_setup\",\n    data: blue_data,\n    partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    # Replace with your query vector\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .topK(3) // The number of results to return\n    .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 0,\n            \"distance\": 1.4093276262283325,\n            \"entity\": {}\n        },\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {}\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {}\n        },\n        {\n            \"id\": 5,\n            \"distance\": 0.7972343564033508,\n            \"entity\": {}\n        },\n        {\n            \"id\": 2,\n            \"distance\": 0.5928734540939331,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [[\n    {\n        \"score\": 1.263043,\n        \"fields\": {\n            \"vector\": [\n                0.9533119,\n                0.02538395,\n                0.76714665,\n                0.35481733,\n                0.9845762\n            ],\n            \"id\": 740\n        }\n    },\n    {\n        \"score\": 1.2377806,\n        \"fields\": {\n            \"vector\": [\n                0.7411156,\n                0.08687937,\n                0.8254139,\n                0.08370924,\n                0.99095553\n            ],\n            \"id\": 640\n        }\n    },\n    {\n        \"score\": 1.1869997,\n        \"fields\": {\n            \"vector\": [\n                0.87928146,\n                0.05324632,\n                0.6312755,\n                0.28005534,\n                0.9542448\n            ],\n            \"id\": 455\n        }\n    }\n]]}\n","[\n  { score: 1.7463608980178833, id: '854' },\n  { score: 1.744946002960205, id: '425' },\n  { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    data=[\n        [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n        [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n    ], # Replace with your query vectors\n    limit=2, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n    Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n    Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .topK(2)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n    [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n    [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: query_vectors,\n    limit: 2,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 1,\n            \"distance\": 1.3017789125442505,\n            \"entity\": {}\n        },\n        {\n            \"id\": 7,\n            \"distance\": 1.2419954538345337,\n            \"entity\": {}\n        }\n    ], # Result set 1\n    [\n        {\n            \"id\": 3,\n            \"distance\": 2.3358664512634277,\n            \"entity\": {}\n        },\n        {\n            \"id\": 8,\n            \"distance\": 0.5642921924591064,\n            \"entity\": {}\n        }\n    ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {\n                \"vector\": [\n                    0.9533119,\n                    0.02538395,\n                    0.76714665,\n                    0.35481733,\n                    0.9845762\n                ],\n                \"id\": 740\n            }\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {\n                \"vector\": [\n                    0.7411156,\n                    0.08687937,\n                    0.8254139,\n                    0.08370924,\n                    0.99095553\n                ],\n                \"id\": 640\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8654699,\n            \"fields\": {\n                \"vector\": [\n                    0.4671427,\n                    0.8378432,\n                    0.98844475,\n                    0.82763994,\n                    0.9729997\n                ],\n                \"id\": 638\n            }\n        },\n        {\n            \"score\": 1.8581753,\n            \"fields\": {\n                \"vector\": [\n                    0.735541,\n                    0.60140246,\n                    0.86730254,\n                    0.93152493,\n                    0.98603314\n                ],\n                \"id\": 855\n            }\n        }\n    ]\n]}\n","[\n  [\n    { score: 2.3590476512908936, id: '854' },\n    { score: 2.2896690368652344, id: '59' }\n  [\n    { score: 2.664059638977051, id: '59' },\n    { score: 2.59483003616333, id: '854' }\n  ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n    collection_name=\"quick_setup\",\n    data=[query_vector],\n    limit=5,\n    search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n    partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .partitionNames(Arrays.asList(\"red\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    partition_names: [\"red\"],\n    limit: 5,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 16,\n            \"distance\": 0.9200337529182434,\n            \"entity\": {}\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.4505271911621094,\n            \"entity\": {}\n        },\n        {\n            \"id\": 15,\n            \"distance\": 0.19924677908420563,\n            \"entity\": {}\n        },\n        {\n            \"id\": 17,\n            \"distance\": 0.0075093843042850494,\n            \"entity\": {}\n        },\n        {\n            \"id\": 13,\n            \"distance\": -0.14609718322753906,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1677284,\n            \"fields\": {\n                \"vector\": [\n                    0.9986977,\n                    0.17964739,\n                    0.49086612,\n                    0.23155272,\n                    0.98438674\n                ],\n                \"id\": 1435\n            }\n        },\n        {\n            \"score\": 1.1476475,\n            \"fields\": {\n                \"vector\": [\n                    0.6952647,\n                    0.13417172,\n                    0.91045254,\n                    0.119336545,\n                    0.9338931\n                ],\n                \"id\": 1291\n            }\n        },\n        {\n            \"score\": 1.0969629,\n            \"fields\": {\n                \"vector\": [\n                    0.3363194,\n                    0.028906643,\n                    0.6675426,\n                    0.030419827,\n                    0.9735209\n                ],\n                \"id\": 1168\n            }\n        },\n        {\n            \"score\": 1.0741848,\n            \"fields\": {\n                \"vector\": [\n                    0.9980543,\n                    0.36063594,\n                    0.66427994,\n                    0.17359233,\n                    0.94954175\n                ],\n                \"id\": 1164\n            }\n        },\n        {\n            \"score\": 1.0584627,\n            \"fields\": {\n                \"vector\": [\n                    0.7187005,\n                    0.12674773,\n                    0.987718,\n                    0.3110777,\n                    0.86093885\n                ],\n                \"id\": 1085\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8030131,\n            \"fields\": {\n                \"vector\": [\n                    0.59726167,\n                    0.7054632,\n                    0.9573117,\n                    0.94529945,\n                    0.8664103\n                ],\n                \"id\": 1203\n            }\n        },\n        {\n            \"score\": 1.7728865,\n            \"fields\": {\n                \"vector\": [\n                    0.6672442,\n                    0.60448086,\n                    0.9325822,\n                    0.80272985,\n                    0.8861626\n                ],\n                \"id\": 1448\n            }\n        },\n        {\n            \"score\": 1.7536311,\n            \"fields\": {\n                \"vector\": [\n                    0.59663296,\n                    0.77831805,\n                    0.8578314,\n                    0.88818026,\n                    0.9030075\n                ],\n                \"id\": 1010\n            }\n        },\n        {\n            \"score\": 1.7520742,\n            \"fields\": {\n                \"vector\": [\n                    0.854198,\n                    0.72294194,\n                    0.9245805,\n                    0.86126596,\n                    0.7969224\n                ],\n                \"id\": 1219\n            }\n        },\n        {\n            \"score\": 1.7452049,\n            \"fields\": {\n                \"vector\": [\n                    0.96419,\n                    0.943535,\n                    0.87611496,\n                    0.8268136,\n                    0.79786557\n                ],\n                \"id\": 1149\n            }\n        }\n    ]\n]}\n","[\n  { score: 3.0258803367614746, id: '1201' },\n  { score: 3.004319190979004, id: '1458' },\n  { score: 2.880324363708496, id: '1187' },\n  { score: 2.8246407508850098, id: '1347' },\n  { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n    collection_name=\"quick_setup\",\n    data=[query_vector],\n    limit=5,\n    search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n    partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .partitionNames(Arrays.asList(\"blue\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    partition_names: [\"blue\"],\n    limit: 5,\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 20,\n            \"distance\": 2.363696813583374,\n            \"entity\": {}\n        },\n        {\n            \"id\": 26,\n            \"distance\": 1.0665391683578491,\n            \"entity\": {}\n        },\n        {\n            \"id\": 23,\n            \"distance\": 1.066049575805664,\n            \"entity\": {}\n        },\n        {\n            \"id\": 29,\n            \"distance\": 0.8353596925735474,\n            \"entity\": {}\n        },\n        {\n            \"id\": 28,\n            \"distance\": 0.7484277486801147,\n            \"entity\": {}\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1628494,\n            \"fields\": {\n                \"vector\": [\n                    0.7442872,\n                    0.046407282,\n                    0.71031404,\n                    0.3544345,\n                    0.9819991\n                ],\n                \"id\": 1992\n            }\n        },\n        {\n            \"score\": 1.1470042,\n            \"fields\": {\n                \"vector\": [\n                    0.5505825,\n                    0.04367262,\n                    0.9985836,\n                    0.18922359,\n                    0.93255126\n                ],\n                \"id\": 1977\n            }\n        },\n        {\n            \"score\": 1.1450152,\n            \"fields\": {\n                \"vector\": [\n                    0.89994013,\n                    0.052991092,\n                    0.8645576,\n                    0.6406729,\n                    0.95679337\n                ],\n                \"id\": 1573\n            }\n        },\n        {\n            \"score\": 1.1439825,\n            \"fields\": {\n                \"vector\": [\n                    0.9253267,\n                    0.15890503,\n                    0.7999555,\n                    0.19126713,\n                    0.898583\n                ],\n                \"id\": 1552\n            }\n        },\n        {\n            \"score\": 1.1029172,\n            \"fields\": {\n                \"vector\": [\n                    0.95661926,\n                    0.18777144,\n                    0.38115507,\n                    0.14323527,\n                    0.93137646\n                ],\n                \"id\": 1823\n            }\n        }\n    ],\n    [\n        {\n            \"score\": 1.8005109,\n            \"fields\": {\n                \"vector\": [\n                    0.5953582,\n                    0.7794224,\n                    0.9388869,\n                    0.79825854,\n                    0.9197286\n                ],\n                \"id\": 1888\n            }\n        },\n        {\n            \"score\": 1.7714822,\n            \"fields\": {\n                \"vector\": [\n                    0.56805456,\n                    0.89422905,\n                    0.88187534,\n                    0.914824,\n                    0.8944365\n                ],\n                \"id\": 1648\n            }\n        },\n        {\n            \"score\": 1.7561421,\n            \"fields\": {\n                \"vector\": [\n                    0.83421993,\n                    0.39865613,\n                    0.92319834,\n                    0.42695504,\n                    0.96633124\n                ],\n                \"id\": 1688\n            }\n        },\n        {\n            \"score\": 1.7553532,\n            \"fields\": {\n                \"vector\": [\n                    0.89994013,\n                    0.052991092,\n                    0.8645576,\n                    0.6406729,\n                    0.95679337\n                ],\n                \"id\": 1573\n            }\n        },\n        {\n            \"score\": 1.7543385,\n            \"fields\": {\n                \"vector\": [\n                    0.16542226,\n                    0.38248396,\n                    0.9888778,\n                    0.80913955,\n                    0.9501492\n                ],\n                \"id\": 1544\n            }\n        }\n    ]\n]}\n","[\n  { score: 2.8421106338500977, id: '1745' },\n  { score: 2.838560104370117, id: '1782' },\n  { score: 2.8134000301361084, id: '1511' },\n  { score: 2.718268871307373, id: '1679' },\n  { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color\"))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 0,\n            \"distance\": 1.4093276262283325,\n            \"entity\": {\n                \"color\": \"pink_8682\"\n            }\n        },\n        {\n            \"id\": 16,\n            \"distance\": 1.0159327983856201,\n            \"entity\": {\n                \"color\": \"yellow_1496\"\n            }\n        },\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.9803846478462219,\n            \"entity\": {\n                \"color\": \"green_2899\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1869997,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1748955,\n            \"fields\": {}\n        },\n        {\n            \"score\": 1.1720343,\n            \"fields\": {}\n        }\n    ]\n]}\n","\n[\n  { score: 3.036271572113037, id: '59', color: 'orange' },\n  { score: 3.0267879962921143, id: '1745', color: 'blue' },\n  { score: 3.0069446563720703, id: '854', color: 'black' },\n  { score: 2.984386682510376, id: '718', color: 'black' },\n  { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n    filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .filter(\"color_tag like \\\"red%\\\"\")\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    filters: \"color_tag like \\\"red%\\\"\",\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        },\n        {\n            \"id\": 6,\n            \"distance\": -0.4113418459892273,\n            \"entity\": {\n                \"color\": \"red_9392\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"red_3026\"}\n        },\n        {\n            \"score\": 1.1677284,\n            \"fields\": {\"color_tag\": \"red_9030\"}\n        },\n        {\n            \"score\": 1.1476475,\n            \"fields\": {\"color_tag\": \"red_3744\"}\n        },\n        {\n            \"score\": 1.0969629,\n            \"fields\": {\"color_tag\": \"red_4168\"}\n        },\n        {\n            \"score\": 1.0741848,\n            \"fields\": {\"color_tag\": \"red_9678\"}\n        }\n    ]\n]}\n","[\n  { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n  { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n  { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n  { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n  { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=5, # Max. number of search results to return\n    search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n    filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .filter(\"color like \\\"%ll%\\\"\")\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    filters: \"color_tag like \\\"%ll%\\\"\",\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 5,\n            \"distance\": 0.7972343564033508,\n            \"entity\": {\n                \"color\": \"yellow_4222\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"yellow_4222\"}\n        }\n    ]\n]}\n","[\n  { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n    \"metric_type\": \"IP\",\n    \"params\": {\n        \"radius\": 0.8, # Radius of the search circle\n        \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n    }\n}\n\nres = client.search(\n    collection_name=\"quick_setup\", # Replace with the actual name of your collection\n    data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n    limit=3, # Max. number of search results to return\n    search_params=search_params, # Search parameters\n    output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n    .collectionName(\"quick_setup\")\n    .data(query_vectors)\n    .outputFields(Arrays.asList(\"color_tag\"))\n    .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n    .topK(5)\n    .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n    collection_name: \"quick_setup\",\n    data: [query_vector],\n    limit: 5,\n    params: {\n        radius: 0.1,\n        range: 1.0\n    },\n    output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n    [\n        {\n            \"id\": 4,\n            \"distance\": 0.9902134537696838,\n            \"entity\": {\n                \"color\": \"red_4794\"\n            }\n        },\n        {\n            \"id\": 14,\n            \"distance\": 0.9803846478462219,\n            \"entity\": {\n                \"color\": \"green_2899\"\n            }\n        },\n        {\n            \"id\": 1,\n            \"distance\": 0.8519943356513977,\n            \"entity\": {\n                \"color\": \"red_7025\"\n            }\n        }\n    ]\n]\n","{\"searchResults\": [\n    [\n        {\n            \"score\": 1.263043,\n            \"fields\": {\"color_tag\": \"green_2052\"}\n        },\n        {\n            \"score\": 1.2377806,\n            \"fields\": {\"color_tag\": \"purple_3709\"}\n        },\n        {\n            \"score\": 1.1869997,\n            \"fields\": {\"color_tag\": \"red_3026\"}\n        },\n        {\n            \"score\": 1.1748955,\n            \"fields\": {\"color_tag\": \"black_1646\"}\n        },\n        {\n            \"score\": 1.1720343,\n            \"fields\": {\"color_tag\": \"green_4853\"}\n        }\n    ]\n]}\n","[\n  { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n  { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n  { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n  { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n  { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n    collection_name=\"group_search\", # Collection name\n    data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n    search_params={\n    \"metric_type\": \"L2\",\n    \"params\": {\"nprobe\": 10},\n    }, # Search parameters\n    limit=5, # Max. number of groups to return\n    group_by_field=\"doc_id\", # Group results by document ID\n    group_size=2, # returned at most 2 passages per document, the default value is 1\n    group_strict_size=True, # ensure every group contains exactly 3 passages\n    output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n    collection_name=\"group_search\", # Collection name\n    data=query_passage_vector, # Replace with your query vector\n    search_params={\n    \"metric_type\": \"L2\",\n    \"params\": {\"nprobe\": 10},\n    }, # Search parameters\n    limit=5, # Max. number of search results to return\n    # group_by_field=\"doc_id\", # Group results by document ID\n    # group_size=2, \n    # group_strict_size=True,\n    output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n    'metric_type': 'L2',\n    'params': {\n        'nprobe': 10,\n        'level': 1,\n        'radius': 1.0\n        'range_filter': 0.8\n    }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Recherche à vecteur unique","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Vue d'ensemble","href":"Overview","type":2,"isActive":false},{"label":"Préparations","href":"Preparations","type":2,"isActive":false},{"label":"Recherche de base","href":"Basic-search","type":2,"isActive":false},{"label":"Recherche filtrée","href":"Filtered-search","type":2,"isActive":false},{"label":"Recherche par plage","href":"Range-search","type":2,"isActive":false},{"label":"Recherche par regroupement","href":"Grouping-search","type":2,"isActive":false},{"label":"Paramètres de recherche","href":"Search-parameters","type":2,"isActive":false}]}
      \ No newline at end of file
      diff --git a/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.md
      index e650ca410..9c574377f 100644
      --- a/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.md
      +++ b/localization/v2.4.x/site/fr/userGuide/search-query-get/single-vector-search.md
      @@ -68,10 +68,12 @@ title: Recherche à vecteur unique
           

      L'extrait de code ci-dessous reprend le code existant pour établir une connexion avec Milvus et configurer rapidement une collection.

      -
      # 1. Set up a Milvus client
      +
      from pymilvus import MilvusClient
      +import random
      +
      +# 1. Set up a Milvus client
       client = MilvusClient(
      -    uri=CLUSTER_ENDPOINT,
      -    token=TOKEN 
      +    uri="http://localhost:19530"
       )
       
       # 2. Create a collection
      @@ -441,7 +443,7 @@ res = await client.search, vous pouvez fournir une ou plusieurs valeurs vectorielles représentant vos enchâssements de requête et une valeur limit indiquant le nombre de résultats à renvoyer.

      -

      En fonction de vos données et de votre vecteur d'interrogation, il se peut que vous obteniez moins de limit résultats. Cela se produit lorsque limit est plus grand que le nombre de vecteurs correspondants possibles pour votre requête.

      +

      En fonction de vos données et de votre vecteur d'interrogation, il se peut que vous obteniez moins de limit résultats. Cela se produit lorsque limit est plus grand que le nombre de vecteurs correspondant à votre requête.

      La recherche à vecteur unique est la forme la plus simple des opérations search dans Milvus, conçue pour trouver les vecteurs les plus similaires à un vecteur d'interrogation donné.

      Pour effectuer une recherche à vecteur unique, indiquez le nom de la collection cible, le vecteur d'interrogation et le nombre de résultats souhaité (limit). Cette opération renvoie un ensemble de résultats comprenant les vecteurs les plus similaires, leurs identifiants et les distances par rapport au vecteur d'interrogation.

      Voici un exemple de recherche des 5 entités les plus similaires au vecteur d'interrogation :

      @@ -449,7 +451,7 @@ res = await client.Python Java Node.js
      # Single vector search
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           # Replace with your query vector
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
      @@ -643,7 +645,7 @@ res = await client.Python  Java Node.js
       
      # Bulk-vector search
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[
               [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
               [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
      @@ -787,7 +789,7 @@ console.log(res.results)
       ]
       

      Les résultats comprennent deux ensembles de plus proches voisins, un pour chaque vecteur d'interrogation, ce qui montre l'efficacité des recherches de vecteurs en vrac dans le traitement de plusieurs vecteurs d'interrogation à la fois.

      -

      La recherche par partition réduit l'étendue de votre recherche à un sous-ensemble ou à une partition spécifique de votre collection. Elle est particulièrement utile pour les ensembles de données organisés où les données sont segmentées en divisions logiques ou catégorielles, ce qui permet d'accélérer les opérations de recherche en réduisant le volume de données à analyser.

      +

      La recherche par partition réduit la portée de votre recherche à un sous-ensemble ou à une partition spécifique de votre collection. Elle est particulièrement utile pour les ensembles de données organisés où les données sont segmentées en divisions logiques ou catégorielles, ce qui permet d'accélérer les opérations de recherche en réduisant le volume de données à analyser.

      Pour effectuer une recherche par partition, il suffit d'inclure le nom de la partition cible dans partition_names de votre demande de recherche. Cela indique que l'opération search ne prend en compte que les vecteurs situés dans la partition spécifiée.

      Voici un exemple de recherche d'entités dans red:

      @@ -1228,7 +1230,7 @@ searchResp = client.search(searchReq); Python Java Node.js
      # Search with output fields
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1376,7 +1378,7 @@ res = await client.Python  Java Node.js
       
      # Search with filter
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1483,7 +1485,7 @@ res = await client.Python  Java Node.js
       
      # Infix match on color field
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1584,7 +1586,7 @@ search_params = {
       }
       
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=3, # Max. number of search results to return
           search_params=search_params, # Search parameters
      @@ -1718,7 +1720,7 @@ res = await client.# Connect to Milvus
      @@ -1795,7 +1797,7 @@ passage_ids = [result['entity'][

      Vecteur: Actuellement, la recherche par regroupement ne prend pas en charge les champs vectoriels de type BINARY_VECTOR. Pour plus d'informations sur les types de données, voir Types de données pris en charge.

    21. Champ: Actuellement, la recherche par regroupement n'autorise qu'une seule colonne. Vous ne pouvez pas spécifier plusieurs noms de champs dans la configuration de group_by_field. En outre, la recherche groupée est incompatible avec les types de données JSON, FLOAT, DOUBLE, ARRAY ou les champs vectoriels.

    22. Impact sur les performances: Soyez conscient que les performances se dégradent avec l'augmentation du nombre de vecteurs de requête. Si l'on prend l'exemple d'un cluster doté de 2 cœurs de CPU et de 8 Go de mémoire, le temps d'exécution de la recherche par regroupement augmente proportionnellement au nombre de vecteurs de requête en entrée.

    23. -
    24. Fonctionnalité: Actuellement, la recherche par regroupement n'est pas prise en charge par la recherche d'intervalle, les itérateurs de recherche, etc.

    25. +
    26. Fonctionnalité: Actuellement, la recherche par regroupement n'est pas prise en charge par la recherche d'intervalle, les itérateurs de recherche et la recherche en ligne.

    27. Paramètres de recherche

      L'étape de préparation suivante se connecte à Milvus et insère des entités générées de manière aléatoire dans une collection.

      Étape 1 : Création d'une collection

      -

      Utiliser MilvusClient pour se connecter au serveur Milvus et create_collection() pour créer une collection.

      +

      Utilisez MilvusClient pour se connecter au serveur Milvus et create_collection() pour créer une collection.

      Pour se connecter au serveur Milvus et créer une collection, il faut utiliser MilvusClientV2 pour se connecter au serveur Milvus et createCollection() pour créer une collection.

      @@ -248,7 +248,7 @@ System.out.println(wrapper.getInsertCount());
    -
    from pymilvus import Collection
    +
    from pymilvus import Collection,connections
     
     # 4. Search with iterator
     connections.connect(host="127.0.0.1", port=19530)
    @@ -405,7 +405,7 @@ System.out.println(results.size());
         
         
           withBatchSize
    -      Le nombre d'entités à renvoyer chaque fois que vous appelez next() sur l'itérateur actuel.
    La valeur par défaut est 1000. Définissez-la à une valeur appropriée pour contrôler le nombre d'entités à renvoyer par itération. + Nombre d'entités à renvoyer chaque fois que vous appelez next() sur l'itérateur actuel.
    La valeur par défaut est 1000. Définissez-la à une valeur appropriée pour contrôler le nombre d'entités à renvoyer par itération. withParams diff --git a/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.json index fd91ac529..21242b37b 100644 --- a/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Aggiornamento del cluster Milvus con i grafici Helm","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Controllare i grafici di Milvus Helm","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Eseguire un aggiornamento continuo","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Aggiornare Milvus con Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrazione dei metadati","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"Aggiornamento del cluster Milvus con i grafici Helm","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Controllare i grafici di Milvus Helm","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Eseguire un aggiornamento continuo","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Aggiornare Milvus con Helm","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"Migrazione dei metadati","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.md index ea12296de..d0f82484c 100644 --- a/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/it/adminGuide/upgrade_milvus_cluster-helm.md @@ -86,7 +86,7 @@ zilliztech/milvus 4.1.1 2.3.0 Milvus is an ope zilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...

    È possibile scegliere il percorso di aggiornamento per il proprio Milvus come segue:

    -
    - Eseguire un aggiornamento continuo](#conduct-a-rolling-upgrade) da Milvus v2.2.3 e versioni successive alla v2.4.15.
    +
    - Eseguire un aggiornamento continuo](#conduct-a-rolling-upgrade) da Milvus v2.2.3 e versioni successive a v2.4.15.
    • Aggiornare Milvus utilizzando Helm per un aggiornamento da una release minore precedente alla v2.2.3 alla v2.4.15.

    • Migrare i metadati prima dell'aggiornamento da Milvus v2.1.x a v2.4.15.

    • @@ -123,7 +123,7 @@ zilliztech/milvus 4.1.0 2.3.0 Milvus is an ope oOperazioneupdateFalso -

      Dopo essersi assicurati che tutte le installazioni nella vostra istanza Milvus siano nello stato normale. È possibile eseguire il seguente comando per aggiornare l'istanza Milvus a 2.4.15.

      +

      Dopo essersi assicurati che tutte le installazioni nella vostra istanza Milvus siano nello stato normale. È possibile eseguire il comando seguente per aggiornare l'istanza Milvus alla versione 2.4.15.

      sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'
       
      @@ -203,7 +203,7 @@ my-release-pulsar-zookeeper-0 my-release-pulsar-zookeeper-1 1/1 Running 0 20m my-release-pulsar-zookeeper-2 1/1 Running 0 20m
    -

    3. Controllare il tag immagine

    Controllare il tag image per il pod my-release-milvus-proxy-6c548f787f-scspp. Si può vedere che la release del cluster Milvus è la v2.1.4.

    +

    3. Controllare il tag immagine

    Controllare il tag image per il pod my-release-milvus-proxy-6c548f787f-scspp. Si può vedere che la release del cluster Milvus è v2.1.4.

    $ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'
     # milvusdb/milvus:v2.1.4
     
    @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
  • Migrare i metadati di Milvus.
  • Avviare i componenti Milvus con una nuova immagine.
  • -

    2. Aggiornare Milvus dalla v2.1.x alla 2.4.15

    I comandi seguenti presuppongono l'aggiornamento di Milvus dalla v2.1.4 alla 2.4.15. Modificateli in base alle vostre esigenze.

    +

    2. Aggiornamento di Milvus da v2.1.x a 2.2.0

    I comandi che seguono presuppongono l'aggiornamento di Milvus dalla v2.1.4 alla 2.2.0. Modificateli in base alle vostre esigenze.

    1. Specificare il nome dell'istanza Milvus, la versione Milvus di origine e la versione Milvus di destinazione.

      -
      ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
      +
      ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
       
    2. Specificate lo spazio dei nomi con -n se Milvus non è installato nello spazio dei nomi predefinito di K8s.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
       
    3. Specificare il percorso della radice con -r se Milvus è installato con il percorso personalizzato rootpath.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
       
    4. -
    5. Specificate il tag dell'immagine con -w se Milvus è installato con il tag personalizzato image.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
      +
    6. Specificate il tag dell'immagine con -w se il vostro Milvus è installato con un image personalizzato.

      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
       
    7. Impostare -d true se si desidera rimuovere automaticamente il pod di migrazione al termine della migrazione.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
       
    8. Se la migrazione non va a buon fine, si può tornare indietro e migrare di nuovo.

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
      -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
      +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
       
    diff --git a/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.json index d3709d224..1b7706ce0 100644 --- a/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"Avviare Milvus in Kubernetes con Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Prerequisiti","href":"Prerequisites","type":2,"isActive":false},{"label":"Installare Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Installazione online","href":"Online-install","type":2,"isActive":false},{"label":"Installazione offline","href":"Offline-install","type":2,"isActive":false},{"label":"Aggiornamento del cluster Milvus in esecuzione","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Disinstallare Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Cosa succede dopo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"Eseguire Milvus in Kubernetes con Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Prerequisiti","href":"Prerequisites","type":2,"isActive":false},{"label":"Installare Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Installazione online","href":"Online-install","type":2,"isActive":false},{"label":"Installazione offline","href":"Offline-install","type":2,"isActive":false},{"label":"Aggiornamento del cluster Milvus in esecuzione","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Disinstallare Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"Cosa succede dopo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.md index a94fbb74b..f92618c86 100644 --- a/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/it/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -5,7 +5,7 @@ related_key: Kubernetes summary: Scoprite come installare il cluster Milvus su Kubernetes. title: Installare il cluster Milvus con Helm --- -

    Avviare Milvus in Kubernetes con Helm

    Prima di installare Milvus Helm Charts, è necessario aggiungere il repository Milvus Helm.

    -
    $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
    +
    $ helm repo add milvus https://github.com/zilliztech/milvus-helm
     
    -

    Il repository di Milvus Helm Charts all'indirizzo https://milvus-io.github.io/milvus-helm/ è stato archiviato ed è possibile ottenere ulteriori aggiornamenti da https://zilliztech.github.io/milvus-helm/ come segue:

    -
    helm repo add zilliztech https://zilliztech.github.io/milvus-helm
    +

    Il repository di Milvus Helm Charts all'indirizzo https://github.com/milvus-io/milvus-helm è stato archiviato ed è possibile ottenere ulteriori aggiornamenti da https://github.com/zilliztech/milvus-helm come segue:

    +
    helm repo add zilliztech https://github.com/zilliztech/milvus-helm
     helm repo update
     # upgrade existing helm release
     helm upgrade my-release zilliztech/milvus
     
    -

    Il repo archiviato è ancora disponibile per i grafici fino alla versione 4.0.31. Per le versioni successive, utilizzare invece il nuovo repo.

    +

    Il repository archiviato è ancora disponibile per i grafici fino alla versione 4.0.31. Per le versioni successive, utilizzare invece il nuovo repo.

    Quindi prelevare i grafici di Milvus dal repository come segue:

    $ helm repo update
    @@ -164,7 +164,7 @@ my-release-pulsar-zookeeper-metadata-98zbr       0/1   Completed  0        3m24s
     
    $ kubectl port-forward service/my-release-milvus 27017:19530
     Forwarding from 127.0.0.1:27017 -> 19530
     
    -

    Facoltativamente, si può usare :19530 invece di 27017:19530 nel comando precedente per lasciare che kubectl assegni una porta locale al posto dell'utente, in modo da non dover gestire conflitti di porte.

    +

    Facoltativamente, si può usare :19530 invece di 27017:19530 nel comando precedente per lasciare che kubectl assegni una porta locale al posto nostro, in modo da non dover gestire conflitti di porte.

    Per impostazione predefinita, il port-forwarding di kubectl ascolta solo su localhost. Usate il flag address se volete che Milvus ascolti su uno o tutti gli indirizzi IP selezionati. Il comando seguente fa sì che il port-forward ascolti tutti gli indirizzi IP della macchina host.

    $ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530
     Forwarding from 0.0.0.0:27017 -> 19530
    @@ -191,7 +191,7 @@ my-release-pulsar-zookeeper-metadata-98zbr       0/1   Completed  0        3m24s
     

    Il comando precedente esegue il rendering dei modelli di grafico per un cluster Milvus e salva l'output in un file di manifest chiamato milvus_manifest.yaml. Utilizzando questo manifest, è possibile installare un cluster Milvus con i suoi componenti e le sue dipendenze in pod separati.

      -
    • Per installare un'istanza di Milvus in modalità standalone, dove tutti i componenti di Milvus sono contenuti in un singolo pod, si deve invece eseguire helm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml per renderizzare i modelli di grafico per un'istanza di Milvus in modalità standalone.
    • +
    • Per installare un'istanza di Milvus in modalità standalone, dove tutti i componenti di Milvus sono contenuti in un singolo pod, si deve invece eseguire helm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml per eseguire il rendering dei modelli di grafico per un'istanza di Milvus in modalità standalone.
    • Per modificare le configurazioni di Milvus, scaricare il modello value.yaml scaricare il modello, inserirvi le impostazioni desiderate e utilizzare helm template -f values.yaml my-release milvus/milvus > milvus_manifest.yaml per eseguire il rendering del manifest di conseguenza.
    diff --git a/localization/v2.4.x/site/it/integrations/integrations_overview.md b/localization/v2.4.x/site/it/integrations/integrations_overview.md index 81af35765..d67e8f16c 100644 --- a/localization/v2.4.x/site/it/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/it/integrations/integrations_overview.md @@ -67,5 +67,9 @@ title: Panoramica delle integrazioni Costruire una RAG con Milvus e fonti di dati non strutturatiFonti di dati non strutturatiMilvus, non strutturato Costruire un RAG con Milvus + PII MaskerFonti di datiMilvus, PII Masker Utilizzare Milvus in PrivateGPTOchestrazionericerca vettoriale +Come iniziare con Mem0 e MilvusAgentiMem0, Milvus +Tabella della conoscenza con MilvusIngegneria della conoscenzaTabella della conoscenza, Milvus +Utilizzare Milvus in DocsGPTOchestrazioneDocsGPT, Milvus +Utilizzare Milvus con SambaNovaOrchestrazioneMilvus, SambaNova diff --git a/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..8b8f37967 --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Knowledge Table con Milvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"Prerequisiti","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonare il progetto","href":"Cloning-the-project","type":2,"isActive":false},{"label":"Configurare l'ambiente","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"Avvio dell'applicazione","href":"Starting-the-app","type":2,"isActive":false},{"label":"Arresto dell'applicazione","href":"Stopping-the-app","type":2,"isActive":false},{"label":"Accesso al progetto","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..8002d49ff --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,146 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + Per impostazione predefinita, Knowledge Table utilizza il database Milvus per + memorizzare e recuperare i dati estratti. Questo permette agli utenti di + cercare, filtrare e analizzare facilmente i dati utilizzando le potenti + funzioni di Milvus. In questa esercitazione mostreremo come iniziare a + utilizzare Knowledge Table e Milvus. +title: Knowledge Table con Milvus +--- +

    Knowledge Table con Milvus

    Knowledge Table, sviluppato da WhyHow AI, è un pacchetto open-source progettato per facilitare l'estrazione e l'esplorazione di dati strutturati da documenti non strutturati. Fornisce agli utenti un'interfaccia simile a un foglio di calcolo e consente di creare rappresentazioni della conoscenza, come tabelle e grafici, attraverso un'interfaccia di interrogazione in linguaggio naturale. Il pacchetto include regole di estrazione personalizzabili, opzioni di formattazione e tracciabilità dei dati attraverso la provenienza, rendendolo adattabile a diverse applicazioni. Supporta la perfetta integrazione nei flussi di lavoro RAG, soddisfacendo sia gli utenti aziendali che necessitano di un'interfaccia facile da usare, sia gli sviluppatori che necessitano di un backend flessibile per l'elaborazione efficiente dei documenti.

    +

    Per impostazione predefinita, Knowledge Table utilizza il database Milvus per memorizzare e recuperare i dati estratti. Questo permette agli utenti di cercare, filtrare e analizzare facilmente i dati utilizzando le potenti funzioni di Milvus. In questa esercitazione verrà mostrato come iniziare a lavorare con Knowledge Table e Milvus.

    +

    Prerequisiti

      +
    • Docker
    • +
    • Docker Compose
    • +
    +

    Clonare il progetto

    $ git clone https://github.com/whyhow-ai/knowledge-table.git
    +
    +

    Configurare l'ambiente

    Il file .env.example si trova nella cartella principale del progetto. Copiare questo file in .env e inserire le variabili d'ambiente necessarie.

    +

    Per Milvus, occorre impostare le variabili d'ambiente MILVUS_DB_URI e MILVUS_DB_TOKEN. Ecco alcuni suggerimenti:

    +
    +
      +
    • L'impostazione di MILVUS_DB_URI come file locale, ad esempio./milvus.db, è il metodo più conveniente, poiché utilizza automaticamente Milvus Lite per memorizzare tutti i dati in questo file.
    • +
    • Se si dispone di una grande quantità di dati, ad esempio più di un milione di vettori, è possibile impostare un server Milvus più performante su Docker o Kubernetes. In questa configurazione, utilizzare l'indirizzo e la porta del server come uri, ad esempiohttp://localhost:19530. Se si abilita la funzione di autenticazione su Milvus, utilizzare "<nome_utente>:<password>" come token, altrimenti non impostare il token.
    • +
    • Se si desidera utilizzare Zilliz Cloud, il servizio cloud completamente gestito per Milvus, regolare MILVUS_DB_URI e MILVUS_DB_TOKEN, che corrispondono all'endpoint pubblico e alla chiave Api di Zilliz Cloud.
    • +
    +
    +

    Oltre a Milvus, è necessario impostare anche altri ambienti, ad esempio OPENAI_API_KEY. Ognuno di questi ambienti può essere ottenuto dai rispettivi siti web.

    +

    Avvio dell'applicazione

    $ docker-compose up -d --build
    +
    +

    Arresto dell'applicazione

    $ docker-compose down
    +
    +

    Accesso al progetto

    Il frontend è accessibile all'indirizzo http://localhost:3000, mentre il backend è accessibile all'indirizzo http://localhost:8000.

    +

    + + + + +

    +

    È possibile giocare con l'interfaccia utente e provare con i propri documenti.

    +

    Per ulteriori dimostrazioni, è possibile consultare la documentazione ufficiale di Knowledge Table.

    diff --git a/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..a6ec850dc --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Come iniziare con Mem0 e Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Preparazione","href":"Preparation","type":2,"isActive":false},{"label":"Gestione delle memorie utente con Mem0 e Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..7fe5c8571 --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,218 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + In questo tutorial, tratteremo le operazioni essenziali di gestione della + memoria di Mem0 - aggiungere, recuperare, aggiornare, cercare, cancellare e + tracciare la storia della memoria - utilizzando Milvus, un database vettoriale + open source ad alte prestazioni che consente di memorizzare e recuperare in + modo efficiente. Questa introduzione pratica vi guiderà attraverso le + operazioni di memoria fondamentali per aiutarvi a costruire interazioni AI + personalizzate con Mem0 e Milvus. +title: Come iniziare con Mem0 e Milvus +--- +

    Come iniziare con Mem0 e Milvus

    +Open In Colab + + +GitHub Repository +

    +

    Mem0 è un livello di memoria intelligente per applicazioni di intelligenza artificiale, progettato per offrire interazioni personalizzate ed efficienti conservando le preferenze dell'utente e adattandosi continuamente nel tempo. Ideale per i chatbot e gli strumenti basati sull'intelligenza artificiale, Mem0 crea esperienze senza soluzione di continuità e consapevoli del contesto.

    +

    In questo tutorial, verranno illustrate le operazioni essenziali di gestione della memoria di Mem0: aggiunta, recupero, aggiornamento, ricerca, cancellazione e tracciamento della cronologia della memoria, utilizzando Milvus, un database vettoriale open source ad alte prestazioni che consente una memorizzazione e un recupero efficienti. Questa introduzione pratica vi guiderà attraverso le operazioni di memoria fondamentali per aiutarvi a costruire interazioni AI personalizzate con Mem0 e Milvus.

    +

    Preparazione

    Scaricare le librerie necessarie

    $ pip install mem0ai pymilvus
    +
    +
    +

    Se si utilizza Google Colab, per abilitare le dipendenze appena installate potrebbe essere necessario riavviare il runtime (fare clic sul menu "Runtime" nella parte superiore dello schermo e selezionare "Restart session" dal menu a discesa).

    +
    +

    Configurare Mem0 con Milvus

    In questo esempio utilizzeremo OpenAI come LLM. È necessario preparare la chiave api OPENAI_API_KEY come variabile d'ambiente.

    +
    import os
    +
    +os.environ["OPENAI_API_KEY"] = "sk-***********"
    +
    +

    Ora possiamo configurare Mem0 per utilizzare Milvus come archivio vettoriale.

    +
    # Define Config
    +from mem0 import Memory
    +
    +config = {
    +    "vector_store": {
    +        "provider": "milvus",
    +        "config": {
    +            "collection_name": "quickstart_mem0_with_milvus",
    +            "embedding_model_dims": "1536",
    +            "url": "./milvus.db",  # Use local vector database for demo purpose
    +        },
    +    },
    +    "version": "v1.1",
    +}
    +
    +m = Memory.from_config(config)
    +
    +
    +
    +
      +
    • Se si ha bisogno di un database vettoriale locale solo per dati su piccola scala o per la prototipazione, impostare l'uri come un file locale, ad esempio./milvus.db, è il metodo più conveniente, poiché utilizza automaticamente Milvus Lite per memorizzare tutti i dati in questo file.
    • +
    • Se si dispone di una grande quantità di dati, ad esempio più di un milione di vettori, è possibile configurare un server Milvus più performante su Docker o Kubernetes. In questa configurazione, utilizzare l'indirizzo e la porta del server come uri, ad esempiohttp://localhost:19530. Se si attiva la funzione di autenticazione su Milvus, utilizzare "<nome_utente>:<password>" come token, altrimenti non impostare il token.
    • +
    • Se si utilizza Zilliz Cloud, il servizio cloud completamente gestito per Milvus, regolare uri e token, che corrispondono all'endpoint pubblico e alla chiave API di Zilliz Cloud.
    • +
    +
    +
    +

    Gestione delle memorie utente con Mem0 e Milvus

    Aggiunta di una memoria

    La funzione add memorizza un testo non strutturato in Milvus come memoria, associandolo a un utente specifico e a metadati opzionali.

    +

    In questo caso, stiamo aggiungendo a Milvus la memoria di Alice, "sto lavorando per migliorare le mie capacità tennistiche", insieme ai metadati rilevanti per il contesto.

    +
    # Add a memory to user: Working on improving tennis skills
    +res = m.add(
    +    messages="I am working on improving my tennis skills.",
    +    user_id="alice",
    +    metadata={"category": "hobbies"},
    +)
    +
    +res
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Working on improving tennis skills',
    +   'event': 'ADD'}],
    + 'relations': []}
    +
    +

    Aggiornare una memoria

    Possiamo usare il valore di ritorno della funzione add per recuperare l'ID della memoria, in modo da aggiornare questa memoria con nuove informazioni tramite update.

    +
    # Get memory_id
    +memory_id = res["results"][0]["id"]
    +
    +# Update this memory with new information: Likes to play tennis on weekends
    +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
    +
    +
    {'message': 'Memory updated successfully!'}
    +
    +

    Ottenere tutte le memorie di un utente

    È possibile utilizzare la funzione get_all per visualizzare tutte le memorie inserite o per filtrare user_id in Milvus.

    +

    Si noti che la memoria è cambiata da "Lavora per migliorare le sue capacità tennistiche" a "Ama giocare a tennis nei fine settimana".

    +
    # Get all memory for the user Alice
    +m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'}]}
    +
    +

    Visualizzazione della cronologia degli aggiornamenti della memoria

    È possibile visualizzare la cronologia degli aggiornamenti della memoria specificando l'ID memoria che ci interessa tramite la funzione history.

    +
    m.history(memory_id=memory_id)
    +
    +
    [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': None,
    +  'new_memory': 'Working on improving tennis skills',
    +  'event': 'ADD',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': None},
    + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': 'Working on improving tennis skills',
    +  'new_memory': 'Likes to play tennis on weekends',
    +  'event': 'UPDATE',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
    +
    +

    Ricerca nella memoria

    Possiamo usare la funzione search per cercare la memoria più correlata all'utente.

    +

    Cominciamo aggiungendo un'altra memoria per Alice.

    +
    new_mem = m.add(
    +    "I have a linear algebra midterm exam on November 20",
    +    user_id="alice",
    +    metadata={"category": "task"},
    +)
    +
    +

    Ora chiamiamo get_all specificando l'ID utente per verificare che ci siano effettivamente 2 voci di memoria per l'utente Alice.

    +
    m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Ora possiamo eseguire search fornendo query e user_id. Si noti che per impostazione predefinita si utilizza la metrica L2 per la ricerca della somiglianza, quindi una score più piccola significa una maggiore somiglianza.

    +
    m.search(query="What are Alice's hobbies", user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'score': 1.2807445526123047,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'score': 1.728922724723816,
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    Cancellare la memoria

    Possiamo anche delete una memoria fornendo il corrispondente memory_id.

    +

    Cancelleremo la memoria "Likes to play tennis on weekends", poiché il suo memory_id è già stato recuperato, e chiameremo get_all per verificare che la cancellazione sia avvenuta con successo.

    +
    m.delete(memory_id=memory_id)
    +
    +m.get_all("alice")
    +
    +
    {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    diff --git a/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..76ba1a792 --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Utilizzare Milvus in DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Requisiti","href":"Requirements","type":2,"isActive":false},{"label":"Clonare il repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Aggiungi dipendenza","href":"Add-dependency","type":2,"isActive":false},{"label":"Impostare le variabili d'ambiente","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Avviare i servizi","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..7a83bf9fe --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,142 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + In questo tutorial vi mostreremo come utilizzare Milvus come database + vettoriale di backend per DocsGPT. +title: Utilizzare Milvus in DocsGPT +--- +

    Utilizzare Milvus in DocsGPT

    DocsGPT è una soluzione open-source avanzata che semplifica la ricerca di informazioni nella documentazione di progetto integrando potenti modelli GPT. Consente agli sviluppatori di ottenere facilmente risposte precise alle loro domande su un progetto, eliminando le lunghe ricerche manuali.

    +

    In questo tutorial vi mostreremo come utilizzare Milvus come database vettoriale di backend per DocsGPT.

    +
    +

    Questa guida fa principalmente riferimento alla guida ufficiale all'installazione di DocsGPT. Se vi accorgete che questo tutorial ha parti obsolete, potete seguire prioritariamente la guida ufficiale e creare un problema con noi.

    +
    +

    Requisiti

    Assicurarsi di avere installato Docker

    +

    Clonare il repository

    Clonare il repository e accedervi:

    +
    $ git clone https://github.com/arc53/DocsGPT.git
    +$ cd DocsGPT
    +
    +

    Aggiungi dipendenza

    Aggiungere la dipendenza langchain-milvus al file requirements.txt nella cartella application:

    +
    $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
    +
    +

    Impostare le variabili d'ambiente

    Aggiungere VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... alle variabili d'ambiente per entrambi i servizi backend e worker nel file docker-compose.yaml, in questo modo:

    +
      backend:
    +    build: ./application
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +
      worker:
    +    build: ./application
    +    command: celery -A application.app.celery worker -l INFO -B
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +

    Per i servizi MILVUS_URI e MILVUS_TOKEN, è possibile utilizzare il servizio Zilliz Cloud(consigliato) completamente gestito o il servizio Milvus avviato manualmente.

    +
      +
    • Per il servizio Zilliz Cloud completamente gestito: Si consiglia di utilizzare il servizio Zilliz Cloud. È possibile registrarsi per un account di prova gratuito su Zilliz Cloud. Successivamente, si otterranno MILVUS_URI e MILVUS_TOKEN, che corrispondono all'endpoint pubblico e alla chiave API.

    • +
    • Per il servizio Milvus avviato manualmente: Se si desidera configurare un servizio Milvus, è possibile seguire la documentazione ufficiale di Milvus per configurare un server Milvus, quindi ottenere MILVUS_URI e MILVUS_TOKEN dal server. MILVUS_URI e MILVUS_TOKEN devono essere rispettivamente nel formato http://<your_server_ip>:19530 e <your_username>:<your_password>.

    • +
    +

    Avviare i servizi

    Eseguire: ./setup.sh

    +

    Quindi navigare su http://localhost:5173/.

    +

    È possibile giocare con l'interfaccia utente e porre domande sui documenti.

    +

    + + alt text + testo alt

    +

    Se si desidera arrestare i servizi, eseguire:

    +
    $ docker-compose down
    +
    +

    Per ulteriori dettagli e configurazioni più avanzate, consultare la documentazione ufficiale di DocsGPT.

    diff --git a/localization/v2.4.x/site/it/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/it/integrations/use_milvus_in_private_gpt.md index 4aeda1bd4..3f0a7c563 100644 --- a/localization/v2.4.x/site/it/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/it/integrations/use_milvus_in_private_gpt.md @@ -67,13 +67,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    PrivateGPT consente di personalizzare la configurazione. È necessario specificare le impostazioni di alcuni moduli. In questa guida, utilizzeremo i seguenti moduli:

    +

    PrivateGPT consente di personalizzare la configurazione di alcuni moduli, come LLM, Embeddings, Vector Stores, UI.

    +

    In questo tutorial utilizzeremo i seguenti moduli:

    • LLM: Ollama
    • Embeddings: Ollama
    • Archivi vettoriali: Milvus
    • UI: Gradio
    +

    Eseguire il seguente comando per utilizzare la poesia per installare le dipendenze del modulo richiesto:

    $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
     

    Avviare il servizio Ollama

    -

    Installare i modelli da utilizzare; settings-ollama.yaml è configurato come utente llama3.1 8b LLM (~4GB) e nomic-embed-text Embeddings (~275MB).

    +

    Installare i modelli da utilizzare; settings-ollama.yaml è configurato per l'utente llama3.1 8b LLM (~4GB) e nomic-embed-text Embeddings (~275MB).

    Per impostazione predefinita, PrivateGPT preleva automaticamente i modelli quando necessario. Questo comportamento può essere cambiato modificando la proprietà ollama.autopull_models.

    -

    In ogni caso, se si desidera estrarre manualmente i modelli, eseguire i seguenti comandi:

    +

    In ogni caso, se si desidera prelevare manualmente i modelli, eseguire i seguenti comandi:

    $ ollama pull llama3.1
     $ ollama pull nomic-embed-text
     
    @@ -133,8 +135,8 @@ $ ollama pull nomic-embed-text Campo OpzioneDescrizione -uriL'impostazione predefinita è "local_data/private_gpt/milvus/milvus_local.db" come file locale; è anche possibile impostare un server Milvus più performante su docker o k8s, ad esempio http://localhost:19530, come uri; per utilizzare Zilliz Cloud, regolare l'uri e il token su Endpoint e Api key in Zilliz Cloud. -tokenCoppia con il server Milvus su docker o k8s o con la chiave api di Zilliz Cloud. +uriL'impostazione predefinita è "local_data/private_gpt/milvus/milvus_local.db" come file locale; è anche possibile impostare un server Milvus più performante su docker o k8s, ad esempio http://localhost:19530, come uri; per utilizzare Zilliz Cloud, adattare l'uri e il token a Public Endpoint e API key in Zilliz Cloud. +tokenCoppia con il server Milvus su docker o k8s o con la chiave API di Zilliz Cloud. nome_raccoltaIl nome della raccolta, impostato come predefinito "milvus_db". sovrascrivereSovrascrive i dati della raccolta, se già esistenti; l'impostazione predefinita è True. @@ -154,10 +156,10 @@ $ ollama pull nomic-embed-text d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    Una volta eseguite tutte le impostazioni, è possibile avviare PrivateGPT con l'interfaccia utente gradio.

    +

    Una volta effettuate tutte le impostazioni, è possibile avviare PrivateGPT con l'interfaccia utente di Gradio.

    PGPT_PROFILES=ollama make run
     
    -

    L'interfaccia utente sarà disponibile all'indirizzohttp://0.0.0.0:8001.

    +

    L'interfaccia utente sarà disponibile all'indirizzo http://0.0.0.0:8001.

    @@ -165,3 +167,4 @@ $ ollama pull nomic-embed-text

    È possibile giocare con l'interfaccia utente e porre domande sui propri documenti.

    +

    Per ulteriori dettagli, consultare la documentazione ufficiale di PrivateGPT.

    diff --git a/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..aecbb8722 --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Utilizzare Milvus con SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Prerequisiti","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonare il repository","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Cambiare il tipo di archivio vettoriale","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Installare le dipendenze","href":"Install-dependencies","type":2,"isActive":false},{"label":"Avviare l'applicazione","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..2a200f63d --- /dev/null +++ b/localization/v2.4.x/site/it/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,135 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + Questo tutorial sfrutta l'integrazione di Milvus in SambaNova AI Starter Kit + per costruire un sistema di Enterprise Knowledge Retrieval, simile a RAG + (Retrieval-Augmented Generation), per il reperimento e la risposta sulla base + dei documenti privati aziendali. +title: Utilizzare Milvus con SambaNova +--- +

    Utilizzare Milvus con SambaNova

    SambaNova è una piattaforma tecnologica AI innovativa che accelera l'implementazione di funzionalità avanzate di AI e deep learning. Progettata per l'uso aziendale, consente alle organizzazioni di sfruttare l'AI generativa per migliorare le prestazioni e l'efficienza. Fornendo soluzioni all'avanguardia come SambaNova Suite e DataScale, la piattaforma consente alle aziende di estrarre informazioni preziose dai propri dati, migliorando le operazioni e promuovendo nuove opportunità nel panorama dell'AI.

    +

    I SambaNova AI Starter Kit sono una raccolta di risorse open-source progettate per assistere sviluppatori e aziende nell'implementazione di applicazioni AI con SambaNova. Questi kit forniscono esempi pratici e guide che facilitano l'implementazione di vari casi d'uso dell'AI, rendendo più facile per gli utenti sfruttare la tecnologia avanzata di SambaNova.

    +

    Questo tutorial sfrutta l'integrazione di Milvus negli Starter Kit AI di SambaNova per costruire un sistema di Enterprise Knowledge Retrieval, simile a RAG (Retrieval-Augmented Generation), per il reperimento e la risposta sulla base dei documenti privati aziendali.

    +
    +

    Questo tutorial fa principalmente riferimento alla guida ufficiale di SambaNova AI Starter Kits. Se ritenete che questo tutorial abbia parti obsolete, potete seguire prioritariamente la guida ufficiale e creare un problema con noi.

    +
    +

    Prerequisiti

    Si consiglia di utilizzare Python >= 3.10 e < 3.12.

    +

    Visitare il SambaNova Cloud per ottenere una chiave API SambaNova.

    +

    Clonare il repository

    $ git clone https://github.com/sambanova/ai-starter-kit.git
    +$ d ai-starter-kit/enterprise_knowledge_retriever
    +
    +

    Cambiare il tipo di archivio vettoriale

    Cambiare l'archivio vettoriale impostando db_type='milvus' nelle funzioni create_vector_store() e load_vdb() in src/document_retrieval.py.

    +
    ...
    +vectorstore = self.vectordb.create_vector_store(
    +    ..., db_type='milvus'
    +)
    +...
    +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
    +
    +

    Installare le dipendenze

    Installare le dipendenze necessarie eseguendo il seguente comando:

    +
    python3 -m venv enterprise_knowledge_env
    +source enterprise_knowledge_env/bin/activate
    +pip install -r requirements.txt
    +
    +

    Avviare l'applicazione

    Utilizzare il seguente comando per avviare l'applicazione:

    +
    $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
    +
    +

    Successivamente, viene visualizzata l'interfaccia utente nel browser:http://localhost:8501/

    +

    + + + + +

    +

    Dopo aver impostato la chiave API SambaNova nell'interfaccia utente, è possibile giocare con l'interfaccia utente e porre domande sui documenti.

    +

    Per ulteriori dettagli, consultare la documentazione ufficiale di Enterprise Knowledge Retrieval of SambaNova AI Starter Kits.

    diff --git a/localization/v2.4.x/site/it/menuStructure/it.json b/localization/v2.4.x/site/it/menuStructure/it.json index 8b2cf0664..5981d2a93 100644 --- a/localization/v2.4.x/site/it/menuStructure/it.json +++ b/localization/v2.4.x/site/it/menuStructure/it.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "Utenti e ruoli", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "Replica in memoria", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "Utenti, privilegi e ruoli", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "Abilitare RBAC", "id": "rbac.md", @@ -1409,7 +1409,7 @@ "children": [] }, { - "label": "Dify", + "label": "Dificare", "id": "dify_with_milvus.md", "order": 6, "children": [] @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivatoGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Tabella delle conoscenze", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Ricerca a imbuto con matrioske embeddings", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "Per saperne di più", "id": "explore-more", diff --git a/localization/v2.4.x/site/it/reference/disk_index.md b/localization/v2.4.x/site/it/reference/disk_index.md index 5c5fc626d..99c173671 100644 --- a/localization/v2.4.x/site/it/reference/disk_index.md +++ b/localization/v2.4.x/site/it/reference/disk_index.md @@ -45,7 +45,7 @@ Attualmente, un campo vettoriale supporta solo un tipo di indice. Milvus cancell
  • Per abilitarla di nuovo, si può impostare queryNode.enableDisk su true.
  • L'istanza di Milvus funziona su Ubuntu 18.04.6 o su una versione successiva.
  • -
  • Il percorso dei dati di Milvus deve essere montato su un'unità SSD NVMe per ottenere prestazioni ottimali:
      +
    • Il percorso dati di Milvus deve essere montato su un'unità SSD NVMe per ottenere prestazioni ottimali:
      • Per un'istanza Milvus Standalone, il percorso dei dati deve essere /var/lib/milvus/data nel contenitore in cui viene eseguita l'istanza.
      • Per un'istanza Milvus Cluster, il percorso dei dati dovrebbe essere /var/lib/milvus/data nei container in cui girano i QueryNode e gli IndexNode.
    • @@ -131,7 +131,7 @@ DiskIndex: MaxDegreeGrado massimo del grafo Vamana.
      Un valore maggiore offre un tasso di richiamo più elevato, ma aumenta le dimensioni e il tempo di costruzione dell'indice.[1, 512]56 SearchListSizeDimensione dell'elenco dei candidati.
      Un valore maggiore aumenta il tempo impiegato per costruire l'indice, ma offre un tasso di richiamo più elevato.
      Impostare un valore inferiore a MaxDegree a meno che non sia necessario ridurre il tempo di costruzione dell'indice.[1, int32_max]100 -PQCodeBugetGBRatioLimite di dimensione del codice PQ.
      Un valore maggiore offre un tasso di richiamo più alto, ma aumenta l'uso della memoria.(0.0, 0.25]0.125 +PQCodeBugetGBRatioLimite di dimensione del codice PQ.
      Un valore maggiore offre un tasso di richiamo più elevato, ma aumenta l'utilizzo della memoria.(0.0, 0.25]0.125 SearchCacheBudgetGBRatioRapporto tra i numeri dei nodi in cache e i dati grezzi.
      Un valore maggiore migliora le prestazioni di costruzione dell'indice, ma aumenta l'uso della memoria.[0.0, 0.3)0.10 BeamWidthRatioRapporto tra il numero massimo di richieste IO per iterazione di ricerca e il numero di CPU.[1, max(128/numero di CPU, 16)].4.0 diff --git a/localization/v2.4.x/site/it/reference/knowhere.json b/localization/v2.4.x/site/it/reference/knowhere.json index 9df60aa57..e9911d9f9 100644 --- a/localization/v2.4.x/site/it/reference/knowhere.json +++ b/localization/v2.4.x/site/it/reference/knowhere.json @@ -1 +1 @@ -{"codeList":[],"headingContent":"","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Knowhere nell'architettura Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Vantaggi di Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Struttura del codice di Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Aggiungere indici a Knowhere","href":"Adding-indexes-to-Knowhere","type":2,"isActive":false},{"label":"Il prossimo passo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":[],"headingContent":"Knowhere","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Knowhere nell'architettura Milvus","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Vantaggi di Knowhere","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Struttura del codice di Knowhere","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Aggiungere indici a Knowhere","href":"Adding-indices-to-Knowhere","type":2,"isActive":false},{"label":"Il prossimo passo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/reference/knowhere.md b/localization/v2.4.x/site/it/reference/knowhere.md index e66bee0b6..475ee4383 100644 --- a/localization/v2.4.x/site/it/reference/knowhere.md +++ b/localization/v2.4.x/site/it/reference/knowhere.md @@ -1,7 +1,7 @@ --- id: knowhere.md summary: Scoprite Knowhere a Milvus. -title: Da nessuna parte +title: Knowhere ---

      Knowhere

      Knowhere è il motore di esecuzione vettoriale principale di Milvus che incorpora diverse librerie di ricerca di similarità vettoriale, tra cui Faiss, Hnswlib e Annoy. Knowhere è anche progettato per supportare l'elaborazione eterogenea. Controlla su quale hardware (CPU o GPU) eseguire le richieste di creazione di indici e di ricerca. È così che Knowhere prende il suo nome: sa dove eseguire le operazioni. Nelle versioni future saranno supportati altri tipi di hardware, tra cui DPU e TPU.

      +

      Knowhere è il motore di esecuzione vettoriale principale di Milvus, che incorpora diverse librerie di ricerca di similarità vettoriale, tra cui Faiss, Hnswlib e Annoy. Knowhere è anche progettato per supportare l'elaborazione eterogenea. Controlla su quale hardware (CPU o GPU) eseguire le richieste di creazione di indici e di ricerca. È così che Knowhere prende il suo nome: sa dove eseguire le operazioni. Nelle versioni future saranno supportati altri tipi di hardware, tra cui DPU e TPU.

      Knowhere nell'architettura Milvus

    -

    Dopo aver fatto riferimento all'indice esistente, è possibile seguire la procedura seguente per aggiungere un nuovo indice a Knowhere.

    +

    Dopo aver fatto riferimento all'indice esistente, si può seguire la procedura seguente per aggiungere un nuovo indice a Knowhere.

    1. Aggiungere il nome del nuovo indice in IndexEnum. Il tipo di dati è stringa.

    2. Aggiungere il controllo di convalida dei dati sul nuovo indice nel file ConfAdapter.cpp. Il controllo di convalida serve principalmente a convalidare i parametri per la formazione dei dati e la query.

    3. Creare un nuovo file per il nuovo indice. La classe base del nuovo indice deve includere VecIndex e l'interfaccia virtuale necessaria di VecIndex.

    4. -
    5. Aggiungere la logica di costruzione del nuovo indice in VecIndexFactory::CreateVecIndex().

    6. +
    7. Aggiungere la logica di costruzione dell'indice per il nuovo indice in VecIndexFactory::CreateVecIndex().

    8. Aggiungere il test unitario nella cartella unittest.

    Il prossimo passo

  • Creare una raccolta con lo schema specificato:

    -
    from pymilvus import Collection
    +
    from pymilvus import Collection,connections
    +conn = connections.connect(host="127.0.0.1", port=19530)
     collection_name1 = "tutorial_1"
     collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
     
    @@ -240,5 +247,5 @@ collection, ins_res = Collection.construct_from_dataframe( diff --git a/localization/v2.4.x/site/it/reference/users_and_roles.json b/localization/v2.4.x/site/it/reference/users_and_roles.json index 7ad1e72f4..2f46ffa93 100644 --- a/localization/v2.4.x/site/it/reference/users_and_roles.json +++ b/localization/v2.4.x/site/it/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"Utenti e ruoli","href":"Users-and-Roles","type":1,"isActive":false},{"label":"Concetti chiave","href":"Key-concepts","type":2,"isActive":false},{"label":"Esempio: Concessione di privilegi","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utenti e ruoli predefiniti","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Elenco dei tipi di oggetto e dei privilegi","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"Cosa fare dopo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"Utenti, privilegi e ruoli","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"Concetti chiave","href":"Key-concepts","type":2,"isActive":false},{"label":"Esempio: Concessione di privilegi","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utenti e ruoli predefiniti","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Elenco dei tipi di oggetto e dei privilegi","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"Cosa fare dopo","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/reference/users_and_roles.md b/localization/v2.4.x/site/it/reference/users_and_roles.md index d56f859c5..28e2b7658 100644 --- a/localization/v2.4.x/site/it/reference/users_and_roles.md +++ b/localization/v2.4.x/site/it/reference/users_and_roles.md @@ -4,9 +4,9 @@ related_key: 'users, roles' summary: >- Conoscere la definizione di utenti, ruoli, oggetti e privilegi nel controllo degli accessi basato sui ruoli (RBAC). -title: Utenti e ruoli +title: 'Utenti, privilegi e ruoli' --- -

    Utenti e ruoli

    Quando si costruiscono sistemi di ricerca vettoriale efficienti, una sfida fondamentale è la gestione dei costi di memorizzazione, mantenendo una latenza e un richiamo accettabili. I moderni modelli di embedding producono vettori con centinaia o migliaia di dimensioni, creando un significativo overhead di archiviazione e calcolo per il vettore grezzo e l'indice.

    +

    Tradizionalmente, i requisiti di memorizzazione vengono ridotti applicando un metodo di quantizzazione o di riduzione della dimensionalità appena prima di costruire l'indice. Ad esempio, è possibile risparmiare memoria riducendo la precisione con la quantizzazione del prodotto (PQ) o il numero di dimensioni con l'analisi delle componenti principali (PCA). Questi metodi analizzano l'intero insieme di vettori per trovarne uno più compatto che mantenga le relazioni semantiche tra i vettori.

    +

    Pur essendo efficaci, questi approcci standard riducono la precisione o la dimensionalità solo una volta e su un'unica scala. Ma cosa succederebbe se potessimo mantenere più livelli di dettaglio contemporaneamente, come una piramide di rappresentazioni sempre più precise?

    +

    Ecco le Matryoshka embeddings. Questi costrutti intelligenti, che prendono il nome dalle matrioske russe (vedi illustrazione), incorporano più scale di rappresentazione all'interno di un singolo vettore. A differenza dei metodi tradizionali di post-elaborazione, le Matryoshka embeddings apprendono questa struttura multi-scala durante il processo di addestramento iniziale. Il risultato è notevole: non solo l'embedding completo cattura la semantica dell'input, ma ogni prefisso annidato del sottoinsieme (prima metà, primo quarto, ecc.) fornisce una rappresentazione coerente, anche se meno dettagliata.

    +
    +

    In questo quaderno esaminiamo come utilizzare gli embedding Matryoshka con Milvus per la ricerca semantica. Illustriamo un algoritmo chiamato "funnel search" che ci permette di eseguire ricerche di similarità su un piccolo sottoinsieme di dimensioni dell'embedding senza un drastico calo del richiamo.

    +
    import functools
    +
    +from datasets import load_dataset
    +import numpy as np
    +import pandas as pd
    +import pymilvus
    +from pymilvus import MilvusClient
    +from pymilvus import FieldSchema, CollectionSchema, DataType
    +from sentence_transformers import SentenceTransformer
    +import torch
    +import torch.nn.functional as F
    +from tqdm import tqdm
    +
    +

    Modello di incorporamento a matrioska

    Invece di utilizzare un modello di incorporamento standard, come ad esempio sentence-transformers/all-MiniLM-L12-v2utilizziamo un modello di Nomic addestrato appositamente per produrre embedding Matryoshka.

    +
    model = SentenceTransformer(
    +    # Remove 'device='mps' if running on non-Mac device
    +    "nomic-ai/nomic-embed-text-v1.5",
    +    trust_remote_code=True,
    +    device="mps",
    +)
    +
    +
    <All keys matched successfully>
    +
    +

    Caricare il set di dati, incorporare gli elementi e costruire il database di vettori

    Il codice seguente è una modifica di quello della pagina di documentazione "Movie Search with Sentence Transformers and Milvus". Per prima cosa, carichiamo il dataset da HuggingFace. Contiene circa 35.000 voci, ognuna delle quali corrisponde a un film con un articolo di Wikipedia. In questo esempio utilizzeremo i campi Title e PlotSummary.

    +
    ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
    +print(ds)
    +
    +
    Dataset({
    +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
    +    num_rows: 34886
    +})
    +
    +

    Successivamente, ci colleghiamo a un database Milvus Lite, specifichiamo lo schema dei dati e creiamo una collezione con questo schema. Memorizzeremo sia l'incorporazione non normalizzata sia il primo sesto dell'incorporazione in campi separati. Il motivo è che abbiamo bisogno del primo 1/6 dell'embedding Matryoshka per eseguire una ricerca di somiglianza, e dei restanti 5/6 dell'embedding per eseguire un reranking e migliorare i risultati della ricerca.

    +
    embedding_dim = 768
    +search_dim = 128
    +collection_name = "movie_embeddings"
    +
    +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    # First sixth of unnormalized embedding vector
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    # Entire unnormalized embedding vector
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +

    Milvus non supporta attualmente la ricerca su sottoinsiemi di incorporazioni, quindi dividiamo le incorporazioni in due parti: la testa rappresenta il sottoinsieme iniziale del vettore da indicizzare e cercare, mentre la coda è il resto. Il modello è stato addestrato per la ricerca di somiglianze a distanza coseno, quindi normalizziamo gli embeddings della testa. Tuttavia, per calcolare in seguito le somiglianze per sottoinsiemi più ampi, è necessario memorizzare la norma dell'embedding della testa, in modo da poterla normalizzare prima di unirla alla coda.

    +

    Per eseguire la ricerca attraverso il primo 1/6 dell'incorporazione, dovremo creare un indice di ricerca vettoriale sul campo head_embedding. In seguito, confronteremo i risultati della "ricerca a imbuto" con una normale ricerca vettoriale, e quindi creeremo un indice di ricerca anche sull'intero embedding.

    +

    È importante notare che utilizziamo la metrica di distanza COSINE anziché IP, perché altrimenti dovremmo tenere traccia delle norme di incorporamento, il che complicherebbe l'implementazione (questo avrà più senso una volta descritto l'algoritmo di ricerca a imbuto).

    +
    index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
    +client.create_index(collection_name, index_params)
    +
    +

    Infine, codifichiamo i riassunti delle trame di tutti i 35k film e inseriamo le corrispondenti incorporazioni nel database.

    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    # This particular model requires us to prefix 'search_document:' to stored entities
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Output of embedding model is unnormalized
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
    +
    +

    Ora implementiamo una "ricerca a imbuto" utilizzando il primo 1/6 delle dimensioni dell'embedding Matryoshka. Ho in mente tre film da recuperare e ho prodotto il mio riassunto della trama per interrogare il database. Incorporiamo le query, quindi eseguiamo una ricerca vettoriale sul campo head_embedding, recuperando 128 candidati risultati.

    +
    queries = [
    +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
    +    "A teenager fakes illness to get off school and have adventures with two friends.",
    +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +# This particular model requires us to prefix 'search_query:' to queries
    +instruct_queries = ["search_query: " + q.strip() for q in queries]
    +search_data = embed_search(instruct_queries)
    +
    +# Normalize head embeddings
    +head_search = [x[:search_dim] for x in search_data]
    +
    +# Perform standard vector search on first sixth of embedding dimensions
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +

    A questo punto, abbiamo eseguito una ricerca su uno spazio vettoriale molto più piccolo e quindi è probabile che la latenza e i requisiti di memorizzazione dell'indice siano ridotti rispetto alla ricerca sull'intero spazio. Esaminiamo le prime 5 corrispondenze per ciascuna query:

    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits][:5]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +The Passage
    +Counterblast
    +Dominion: Prequel to the Exorcist
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +How to Deal
    +Shorts
    +Blackbird
    +Valentine
    +Unfriended
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +Ghostkeeper
    +Our Vines Have Tender Grapes
    +The Ref
    +Impact
    +The House in Marsh Road
    +
    +

    Come possiamo vedere, il richiamo ha sofferto come conseguenza del troncamento delle incorporazioni durante la ricerca. La ricerca a imbuto risolve questo problema con un trucco intelligente: possiamo usare il resto delle dimensioni dell'embedding per riordinare e sfoltire il nostro elenco di candidati e recuperare le prestazioni di recupero senza eseguire ulteriori costose ricerche vettoriali.

    +

    Per facilitare l'esposizione dell'algoritmo di ricerca funnel, convertiamo i risultati della ricerca Milvus per ogni query in un dataframe Pandas.

    +
    def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
    +    """
    +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
    +
    +    """
    +    rows = [x["entity"] for x in hits]
    +    rows_dict = [
    +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
    +    ]
    +    return pd.DataFrame.from_records(rows_dict)
    +
    +
    +dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +

    Ora, per eseguire la ricerca a imbuto, iteriamo sui sottoinsiemi sempre più grandi delle incorporazioni. A ogni iterazione, i candidati vengono classificati in base alle nuove somiglianze e viene eliminata una frazione di quelli classificati più in basso.

    +

    Per fare un esempio concreto, dalla fase precedente abbiamo recuperato 128 candidati utilizzando 1/6 delle dimensioni dell'embedding e della query. Il primo passo per eseguire la ricerca a imbuto consiste nel ricalcolare le somiglianze tra le query e i candidati utilizzando il primo 1/3 delle dimensioni. Gli ultimi 64 candidati vengono eliminati. Quindi si ripete il processo con i primi 2/3 delle dimensioni e poi con tutte le dimensioni, riducendo successivamente a 32 e 16 i candidati.

    +
    # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
    +def calculate_score(row, query_emb=None, dims=768):
    +    emb = F.normalize(row["embedding"][:dims], dim=-1)
    +    return (emb @ query_emb).item()
    +
    +
    +# You could also add a top-K parameter as a termination condition
    +def funnel_search(
    +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
    +) -> pd.DataFrame:
    +    # Loop over increasing prefixes of the embeddings
    +    for dims in scales:
    +        # Query vector must be normalized for each new dimensionality
    +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
    +
    +        # Score
    +        scores = df.apply(
    +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
    +        )
    +        df["scores"] = scores
    +
    +        # Re-rank
    +        df = df.sort_values(by="scores", ascending=False)
    +
    +        # Prune (in our case, remove half of candidates at each step)
    +        df = df.head(int(prune_ratio * len(df)))
    +
    +    return df
    +
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, search_data)
    +]
    +
    +
    for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    + 0           "Pimpernel" Smith
    +1               Black Hunters
    +29    Raiders of the Lost Ark
    +34             The Master Key
    +51            My Gun Is Quick
    +Name: title, dtype: object 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    + 21               How I Live Now
    +32     On the Edge of Innocence
    +77             Bratz: The Movie
    +4                    Unfriended
    +108                  Simon Says
    +Name: title, dtype: object 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    + 9         The Shining
    +0         Ghostkeeper
    +11     Fast and Loose
    +7      Killing Ground
    +12         Home Alone
    +Name: title, dtype: object 
    +
    +

    Siamo riusciti a ripristinare il richiamo senza eseguire ulteriori ricerche vettoriali! Qualitativamente, questi risultati sembrano avere un richiamo più elevato per "I predatori dell'arca perduta" e "Shining" rispetto alla ricerca vettoriale standard del tutorial "Movie Search using Milvus and Sentence Transformers", che utilizza un modello di incorporamento diverso. Tuttavia, non riesce a trovare "Ferris Bueller's Day Off", su cui torneremo più avanti nel quaderno. (Si veda il documento Matryoshka Representation Learning per ulteriori esperimenti quantitativi e benchmark).

    +

    Confrontiamo i risultati della nostra ricerca a imbuto con una ricerca vettoriale standard sullo stesso set di dati con lo stesso modello di incorporazione. Eseguiamo una ricerca sulle incorporazioni complete.

    +
    # Search on entire embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=search_data,
    +    anns_field="embedding",
    +    limit=5,
    +    output_fields=["title", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +Raiders of the Lost Ark
    +The Master Key
    +My Gun Is Quick
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +A Walk to Remember
    +Ferris Bueller's Day Off
    +How I Live Now
    +On the Edge of Innocence
    +Bratz: The Movie
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +The Shining
    +Ghostkeeper
    +Fast and Loose
    +Killing Ground
    +Home Alone
    +
    +

    Con l'eccezione dei risultati per "Un adolescente finge una malattia per non andare a scuola...", i risultati della ricerca a imbuto sono quasi identici a quelli della ricerca completa, anche se la ricerca a imbuto è stata eseguita su uno spazio di ricerca di 128 dimensioni contro le 768 della ricerca normale.

    +

    Analisi del fallimento della ricerca a imbuto per Ferris Bueller's Day Off

    Perché la ricerca a imbuto non è riuscita a recuperare Ferris Bueller's Day Off? Verifichiamo se era presente nell'elenco originale dei candidati o se è stato erroneamente filtrato.

    +
    queries2 = [
    +    "A teenager fakes illness to get off school and have adventures with two friends."
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +instruct_queries = ["search_query: " + q.strip() for q in queries2]
    +search_data2 = embed_search(instruct_queries)
    +head_search2 = [x[:search_dim] for x in search_data2]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search2,
    +    anns_field="head_embedding",
    +    limit=256,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", queries2[0])
    +    for idx, row in enumerate(rows):
    +        if row["title"].strip() == "Ferris Bueller's Day Off":
    +            print(f"Row {idx}: Ferris Bueller's Day Off")
    +
    +
    Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Row 228: Ferris Bueller's Day Off
    +
    +

    Vediamo che il problema era che l'elenco iniziale dei candidati non era abbastanza ampio, o meglio, l'hit desiderato non era abbastanza simile alla query al massimo livello di granularità. Cambiando da 128 a 256 il risultato è stato recuperato con successo. Dovremmo stabilire una regola empirica per impostare il numero di candidati su un set di attesa per valutare empiricamente il compromesso tra richiamo e latenza.

    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries2, dfs, search_data2)
    +]
    +
    +for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
    +
    +
    A teenager fakes illness to get off school and have adventures with two friends. 
    +       A Walk to Remember
    +Ferris Bueller's Day Off
    +          How I Live Now
    +On the Edge of Innocence
    +        Bratz: The Movie
    +              Unfriended
    +              Simon Says 
    +
    +

    L'ordine è importante? Incorporazione di prefissi e suffissi.

    Il modello è stato addestrato per ottenere buoni risultati con i prefissi ricorsivamente più piccoli degli embeddings. L'ordine delle dimensioni che utilizziamo è importante? Per esempio, potremmo prendere anche sottoinsiemi di embeddings che sono suffissi? In questo esperimento, invertiamo l'ordine delle dimensioni nelle Matryoshka embeddings ed eseguiamo una ricerca a imbuto.

    +
    client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +client.create_index(collection_name, index_params)
    +
    +
    huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
    +To disable this warning, you can either:
    +    - Avoid using `tokenizers` before the fork if possible
    +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
    +
    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Encode and flip embeddings
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    embeddings = torch.flip(embeddings, dims=[-1])
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
    +
    +
    # Normalize head embeddings
    +
    +flip_search_data = [
    +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
    +]
    +flip_head_search = [x[:search_dim] for x in flip_search_data]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=flip_head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
    +]
    +
    +for d in dfs_results:
    +    print(
    +        d["query"],
    +        "\n",
    +        d["results"][:7]["title"].to_string(index=False, header=False),
    +        "\n",
    +    )
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    +       "Pimpernel" Smith
    +          Black Hunters
    +Raiders of the Lost Ark
    +         The Master Key
    +        My Gun Is Quick
    +            The Passage
    +        The Mole People 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    +                       A Walk to Remember
    +                          How I Live Now
    +                              Unfriended
    +Cirque du Freak: The Vampire's Assistant
    +                             Last Summer
    +                                 Contest
    +                                 Day One 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    +         Ghostkeeper
    +     Killing Ground
    +Leopard in the Snow
    +              Stone
    +          Afterglow
    +         Unfaithful
    +     Always a Bride 
    +
    +

    Il richiamo è molto più scarso rispetto alla ricerca a imbuto o alla ricerca normale, come ci si aspettava (il modello di incorporazione è stato addestrato tramite apprendimento contrastivo sui prefissi delle dimensioni di incorporazione, non sui suffissi).

    +

    Sintesi

    Ecco un confronto dei risultati della ricerca tra i vari metodi:

    +
    +
    +
    +Abbiamo mostrato come utilizzare le Matryoshka embeddings con Milvus per eseguire un algoritmo di ricerca semantica più efficiente chiamato "funnel search". Abbiamo anche esplorato l'importanza delle fasi di reranking e pruning dell'algoritmo, nonché una modalità di fallimento quando l'elenco iniziale di candidati è troppo piccolo. Infine, abbiamo discusso di come l'ordine delle dimensioni sia importante quando si formano i sub-embeddings: deve essere nello stesso modo per il quale il modello è stato addestrato. O meglio, è solo perché il modello è stato addestrato in un certo modo che i prefissi delle incorporazioni sono significativi. Ora sapete come implementare le Matryoshka embeddings e la ricerca a imbuto per ridurre i costi di memorizzazione della ricerca semantica senza sacrificare troppo le prestazioni di recupero! diff --git a/localization/v2.4.x/site/it/tutorials/tutorials-overview.md b/localization/v2.4.x/site/it/tutorials/tutorials-overview.md index 5686e1573..f57dcaaf3 100644 --- a/localization/v2.4.x/site/it/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/it/tutorials/tutorials-overview.md @@ -27,8 +27,8 @@ title: Panoramica dei tutorial Costruire RAG con MilvusRAGricerca vettoriale RAG multimodale con MilvusRAGricerca vettoriale, campo dinamico Ricerca per immagini con MilvusRicerca semanticaricerca vettoriale, campo dinamico -Ricerca ibrida con MilvusRicerca ibridaricerca ibrida, multi vettoriale, incorporazione densa, incorporazione rada -Ricerca multimodale con più vettoriRicerca semanticamulti vettoriale, ricerca ibrida +Ricerca ibrida con MilvusRicerca ibridaricerca ibrida, multi-vettore, incorporazione densa, incorporazione rada +Ricerca multimodale con più vettoriRicerca semanticamulti vettore, ricerca ibrida Sistema di risposta alle domandeRisposta alle domandericerca vettoriale Sistema di raccomandazioneSistema di raccomandazionericerca vettoriale Ricerca per similarità videoRicerca semanticaricerca vettoriale @@ -43,5 +43,6 @@ title: Panoramica dei tutorial Utilizzare ColPali per il recupero multimodale con MilvusAvvio rapidoricerca vettoriale Visualizzazione vettorialeAvvio rapidoricerca vettoriale Raccomandazione di film con MilvusSistema di raccomandazionericerca vettoriale +Ricerca a imbuto con Matryoshka EmbeddingsAvvio rapidoricerca vettoriale diff --git a/localization/v2.4.x/site/it/userGuide/manage-collections.json b/localization/v2.4.x/site/it/userGuide/manage-collections.json index a59ac5855..f9edcb16f 100644 --- a/localization/v2.4.x/site/it/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/it/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gestire le raccolte","href":"Manage-Collections","type":1,"isActive":false},{"label":"Prima di iniziare","href":"Before-you-start","type":2,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Creare una raccolta","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualizzare le raccolte","href":"View-Collections","type":2,"isActive":false},{"label":"Caricamento e rilascio della raccolta","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Impostare gli alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Impostare le proprietà","href":"Set-Properties","type":2,"isActive":false},{"label":"Abbandonare una raccolta","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gestire le raccolte","href":"Manage-Collections","type":1,"isActive":false},{"label":"Prima di iniziare","href":"Before-you-start","type":2,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Creare una raccolta","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualizzare le raccolte","href":"View-Collections","type":2,"isActive":false},{"label":"Caricamento e rilascio della raccolta","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Impostare gli alias","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Impostare le proprietà","href":"Set-Properties","type":2,"isActive":false},{"label":"Abbandonare una raccolta","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/userGuide/manage-collections.md b/localization/v2.4.x/site/it/userGuide/manage-collections.md index 8104c9e34..1ec4bdd4f 100644 --- a/localization/v2.4.x/site/it/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/it/userGuide/manage-collections.md @@ -54,7 +54,7 @@ title: Gestire le raccolte

    In Milvus, si memorizzano le incorporazioni vettoriali in collezioni. Tutti gli embeddings vettoriali all'interno di una collezione condividono la stessa dimensionalità e la stessa metrica di distanza per misurare la somiglianza.

    Le collezioni di Milvus supportano campi dinamici (cioè campi non predefiniti nello schema) e l'incremento automatico delle chiavi primarie.

    -

    Per soddisfare le diverse preferenze, Milvus offre due metodi per creare una raccolta. Uno fornisce una configurazione rapida, mentre l'altro consente una personalizzazione dettagliata dello schema della collezione e dei parametri degli indici.

    +

    Per soddisfare le diverse preferenze, Milvus offre due metodi per creare una collezione. Uno fornisce una configurazione rapida, mentre l'altro consente una personalizzazione dettagliata dello schema della collezione e dei parametri degli indici.

    Inoltre, è possibile visualizzare, caricare, rilasciare e abbandonare una raccolta quando necessario.

    Creare una raccolta

    In Milvus, un indice scalare viene utilizzato per velocizzare il metafiltraggio in base a un valore specifico di un campo non vettoriale, in modo simile a un indice tradizionale di un database. Questa guida illustra la creazione e la configurazione di indici scalari per campi come numeri interi, stringhe, ecc.

    +

    In Milvus, un indice scalare viene utilizzato per accelerare il metafiltraggio in base a un valore specifico di un campo non vettoriale, in modo simile a un indice tradizionale di un database. Questa guida illustra la creazione e la configurazione di indici scalari per campi come numeri interi, stringhe, ecc.

    Tipi di indicizzazione scalare

    • In quale scenario è consigliata la ricerca ibrida?

      -

      La ricerca ibrida è ideale per situazioni complesse che richiedono un'elevata precisione, soprattutto quando un'entità può essere rappresentata da più vettori diversi. Questo vale per i casi in cui gli stessi dati, come una frase, vengono elaborati attraverso diversi modelli di incorporazione o quando le informazioni multimodali (come le immagini, le impronte digitali e le impronte vocali di un individuo) vengono convertite in diversi formati vettoriali. Assegnando dei pesi a questi vettori, la loro influenza combinata può arricchire significativamente il richiamo e migliorare l'efficacia dei risultati di ricerca.

    • +

      La ricerca ibrida è ideale per situazioni complesse che richiedono un'elevata precisione, soprattutto quando un'entità può essere rappresentata da più vettori diversi. Questo vale per i casi in cui gli stessi dati, come una frase, vengono elaborati attraverso diversi modelli di incorporamento o quando le informazioni multimodali (come le immagini, le impronte digitali e le impronte vocali di un individuo) vengono convertite in diversi formati vettoriali. Assegnando dei pesi a questi vettori, la loro influenza combinata può arricchire significativamente il richiamo e migliorare l'efficacia dei risultati di ricerca.

    • Come fa un ranker ponderato a normalizzare le distanze tra diversi campi vettoriali?

      -

      Un ranker ponderato normalizza le distanze tra i campi vettoriali utilizzando i pesi assegnati a ciascun campo. Calcola l'importanza di ogni campo vettoriale in base al suo peso, dando priorità a quelli con pesi più elevati. Si consiglia di utilizzare lo stesso tipo di metrica per tutte le richieste di ricerca di RNA per garantire la coerenza. Questo metodo garantisce che i vettori ritenuti più significativi abbiano una maggiore influenza sulla classifica generale.

    • +

      Un ranker ponderato normalizza le distanze tra i campi vettoriali utilizzando i pesi assegnati a ciascun campo. Calcola l'importanza di ogni campo vettoriale in base al suo peso, dando priorità a quelli con pesi più elevati. Si consiglia di utilizzare lo stesso tipo di metrica per tutte le richieste di ricerca di RNA, per garantire la coerenza. Questo metodo garantisce che i vettori ritenuti più significativi abbiano una maggiore influenza sulla classifica generale.

    • È possibile utilizzare classificatori alternativi come Cohere Ranker o BGE Ranker?

      Attualmente sono supportati solo i classificatori forniti. Per i prossimi aggiornamenti è prevista l'inclusione di altri classificatori.

    • È possibile eseguire più operazioni di ricerca ibrida contemporaneamente?

      diff --git a/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.json index f855cbf67..5c2f8cb05 100644 --- a/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Ricerca per singolo vettore","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Preparazioni","href":"Preparations","type":2,"isActive":false},{"label":"Ricerca di base","href":"Basic-search","type":2,"isActive":false},{"label":"Ricerca filtrata","href":"Filtered-search","type":2,"isActive":false},{"label":"Ricerca per intervallo","href":"Range-search","type":2,"isActive":false},{"label":"Ricerca per raggruppamento","href":"Grouping-search","type":2,"isActive":false},{"label":"Parametri di ricerca","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Ricerca per singolo vettore","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Preparazioni","href":"Preparations","type":2,"isActive":false},{"label":"Ricerca di base","href":"Basic-search","type":2,"isActive":false},{"label":"Ricerca filtrata","href":"Filtered-search","type":2,"isActive":false},{"label":"Ricerca per intervallo","href":"Range-search","type":2,"isActive":false},{"label":"Ricerca per raggruppamento","href":"Grouping-search","type":2,"isActive":false},{"label":"Parametri di ricerca","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.md index 2c39fb7ee..923d802ee 100644 --- a/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/it/userGuide/search-query-get/single-vector-search.md @@ -24,7 +24,7 @@ title: Ricerca per singolo vettore

      Una volta inseriti i dati, il passo successivo consiste nell'eseguire ricerche di similarità sulla collezione in Milvus.

      Milvus consente di effettuare due tipi di ricerca, a seconda del numero di campi vettoriali presenti nella collezione:

        -
      • Ricerca a vettore singolo: Se la vostra collezione ha un solo campo vettoriale, utilizzate il metodo search() per trovare le entità più simili. Questo metodo confronta il vettore interrogato con i vettori esistenti nella collezione e restituisce gli ID delle corrispondenze più vicine insieme alle distanze tra loro. Opzionalmente, può anche restituire i valori del vettore e i metadati dei risultati.
      • +
      • Ricerca a vettore singolo: Se la vostra collezione ha un solo campo vettoriale, utilizzate il metodo search() per trovare le entità più simili. Questo metodo confronta il vettore dell'interrogazione con i vettori esistenti nella collezione e restituisce gli ID delle corrispondenze più vicine insieme alle distanze tra loro. Opzionalmente, può anche restituire i valori del vettore e i metadati dei risultati.
      • Ricerca ibrida: Per le raccolte con due o più campi vettoriali, utilizzare il metodo hybrid_search() . Questo metodo esegue più richieste di ricerca Approximate Nearest Neighbor (ANN) e combina i risultati per restituire le corrispondenze più rilevanti dopo una nuova classificazione.

      Questa guida si concentra su come eseguire una ricerca monovettoriale in Milvus. Per maggiori dettagli sulla ricerca ibrida, consultare la sezione Ricerca ibrida.

      @@ -68,10 +68,12 @@ title: Ricerca per singolo vettore

      Il frammento di codice seguente ripropone il codice esistente per stabilire una connessione a Milvus e impostare rapidamente una raccolta.

      -
      # 1. Set up a Milvus client
      +
      from pymilvus import MilvusClient
      +import random
      +
      +# 1. Set up a Milvus client
       client = MilvusClient(
      -    uri=CLUSTER_ENDPOINT,
      -    token=TOKEN 
      +    uri="http://localhost:19530"
       )
       
       # 2. Create a collection
      @@ -449,7 +451,7 @@ res = await client.Python  Java Node.js
       
      # Single vector search
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           # Replace with your query vector
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
      @@ -643,7 +645,7 @@ res = await client.Python  Java Node.js
       
      # Bulk-vector search
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[
               [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
               [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
      @@ -1220,7 +1222,7 @@ searchResp = client.search(searchReq);
         { score: 2.7014894485473633, id: '1597' }
       ]
       
      -

      I dati di red differiscono da quelli di blue. Pertanto, i risultati della ricerca saranno limitati alla partizione specificata, riflettendo le caratteristiche uniche e la distribuzione dei dati di quel sottoinsieme.

      +

      I dati contenuti in red differiscono da quelli contenuti in blue. Pertanto, i risultati della ricerca saranno limitati alla partizione specificata, riflettendo le caratteristiche uniche e la distribuzione dei dati di quel sottoinsieme.

      Ricerca con campi di output

      La ricerca con campi di output consente di specificare quali attributi o campi dei vettori abbinati devono essere inclusi nei risultati della ricerca.

      È possibile specificare output_fields in una richiesta per restituire risultati con campi specifici.

      Ecco un esempio di restituzione dei risultati con i valori dell'attributo color:

      @@ -1228,7 +1230,7 @@ searchResp = client.search(searchReq); Python Java Node.js
      # Search with output fields
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1357,7 +1359,7 @@ res = await client.
             
      -    

      La ricerca filtrata applica filtri scalari alle ricerche vettoriali, consentendo di affinare i risultati della ricerca in base a criteri specifici. Maggiori informazioni sulle espressioni di filtro sono disponibili in Regole delle espressioni booleane ed esempi in Ottieni e Query scalari.

      +

      La ricerca filtrata applica filtri scalari alle ricerche vettoriali, consentendo di affinare i risultati della ricerca in base a criteri specifici. Maggiori informazioni sulle espressioni di filtro sono disponibili in Regole di espressione booleana ed esempi in Ottieni e Query scalari.

      Utilizzare l'operatore like

      L'operatore like migliora la ricerca di stringhe valutando modelli che includono prefissi, infissi e suffissi:

      • Corrispondenza dei prefissi: per trovare valori che iniziano con un prefisso specifico, utilizzare la sintassi 'like "prefix%"'.
      • @@ -1376,7 +1378,7 @@ res = await client.Python Java Node.js
        # Search with filter
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1483,7 +1485,7 @@ res = await client.Python  Java Node.js
         
        # Infix match on color field
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1584,7 +1586,7 @@ search_params = {
         }
         
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=3, # Max. number of search results to return
             search_params=search_params, # Search parameters
        @@ -1787,7 +1789,7 @@ passage_ids = [result['entity'][["doc_11", "doc_11", "doc_11", "doc_11", "doc_11"]
         [1, 10, 3, 12, 9]
         
        -

        Nell'output dato, si può osservare che "doc_11" ha dominato completamente i risultati della ricerca, mettendo in ombra i paragrafi di alta qualità degli altri documenti, il che può essere un cattivo suggerimento per LLM.

        +

        Nell'output dato, si può osservare che "doc_11" ha dominato completamente i risultati della ricerca, mettendo in ombra i paragrafi di alta qualità di altri documenti, il che può essere un cattivo suggerimento per LLM.

        Un altro punto da notare: per impostazione predefinita, grouping_search restituisce i risultati istantaneamente quando ha abbastanza gruppi, il che può far sì che il numero di risultati in ogni gruppo non sia sufficiente a soddisfare il group_size. Se vi interessa il numero di risultati per ogni gruppo, impostate group_strict_size=True come mostrato nel codice qui sopra. In questo modo Milvus si sforzerà di ottenere un numero sufficiente di risultati per ogni gruppo, con un leggero costo in termini di prestazioni.

        Limitazioni

          diff --git a/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.json b/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.json index 3e1008259..b007cd2b8 100644 --- a/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.json +++ b/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Con gli iteratori","href":"With-Iterators","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Preparazione","href":"Preparations","type":2,"isActive":false},{"label":"Ricerca con iteratore","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Interrogazione con un iteratore","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection,connections\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Con gli iteratori","href":"With-Iterators","type":1,"isActive":false},{"label":"Panoramica","href":"Overview","type":2,"isActive":false},{"label":"Preparazione","href":"Preparations","type":2,"isActive":false},{"label":"Ricerca con iteratore","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Interrogazione con un iteratore","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.md b/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.md index 45a038b6a..8f4d01f33 100644 --- a/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.md +++ b/localization/v2.4.x/site/it/userGuide/search-query-get/with-iterators.md @@ -248,7 +248,7 @@ System.out.println(wrapper.getInsertCount()); -
          from pymilvus import Collection
          +
          from pymilvus import Collection,connections
           
           # 4. Search with iterator
           connections.connect(host="127.0.0.1", port=19530)
          @@ -367,7 +367,7 @@ System.out.println(results.size());
               
               
                 batch_size
          -      Il numero di entità da restituire ogni volta che si chiama next() sull'iteratore corrente.
          Il valore predefinito è 1000. Impostare un valore corretto per controllare il numero di entità da restituire per ogni iterazione. + Il numero di entità da restituire ogni volta che si chiama next() sull'iteratore corrente.
          Il valore è predefinito a 1000. Impostare un valore corretto per controllare il numero di entità da restituire per ogni iterazione. param @@ -546,7 +546,7 @@ R<QueryIterator> queryIteratRes = c batch_size - Il numero di entità da restituire ogni volta che si richiama next() sull'iteratore corrente.
          Il valore predefinito è 1000. Impostare un valore appropriato per controllare il numero di entità da restituire per ogni iterazione. + Il numero di entità da restituire ogni volta che si richiama next() sull'iteratore corrente.
          Il valore predefinito è 1000. Impostare un valore corretto per controllare il numero di entità da restituire per ogni iterazione. expr diff --git a/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.json index 75f0d2dae..ce6cb3cc4 100644 --- a/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"HelmチャートによるMilvusクラスタのアップグレード","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Milvus Helmチャートの確認","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"ローリングアップグレードの実施","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Helmを使用したMilvusのアップグレード","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"メタデータの移行","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"HelmチャートによるMilvusクラスタのアップグレード","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"Milvus Helmチャートの確認","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"ローリングアップグレードの実施","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"Helmを使用したMilvusのアップグレード","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"メタデータの移行","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.md index 59d640b3c..d66d5e17e 100644 --- a/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/ja/adminGuide/upgrade_milvus_cluster-helm.md @@ -170,7 +170,7 @@ helm upgrade my-release zilliztech/milvus --reuse-values --version=1.Milvusバージョンの確認

          $ helm list を実行し、Milvusアプリのバージョンを確認します。APP VERSION は 2.1.4 です。

          +

          1.Milvusバージョンの確認

          $ helm list を実行し、Milvusアプリのバージョンを確認します。APP VERSION 、2.1.4であることがわかります。

          NAME                NAMESPACE   REVISION    UPDATED                                 STATUS      CHART           APP VERSION    
           new-release         default     1           2022-11-21 15:41:25.51539 +0800 CST     deployed    milvus-3.2.18   2.1.4 
           
          @@ -221,7 +221,7 @@ my-release-pulsar-zookeeper-2 tインストール先のMilvusのバージョン。NonerMilvusメタのルートパス。by-devwMilvusの新しい画像タグ。milvusdb/milvus:v2.2.0False -mmetaマイグレーションイメージタグ。milvusdb/meta-migration:v2.2.0誤 +mmetaマイグレーションイメージタグ。milvusdb/meta-migration:v2.2.0False oメタマイグレーション操作migratedマイグレーション完了後にマイグレーションポッドを削除するかどうか。falseFalse cメタ・マイグレーションpvcのストレージ・クラス。default storage classFalse @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
        • Milvusメタデータを移行します。
        • 新しいイメージでMilvusコンポーネントを起動する。
        • -

          2.Milvusをv2.1.xから2.4.15にアップグレードする。

          以下のコマンドは、Milvusをv2.1.4から2.4.15にアップグレードすることを前提としています。必要なバージョンに変更してください。

          +

          2.Milvusをv2.1.xから2.2.0にアップグレードする。

          以下のコマンドは、Milvusをv2.1.4から2.2.0にアップグレードすることを前提としています。必要なバージョンに変更してください。

          1. Milvusインスタンス名、ソースMilvusバージョン、ターゲットMilvusバージョンを指定します。

            -
            ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
            +
            ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
             
          2. MilvusがデフォルトのK8s名前空間にインストールされていない場合は、-n で名前空間を指定します。

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
             
          3. Milvusがカスタムrootpath でインストールされている場合は、-r でルートパスを指定してください。

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
             
          4. Milvusがカスタムimage でインストールされている場合は、-w でイメージタグを指定してください。

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
             
          5. マイグレーション完了後にマイグレーションポッドを自動的に削除する場合は、-d true を設定します。

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
             
          6. マイグレーションに失敗した場合は、ロールバックしてマイグレーションをやり直します。

            -
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
            -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
            +
            ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
            +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
             
          diff --git a/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.json index 24fad2259..6012d8dd7 100644 --- a/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"Helmを使ってKubernetesでMilvusを実行する","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"Milvusヘルムチャートのインストール","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"オンラインインストール","href":"Online-install","type":2,"isActive":false},{"label":"オフラインインストール","href":"Offline-install","type":2,"isActive":false},{"label":"Milvusクラスタのアップグレード","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Milvusのアンインストール","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"次の記事","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"KubernetesでHelmを使ってMilvusを起動する","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"Milvus Helm Chartのインストール","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"オンラインインストール","href":"Online-install","type":2,"isActive":false},{"label":"オフラインインストール","href":"Offline-install","type":2,"isActive":false},{"label":"稼働中のMilvusクラスタのアップグレード","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Milvusのアンインストール","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"次の作業","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.md index bbd2cd275..5c17eafae 100644 --- a/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/ja/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -2,7 +2,7 @@ id: install_cluster-helm.md label: Helm related_key: Kubernetes -summary: KubernetesにMilvusクラスタをインストールする方法を学ぶ。 +summary: KubernetesにMilvusクラスタをインストールする方法をご紹介します。 title: HelmでMilvusクラスタをインストールする ---

          KubernetesでHelmを使ってMilvusを起動する

        • インストール前にハードウェアとソフトウェアの要件を確認します。

        • -
        • Milvusをインストールする前に、Milvus Sizing Toolを使用して、データサイズに基づいてハードウェア要件を見積もることを推奨します。これにより、Milvusのインストールに最適なパフォーマンスとリソースの割り当てを確保することができます。

        • +
        • Milvusをインストールする前に、Milvus Sizing Toolを使用して、データサイズに基づいてハードウェア要件を見積もることを推奨します。これにより、Milvusのインストールに最適なパフォーマンスとリソースを確保することができます。

        イメージのプル時に問題が発生した場合は、community@zilliz.comまで問題の詳細をご連絡ください。

        @@ -83,21 +83,21 @@ NAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDI >

        Milvus Helm Chartsをインストールする前に、Milvus Helmリポジトリを追加する必要があります。

        -
        $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
        +
        $ helm repo add milvus https://github.com/zilliztech/milvus-helm
         
        -

        https://milvus-io.github.io/milvus-helm/ にある Milvus Helm Charts リポジトリはアーカイブされており、以下のようにhttps://zilliztech.github.io/milvus-helm/ からさらなるアップデートを取得することができます:

        -
        helm repo add zilliztech https://zilliztech.github.io/milvus-helm
        +

        https://github.com/milvus-io/milvus-helm にある Milvus Helm Charts リポジトリはアーカイブされており、https://github.com/zilliztech/milvus-helm から以下のようにアップデートを入手することができます:

        +
        helm repo add zilliztech https://github.com/zilliztech/milvus-helm
         helm repo update
         # upgrade existing helm release
         helm upgrade my-release zilliztech/milvus
         

        アーカイブされたリポジトリは、4.0.31までのチャートで利用可能です。それ以降のリリースについては、新しいレポをご利用ください。

        -

        次に、以下のようにリポジトリからMilvusチャートを取得します:

        +

        Milvusチャートをリポジトリから取得するには以下のようにします:

        $ helm repo update
         
        -

        このコマンドを実行することで、いつでも最新のMilvus Helmチャートを取得することができます。

        +

        このコマンドを実行することで、常に最新のMilvus Helmチャートを取得することができます。

        オンラインインストール

        1.Milvusクラスタのデプロイ

        Helmチャートをインストールしたら、Kubernetes上でMilvusを起動します。ここでは、Milvusの起動手順を説明する。

        +

        1.Milvusクラスタのデプロイ

        Helmチャートをインストールしたら、Kubernetes上でMilvusを起動できます。ここでは、Milvusの起動手順を説明します。

        $ helm install my-release milvus/milvus
         

        上記のコマンドでは、my-release がリリース名、milvus/milvus がローカルにインストールされているチャートリポジトリです。別の名前を使用する場合は、my-release を適切なものに置き換えてください。

        -

        上記のコマンドは、Milvusクラスタとそのコンポーネントおよび依存関係をデフォルトの設定でデプロイします。これらの設定をカスタマイズするには、Milvus Sizing Toolを使用して実際のデータサイズに基づいて設定を調整し、対応するYAMLファイルをダウンロードすることをお勧めします。設定パラメータの詳細については、Milvusシステム設定チェックリストを参照してください。

        +

        上記のコマンドは、Milvusクラスタとそのコンポーネントおよび依存関係をデフォルトの設定でデプロイします。これらの設定をカスタマイズするには、Milvus Sizing Toolを使用して実際のデータサイズに基づいて設定を調整し、対応するYAMLファイルをダウンロードすることをお勧めします。コンフィギュレーションパラメータの詳細については、Milvusシステムコンフィギュレーションチェックリストをご参照ください。

        • リリース名にはアルファベット、数字、ダッシュのみを使用してください。リリース名にはドットは使用できません。
        • -
        • デフォルトのコマンドラインでは、Helmを使用したMilvusのインストール時にクラスタバージョンのMilvusがインストールされます。Milvusをスタンドアロンでインストールする場合は、さらなる設定が必要です。
        • -
        • Kubernetesのdeprecated API migration guideによると、PodDisruptionBudgetのpolicy/v1beta1APIバージョンはv1.25で提供されなくなった。代わりにpolicy/v1APIバージョンを使用するようにマニフェストとAPIクライアントを移行することが推奨されます。
          Kubernetes v1.25以降でPodDisruptionBudgetのpolicy/v1beta1APIバージョンをまだ使用しているユーザのための回避策として、代わりに以下のコマンドを実行してMilvusをインストールすることができます:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • -
        • 詳細については、Milvus Helm ChartおよびHelmを参照してください。
        • +
        • MilvusをHelmと共にインストールする場合、デフォルトのコマンドラインはMilvusのクラスタバージョンをインストールします。Milvusをスタンドアロンでインストールする場合は、さらなる設定が必要です。
        • +
        • Kubernetesのdeprecated API migration guideによると、PodDisruptionBudgetのpolicy/v1beta1APIバージョンはv1.25で提供されなくなった。代わりにpolicy/v1APIバージョンを使用するようにマニフェストとAPIクライアントを移行することが推奨されます。
          Kubernetes v1.25以降でPodDisruptionBudgetのpolicy/v1beta1APIバージョンをまだ使用しているユーザのための回避策として、代わりに以下のコマンドを実行してmilvusをインストールすることができます:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • +
        • 詳細はMilvus Helm Chartと Helmを参照してください。
        -

        2.Milvusクラスタのステータスの確認

        以下のコマンドを実行して、Milvusクラスタ内のすべてのPodのステータスを確認します。

        +

        2.Milvusクラスタのステータスの確認

        以下のコマンドを実行し、Milvusクラスタ内のすべてのPodのステータスを確認します。

        $ kubectl get pods
         

        すべてのPodが稼働していれば、上記コマンドの出力は以下のようになるはずです:

        @@ -158,13 +158,13 @@ my-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s

        出力は、Milvusインスタンスがデフォルトのポート19530でサービスを提供していることを示しています。

        -

        スタンドアロンモードでMilvusをデプロイしている場合、ポッド名をmy-release-milvus-proxy-xxxxxxxxxx-xxxxx からmy-release-milvus-xxxxxxxxxx-xxxxx に変更します。

        +

        Milvusをスタンドアロンモードでデプロイしている場合、ポッド名をmy-release-milvus-proxy-xxxxxxxxxx-xxxxx からmy-release-milvus-xxxxxxxxxx-xxxxx に変更します。

        次に、以下のコマンドを実行して、ローカルポートをMilvusがサービスを提供するポートに転送します。

        $ kubectl port-forward service/my-release-milvus 27017:19530
         Forwarding from 127.0.0.1:27017 -> 19530
         
        -

        オプションとして、上記のコマンドで27017:19530 の代わりに:19530 を使用し、kubectl にローカルポートを割り当てさせることで、ポートの競合を管理する必要がなくなります。

        +

        オプションとして、上記のコマンドで27017:19530 の代わりに:19530 を使用することで、kubectl にローカルポートを割り当てさせることができ、ポートの競合を管理する必要がなくなります。

        デフォルトでは、kubectlのポートフォワーディングはlocalhost のみをリッスンします。Milvusに選択したIPアドレスまたはすべてのIPアドレスをリッスンさせたい場合は、address フラグを使用してください。以下のコマンドは、port-forwardをホストマシンのすべてのIPアドレスでリッスンするようにします。

        $ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530
         Forwarding from 0.0.0.0:27017 -> 19530
        @@ -188,11 +188,11 @@ my-release-pulsar-zookeeper-metadata-98zbr       0/1   Completed  0        3m24s
         

        1.Milvusマニフェストの取得

        以下のコマンドを実行してMilvusマニフェストを取得します。

        $ helm template my-release milvus/milvus > milvus_manifest.yaml
         
        -

        上記のコマンドはMilvusクラスタ用のチャートテンプレートをレンダリングし、その出力をmilvus_manifest.yaml という名前のマニフェストファイルに保存します。このマニフェストを使用して、コンポーネントと依存関係を持つMilvusクラスタを個別のポッドにインストールできます。

        +

        上記のコマンドはMilvusクラスタのチャートテンプレートをレンダリングし、その出力をmilvus_manifest.yaml という名前のマニフェストファイルに保存します。このマニフェストを使用すると、コンポーネントと依存関係を持つMilvusクラスタを個別のポッドにインストールできます。

          -
        • すべてのMilvusコンポーネントが単一のポッドに含まれるスタンドアロンモードでMilvusインスタンスをインストールするには、代わりにhelm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml を実行してスタンドアロンモードのMilvusインスタンス用のチャートテンプレートをレンダリングする必要があります。
        • -
        • Milvusの設定を変更するには value.yamlテンプレートをダウンロードし、必要な設定をそのテンプレートに配置し、helm template -f values.yaml my-release milvus/milvus > milvus_manifest.yaml を使用して、それに従ってマニフェストをレンダリングします。
        • +
        • すべてのMilvusコンポーネントが単一のポッドに含まれるスタンドアロンモードでMilvusインスタンスをインストールするには、代わりにhelm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml を実行して、スタンドアロンモードのMilvusインスタンス用のチャートテンプレートをレンダリングする必要があります。
        • +
        • Milvusのコンフィギュレーションを変更するには、Milvusテンプレートをダウンロードし、必要な設定をそのテンプレートに配置します。 value.yamlテンプレートをダウンロードし、必要な設定をそのテンプレートに配置し、helm template -f values.yaml my-release milvus/milvus > milvus_manifest.yaml を使用して、それに従ってマニフェストをレンダリングします。

        2.image-pulling スクリプトのダウンロード

        画像抽出スクリプトはPythonで開発されています。requirement.txt ファイルにある依存関係とともにスクリプトをダウンロードしてください。

        @@ -225,7 +225,7 @@ $ python3 save_image.py --manifest milvus_manifest.yaml d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        以下のコマンドを実行して、実行中のMilvusクラスタを最新バージョンにアップグレードします:

        +

        以下のコマンドを実行し、稼働中のMilvusクラスタを最新バージョンにアップグレードします:

        $ helm repo update
         $ helm upgrade my-release zilliztech/milvus
         
        @@ -265,7 +265,7 @@ $ helm upgrade my-release zilliztech/milvus

        DockerにMilvusをインストールしました:

        diff --git a/localization/v2.4.x/site/ja/integrations/integrations_overview.md b/localization/v2.4.x/site/ja/integrations/integrations_overview.md index ba93d2292..c73b8372b 100644 --- a/localization/v2.4.x/site/ja/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/ja/integrations/integrations_overview.md @@ -41,7 +41,7 @@ title: インテグレーション概要 MilvusとJinaによるセマンティック検索セマンティック検索Milvus、Jina MilvusとSnowparkコンテナサービスデータ接続Milvus、Snowpark MilvusとWhyHowによるルールベースの検索質問応答Milvus, WhyHow -LangfuseにおけるMilvus観測可能性Milvus, Langfuse +LangfuseにおけるMilvus観測可能性Milvus、Langfuse MilvusとRAGによる評価評価Milvus、Ragas MilvusとMemGPTによるチャットボットエージェントエージェントMilvus、MemGPT MilvusでFastGPTをデプロイする方法ラグMilvus、FastGPT @@ -51,7 +51,7 @@ title: インテグレーション概要 高度なビデオ検索:Twelve LabsとMilvusを活用したセマンティック検索セマンティック検索Milvus、Twelve Labs Milvus、vLLM、Llama 3.1によるRAGの構築RAGMilvus、vLLM、LlamaIndex Milvus, Milral AI, Llama-エージェントによるマルチエージェントシステムエージェントMilvus、Mistral AI、LlamaIndex -KafkaとMilvusの接続データソースMilvus、Kafka +KafkaとMilvusの接続データソースMilvus, Kafka Kotaemon RAGとMilvusの連携RAGMilvus、Kotaemon 検索拡張生成:Apifyでウェブサイトをクロールし、Milvusにデータを保存して質問に答える。データソースMilvus、Apify DeepEvalによる評価評価と観測可能性Milvus、DeepEval @@ -64,6 +64,10 @@ title: インテグレーション概要 MilvusとSiliconFlowによるRAGの構築LLMMilvus、SiliconFlow Milvusと非構造化データでRAGを構築するデータソースMilvus、非構造化データソース Milvus + PII MaskerによるRAGの構築データソースMilvus、PIIマスカー -PrivateGPTでのMilvusの使用オーケストレーションベクター検索 +PrivateGPTでのMilvusの使用オーケストレーションベクトル検索 +MilvusとMem0を使い始めるエージェントMem0とMilvus +Milvusとナレッジテーブルナレッジエンジニアリングナレッジテーブル, Milvus +DocsGPTでMilvusを使うオーケストレーションDocsGPT、Milvus +SambaNovaでMilvusを使うオーケストレーションMilvus、SambaNova diff --git a/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..c54c6b05c --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"ナレッジテーブルとMilvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"プロジェクトのクローン","href":"Cloning-the-project","type":2,"isActive":false},{"label":"環境のセットアップ","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"アプリの起動","href":"Starting-the-app","type":2,"isActive":false},{"label":"アプリの停止","href":"Stopping-the-app","type":2,"isActive":false},{"label":"プロジェクトへのアクセス","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..aa9560a0e --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,144 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + デフォルトでは、Knowledge + TableはMilvusデータベースを使用して、抽出されたデータを保存・検索します。これにより、ユーザはMilvusの強力な機能を使用して簡単にデータを検索、フィルタリング、分析することができます。このチュートリアルでは、Knowledge + TableとMilvusを使い始める方法を紹介します。 +title: ナレッジテーブルとMilvus +--- +

        ナレッジテーブルとMilvus

        WhyHow AIによって開発されたKnowledge Tableは、非構造化文書からの構造化データの抽出と探索を容易にするために設計されたオープンソースのパッケージです。ユーザーにスプレッドシートのようなインターフェイスを提供し、自然言語クエリインターフェイスを通じて表やグラフなどの知識表現を作成することができる。このパッケージには、カスタマイズ可能な抽出ルール、書式設定オプション、実績によるデータトレーサビリティが含まれており、多様なアプリケーションに適応可能です。RAGワークフローへのシームレスな統合をサポートしており、ユーザーフレンドリーなインターフェースを必要とするビジネスユーザーと、効率的な文書処理のための柔軟なバックエンドを必要とする開発者の両方に対応しています。

        +

        デフォルトでは、Knowledge TableはMilvusデータベースを使用して、抽出されたデータを保存・検索します。これにより、ユーザはMilvusの強力な機能を使用して簡単にデータを検索、フィルタリング、分析することができます。このチュートリアルでは、Knowledge TableとMilvusを使い始める方法を紹介します。

        +

        前提条件

          +
        • Docker
        • +
        • Docker Compose
        • +
        +

        プロジェクトのクローン

        $ git clone https://github.com/whyhow-ai/knowledge-table.git
        +
        +

        環境のセットアップ

        プロジェクトのルート・ディレクトリに.env.example ファイルがあります。このファイルを.env にコピーし、必要な環境変数を入力してください。

        +

        Milvusの場合は、MILVUS_DB_URIMILVUS_DB_TOKEN 環境変数を設定します。以下はそのヒントです:

        +
        +
          +
        • 例えば、./milvus.db のように、MILVUS_DB_URI をローカルファイルとして設定する方法は、Milvus Lite を自動的に利用してすべてのデータをこのファイルに保存するため、最も便利な方法です。
        • +
        • もし、100万ベクトルを超えるような大規模なデータがある場合、DockerやKubernetes上に、よりパフォーマンスの高いMilvusサーバを構築することができます。このセットアップでは、サーバのアドレスとポートをURIとして使用してください(例:http://localhost:19530 )。Milvusの認証機能を有効にしている場合は、トークンに"<your_username>:<your_password>"を使用してください。
        • +
        • MilvusのフルマネージドクラウドサービスであるZilliz Cloudを利用する場合は、Zilliz CloudのPublic EndpointとApi keyに対応するMILVUS_DB_URIMILVUS_DB_TOKEN を調整してください。
        • +
        +
        +

        Milvus 以外にも、OPENAI_API_KEY などの環境を設定する必要があります。これらはそれぞれのウェブサイトから入手できます。

        +

        アプリの起動

        $ docker-compose up -d --build
        +
        +

        アプリの停止

        $ docker-compose down
        +
        +

        プロジェクトへのアクセス

        フロントエンドはhttp://localhost:3000 から、バックエンドはhttp://localhost:8000 からアクセスできます。

        +

        + + + + +

        +

        UIで遊んでみたり、自分のドキュメントで試してみたりすることができる。

        +

        さらに詳しいデモの使い方については、ナレッジテーブルの公式ドキュメントを参照してください。

        diff --git a/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..6b223b04b --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Mem0とMilvusを使い始める","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"準備","href":"Preparation","type":2,"isActive":false},{"label":"Mem0とMilvusでユーザーメモリを管理する","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..f296bc585 --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,212 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + このチュートリアルでは、効率的な記憶と検索を可能にする高性能なオープンソースのベクトル・データベースであるMilvusを使用した、Mem0のメモリ管理に不可欠な操作(メモリの追加、検索、更新、検索、削除、履歴の追跡)について説明します。このハンズオン入門では、Mem0とMilvusを使用してパーソナライズされたAIインタラクションを構築するのに役立つ、基礎的なメモリ操作について説明します。 +title: Mem0とMilvusを使い始める +--- +

        Mem0とMilvusを使い始める

        +Open In Colab + + +GitHub Repository +

        +

        Mem0は、AIアプリケーションのためのインテリジェントなメモリーレイヤーで、ユーザーの好みを保持し、時間の経過とともに継続的に適応することで、パーソナライズされた効率的なインタラクションを実現するように設計されています。チャットボットやAI主導のツールに最適なMem0は、シームレスでコンテキストを意識したエクスペリエンスを実現します。

        +

        このチュートリアルでは、効率的な保存と検索を可能にする高性能なオープンソース・ベクター・データベースであるMilvusを使用して、Mem0に不可欠なメモリー管理操作(メモリー履歴の追加、検索、更新、検索、削除、追跡)について説明します。このハンズオン入門では、Mem0とMilvusを使用してパーソナライズされたAIインタラクションを構築するのに役立つ、基礎的なメモリー操作について説明します。

        +

        準備

        必要なライブラリのダウンロード

        $ pip install mem0ai pymilvus
        +
        +
        +

        Google Colabを使用している場合、インストールした依存関係を有効にするために、ランタイムを再起動する必要があります(画面上部の "Runtime "メニューをクリックし、ドロップダウンメニューから "Restart session "を選択してください)。

        +
        +

        Milvusを使ったMem0の設定

        この例ではOpenAIをLLMとして使用します。環境変数としてapi key OPENAI_API_KEY

        +
        import os
        +
        +os.environ["OPENAI_API_KEY"] = "sk-***********"
        +
        +

        次に、Milvusをベクターストアとして使うようにMem0を設定します。

        +
        # Define Config
        +from mem0 import Memory
        +
        +config = {
        +    "vector_store": {
        +        "provider": "milvus",
        +        "config": {
        +            "collection_name": "quickstart_mem0_with_milvus",
        +            "embedding_model_dims": "1536",
        +            "url": "./milvus.db",  # Use local vector database for demo purpose
        +        },
        +    },
        +    "version": "v1.1",
        +}
        +
        +m = Memory.from_config(config)
        +
        +
        +
        +
          +
        • 小規模なデータやプロトタイピングのためにローカルのベクターデータベースが必要なだけであれば、uriをローカルファイル、例えば./milvus.db に設定するのが最も便利な方法です。
        • +
        • もし、100万ベクトルを超えるような大規模なデータがある場合は、DockerやKubernetes上に、よりパフォーマンスの高いMilvusサーバを構築することができます。このセットアップでは、サーバのアドレスとポートをURIとして使用してください(例:http://localhost:19530 )。Milvusの認証機能を有効にしている場合は、トークンに"<your_username>:<your_password>"を使用します。
        • +
        • MilvusのフルマネージドクラウドサービスであるMilvus Cloudをご利用の場合は、Milvus CloudのPublic EndpointとAPI keyに対応するuritoken を調整してください。
        • +
        +
        +
        +

        Mem0とMilvusでユーザーメモリを管理する

        メモリの追加

        add 関数は構造化されていないテキストをMilvusにメモリとして保存し、特定のユーザとオプションのメタデータを関連付けます。

        +

        ここでは、Aliceの「テニスの上達に取り組んでいる」というメモリーと、Milvusのコンテキストに関連するメタデータを追加しています。

        +
        # Add a memory to user: Working on improving tennis skills
        +res = m.add(
        +    messages="I am working on improving my tennis skills.",
        +    user_id="alice",
        +    metadata={"category": "hobbies"},
        +)
        +
        +res
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Working on improving tennis skills',
        +   'event': 'ADD'}],
        + 'relations': []}
        +
        +

        メモリの更新

        add 関数の戻り値を使ってメモリ ID を取得し、update を使って新しい情報でメモリを更新することができます。

        +
        # Get memory_id
        +memory_id = res["results"][0]["id"]
        +
        +# Update this memory with new information: Likes to play tennis on weekends
        +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
        +
        +
        {'message': 'Memory updated successfully!'}
        +
        +

        ユーザの全メモリの取得

        Milvusでは、get_all 関数を使用して、挿入されたすべてのメモリを表示したり、user_id でフィルタリングすることができます。

        +

        メモリが "テニスのスキルを磨く "から "週末にテニスをするのが好き "に変わったことがわかります。

        +
        # Get all memory for the user Alice
        +m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'}]}
        +
        +

        メモリの更新履歴を見る

        history 、どのmemory_idに興味があるかを指定することで、メモリの更新履歴を見ることもできます。

        +
        m.history(memory_id=memory_id)
        +
        +
        [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': None,
        +  'new_memory': 'Working on improving tennis skills',
        +  'event': 'ADD',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': None},
        + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': 'Working on improving tennis skills',
        +  'new_memory': 'Likes to play tennis on weekends',
        +  'event': 'UPDATE',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
        +
        +

        メモリの検索

        search 関数を使って、ユーザーに最も関連性の高いメモリーを検索することができます。

        +

        まずアリスのメモリーを追加します。

        +
        new_mem = m.add(
        +    "I have a linear algebra midterm exam on November 20",
        +    user_id="alice",
        +    metadata={"category": "task"},
        +)
        +
        +

        ここで、user_idを指定してget_all

        +
        m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        search query 、 。デフォルトでは メトリックを類似性検索に使っているので、 が小さいほど類似性が高いことを意味することに注意してください。user_id L2 score

        +
        m.search(query="What are Alice's hobbies", user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'score': 1.2807445526123047,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'score': 1.728922724723816,
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        メモリの削除

        対応するmemory_id を指定することで、delete メモリを削除することもできる。

        +

        memory_id はすでに検索されているので、"Likes to play tennis on weekends" というメモリーを削除し、get_all を呼び出して削除が成功したことを確認する。

        +
        m.delete(memory_id=memory_id)
        +
        +m.get_all("alice")
        +
        +
        {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..1c493a98e --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"DocsGPTでMilvusを使う","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"必要条件","href":"Requirements","type":2,"isActive":false},{"label":"リポジトリをクローンする","href":"Clone-the-repository","type":2,"isActive":false},{"label":"依存関係の追加","href":"Add-dependency","type":2,"isActive":false},{"label":"環境変数の設定","href":"Set-environment-variables","type":2,"isActive":false},{"label":"サービスの起動","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..4999b405b --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,140 @@ +--- +id: use_milvus_in_docsgpt.md +summary: このチュートリアルでは、MilvusをDocsGPTのバックエンドベクターデータベースとして使用する方法を紹介します。 +title: DocsGPTでMilvusを使う +--- +

        DocsGPTでMilvusを使う

        DocsGPTは、強力なGPTモデルを統合することで、プロジェクトドキュメントの情報検索を簡素化する先進的なオープンソースソリューションです。これにより、開発者はプロジェクトに関する質問に対する正確な答えを簡単に得ることができ、時間のかかる手作業による検索を省くことができます。

        +

        このチュートリアルでは、MilvusをDocsGPTのバックエンドベクターデータベースとして使用する方法を紹介します。

        +
        +

        このチュートリアルは主にDocsGPT公式インストールガイドを参照しています。もしこのチュートリアルに古い部分があるようでしたら、オフィシャルガイドに従うことを優先し、私たちに問題を作成してください。

        +
        +

        必要条件

        Dockerがインストールされていることを確認してください。

        +

        リポジトリをクローンする

        リポジトリをクローンし、そこに移動します:

        +
        $ git clone https://github.com/arc53/DocsGPT.git
        +$ cd DocsGPT
        +
        +

        依存関係の追加

        application フォルダ下のrequirements.txt ファイルにlangchain-milvus 依存関係を追加する:

        +
        $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
        +
        +

        環境変数の設定

        docker-compose.yaml ファイルのbackendworker サービスの環境変数にVECTOR_STORE=milvus,MILVUS_URI=...,MILVUS_TOKEN=... を追加します:

        +
          backend:
        +    build: ./application
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +
          worker:
        +    build: ./application
        +    command: celery -A application.app.celery worker -l INFO -B
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +

        MILVUS_URIMILVUS_TOKEN については、フルマネージドのZilliz Cloud(推奨)サービスを使用するか、手動でMilvusサービスを起動することができます。

        +
          +
        • フルマネージドZilliz Cloudサービスの場合:Zilliz Cloudサービスのご利用をお勧めします。Zilliz Cloudの無料トライアルアカウントにサインアップすることができます。その後、パブリックエンドポイントとAPIキーに対応するMILVUS_URIMILVUS_TOKEN

        • +
        • 手動でMilvusサービスを開始する場合:Milvusサービスを手動で立ち上げる場合:Milvus公式ドキュメントに従ってMilvusサーバを立ち上げ、サーバからMILVUS_URIMILVUS_TOKEN を取得します。MILVUS_URIMILVUS_TOKEN はそれぞれhttp://<your_server_ip>:19530<your_username>:<your_password> の形式にしてください。

        • +
        +

        サービスの起動

        実行する:./setup.sh

        +

        その後、http://localhost:5173/。

        +

        UIで遊んだり、文書について質問することができます。

        +

        + + alt text + オルトテキスト

        +

        サービスを停止したい場合は、実行します:

        +
        $ docker-compose down
        +
        +

        詳細やより高度な設定については、DocsGPTの公式ドキュメントを参照してください。

        diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.json b/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.json index 58d1dfd46..f4b365139 100644 --- a/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.json +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.json @@ -1 +1 @@ -{"codeList":["$ git clone https://github.com/zylon-ai/private-gpt\n$ cd private-gpt\n","$ brew install make\n","$ choco install make\n","$ poetry install --extras \"llms-ollama embeddings-ollama vector-stores-milvus ui\"\n","$ ollama serve\n","$ ollama pull llama3.1\n$ ollama pull nomic-embed-text\n","vectorstore:\n database: milvus\n","milvus:\n uri: http://localhost:19530\n collection_name: my_collection\n","PGPT_PROFILES=ollama make run\n"],"headingContent":"Use Milvus in PrivateGPT","anchorList":[{"label":"PrivateGPTでMilvusを使う","href":"Use-Milvus-in-PrivateGPT","type":1,"isActive":false},{"label":"PrivateGPTを実行するための基本要件","href":"Base-requirements-to-run-PrivateGPT","type":2,"isActive":false},{"label":"利用可能なモジュールのインストール","href":"Install-Available-Modules","type":2,"isActive":false},{"label":"Ollamaサービスを開始する","href":"Start-Ollama-service","type":2,"isActive":false},{"label":"Milvus設定の変更","href":"Change-Milvus-Settings","type":2,"isActive":false},{"label":"PrivateGPTの開始","href":"Start-PrivateGPT","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ git clone https://github.com/zylon-ai/private-gpt\n$ cd private-gpt\n","$ brew install make\n","$ choco install make\n","$ poetry install --extras \"llms-ollama embeddings-ollama vector-stores-milvus ui\"\n","$ ollama serve\n","$ ollama pull llama3.1\n$ ollama pull nomic-embed-text\n","vectorstore:\n database: milvus\n","milvus:\n uri: http://localhost:19530\n collection_name: my_collection\n","PGPT_PROFILES=ollama make run\n"],"headingContent":"Use Milvus in PrivateGPT","anchorList":[{"label":"PrivateGPTでMilvusを使う","href":"Use-Milvus-in-PrivateGPT","type":1,"isActive":false},{"label":"PrivateGPTを実行するための基本要件","href":"Base-requirements-to-run-PrivateGPT","type":2,"isActive":false},{"label":"利用可能なモジュールのインストール","href":"Install-Available-Modules","type":2,"isActive":false},{"label":"Ollamaサービスを開始","href":"Start-Ollama-service","type":2,"isActive":false},{"label":"Milvus設定の変更","href":"Change-Milvus-Settings","type":2,"isActive":false},{"label":"PrivateGPTの開始","href":"Start-PrivateGPT","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.md index b9467f35e..e88bd2867 100644 --- a/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_in_private_gpt.md @@ -18,7 +18,7 @@ title: PrivateGPTでMilvusを使う d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        PrivateGPTは、インターネットに接続することなく、100%のプライバシーを確保しながら、大規模言語モデルを使ってユーザーが文書について質問することを可能にする、量産可能なAIプロジェクトです。PrivateGPTは高レベルと低レベルのブロックに分かれたAPIを提供します。また、Gradio UIクライアントや、モデルの一括ダウンロードスクリプトやインジェストスクリプトのような便利なツールも提供します。概念的には、PrivateGPTはRAGパイプラインをラップし、そのプリミティブを公開することで、すぐに使用でき、APIとRAGパイプラインの完全な実装を提供します。

        +

        PrivateGPTは、インターネットに接続することなく、100%のプライバシーを確保しながら、ユーザーが大規模言語モデルを使用して文書に関する質問をすることを可能にする、量産可能なAIプロジェクトです。PrivateGPTは高レベルと低レベルのブロックに分かれたAPIを提供します。また、Gradio UIクライアントや、モデルの一括ダウンロードスクリプトやインジェストスクリプトのような便利なツールも提供します。概念的には、PrivateGPTはRAGパイプラインをラップし、そのプリミティブを公開することで、すぐに使用でき、APIとRAGパイプラインの完全な実装を提供します。

        このチュートリアルでは、PrivateGPTのバックエンドベクターデータベースとしてMilvusを使用する方法を紹介します。

        このチュートリアルは主にPrivateGPT公式インストールガイドを参照しています。もしこのチュートリアルに古い部分があるようでしたら、公式ガイドに従うことを優先し、私たちにissueを作成してください。

        @@ -65,16 +65,18 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        PrivateGPTではセットアップのカスタマイズが可能です。いくつかのモジュール設定を指定する必要があります。このチュートリアルでは、以下のモジュールを使用します:

        +

        PrivateGPTでは、LLM、Embeddings、Vector Stores、UIなど、いくつかのモジュールのセットアップをカスタマイズすることができます。

        +

        このチュートリアルでは、以下のモジュールを使用します:

        • LLM: Ollama
        • -
        • エンベッディング:Ollama
        • -
        • ベクトル・ストア:Milvus
        • +
        • エンベッディングOllama
        • +
        • ベクトル・ストアMilvus
        • UI:Gradio
        +

        必要なモジュールの依存関係をインストールするために詩を使用するには、次のコマンドを実行します:

        $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
         
        -

        Ollamaサービスを開始する

        ollama.aiにアクセスし、指示に従ってOllamaをあなたのマシンにインストールしてください。

        -

        インストールが終わったら、Ollamaのデスクトップアプリが終了していることを確認する。

        +

        ollama.aiにアクセスし、指示に従ってあなたのマシンにOllamaをインストールしてください。

        +

        インストールが終わったら、Ollamaデスクトップアプリが終了していることを確認してください。

        Ollamaサービスを起動します(ローカル推論サーバーが起動し、LLMとEmbeddingsの両方に対応します):

        $ ollama serve
         
        -

        使用するモデルをインストールします。デフォルトのsettings-ollama.yaml はユーザーllama3.1 8b LLM (~4GB)とnomic-embed-text Embeddings (~275MB)に設定されています。

        -

        デフォルトでは、PrivateGPTは必要に応じて自動的にモデルをプルします。この動作はollama.autopull_models プロパティを変更することで変更できます。

        +

        使用するモデルをインストールします。デフォルトのsettings-ollama.yaml はユーザーllama3.1 8b LLM (~4GB) とnomic-embed-text Embeddings (~275MB) に設定されています。

        +

        デフォルトでは、PrivateGPTは必要に応じて自動的にモデルをプルします。この動作は、ollama.autopull_models プロパティを変更することで変更できます。

        いずれにせよ、手動でモデルをプルしたい場合は、以下のコマンドを実行してください:

        $ ollama pull llama3.1
         $ ollama pull nomic-embed-text
        @@ -131,8 +133,8 @@ $ ollama pull nomic-embed-text
         フィールド オプション説明
         
         
        -uriデフォルトではローカルファイルとして "local_data/private_gpt/milvus/milvus_local.db "が設定されています。dockerやk8s上のよりパフォーマンスの高いMilvusサーバ(例:http://localhost:19530)をuriとして設定することもできます。Milvusクラウドを利用する場合は、uriとtokenをMilvusクラウドのEndpointとApi keyに合わせます。
        -トークンdockerやk8s上のMilvusサーバー、またはZilliz Cloudのapiキーとペア。
        +uriデフォルトではローカルファイルとして "local_data/private_gpt/milvus/milvus_local.db "が設定されています。dockerやk8s上のよりパフォーマンスの高いMilvusサーバ(例:http://localhost:19530)をuriとして設定することもできます。Zilliz Cloudを利用する場合は、uriとtokenをZilliz CloudのPublic EndpointとAPI keyに合わせます。
        +トークンdockerやk8s上のMilvusサーバー、またはZilliz CloudのAPIキーとペア。
         コレクション名コレクション名。デフォルトは "milvus_db"。
         上書きコレクション内のデータが存在する場合、上書きする。
         
        @@ -152,7 +154,7 @@ $ ollama pull nomic-embed-text
                   d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
                 >
               
        -    

        すべての設定が完了したら、gradio UIでPrivateGPTを実行できます。

        +

        すべての設定が完了したら、Gradio UIでPrivateGPTを実行できます。

        PGPT_PROFILES=ollama make run
         

        UIはhttp://0.0.0.0:8001

        @@ -162,4 +164,5 @@ $ ollama pull nomic-embed-text

        -

        UIで遊んだり、ドキュメントについて質問することができます。

        +

        UIで遊んだり、文書について質問したりすることができる。

        +

        詳細はPrivateGPTの公式ドキュメントを参照してください。

        diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..b184baf13 --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"SambaNovaでMilvusを使う","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"リポジトリをクローンする","href":"Clone-the-repository","type":2,"isActive":false},{"label":"ベクターストアのタイプを変更する","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"依存関係のインストール","href":"Install-dependencies","type":2,"isActive":false},{"label":"アプリケーションの起動","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..dfd5cc4fb --- /dev/null +++ b/localization/v2.4.x/site/ja/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,134 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + このチュートリアルでは、RAG(Retrieval-Augmented + Generation)のような、企業のプライベート文書に基づいた検索と回答のためのエンタープライズ知識検索システムを構築するために、SambaNova AI + Starter KitsのMilvusインテグレーションを活用する。 +title: SambaNovaでMilvusを使う +--- +

        SambaNovaでMilvusを使う

        SambaNovaは、高度なAIとディープラーニング機能の展開を加速する革新的なAIテクノロジープラットフォームです。SambaNovaは企業向けに設計されており、生成的なAIを活用してパフォーマンスと効率を向上させることができます。SambaNova SuiteやDataScaleのような最先端のソリューションを提供することで、このプラットフォームは、企業がデータから価値ある洞察を引き出すことを可能にし、業務改善を促進し、AIの展望における新たな機会を育成します。

        +

        SambaNova AIスターターキットは、開発者や企業がSambaNovaでAI駆動型アプリケーションを展開するのを支援するために設計されたオープンソースリソースのコレクションです。これらのキットは、様々なAIユースケースの実装を容易にする実践的な例やガイドを提供し、ユーザーがSambaNovaの先進技術を活用することを容易にします。

        +

        このチュートリアルではSambaNova AIスターターキットのMilvusインテグレーションを活用し、RAG(Retrieval-Augmented Generation)に似たエンタープライズ知識検索システムを構築し、企業のプライベートドキュメントに基づいた検索と回答を行います。

        +
        +

        このチュートリアルは主にSambaNova AI Starter Kitsの公式ガイドを参照しています。もし、このチュートリアルに古い部分があるようでしたら、オフィシャルガイドに従うことを優先し、私たちに問題を作成してください。

        +
        +

        前提条件

        Python >= 3.10, < 3.12の使用を推奨します。

        +

        SambaNova Cloudにアクセスし、SambaNova APIキーを取得する。

        +

        リポジトリをクローンする

        $ git clone https://github.com/sambanova/ai-starter-kit.git
        +$ d ai-starter-kit/enterprise_knowledge_retriever
        +
        +

        ベクターストアのタイプを変更する

        create_vector_store()db_type='milvus'src/document_retrieval.pyload_vdb() 関数を設定して、ベクターストアを変更する。

        +
        ...
        +vectorstore = self.vectordb.create_vector_store(
        +    ..., db_type='milvus'
        +)
        +...
        +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
        +
        +

        依存関係のインストール

        以下のコマンドを実行し、必要な依存関係をインストールする:

        +
        python3 -m venv enterprise_knowledge_env
        +source enterprise_knowledge_env/bin/activate
        +pip install -r requirements.txt
        +
        +

        アプリケーションの起動

        以下のコマンドでアプリケーションを起動します:

        +
        $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
        +
        +

        その後、ブラウザにユーザーインターフェースが表示される:http://localhost:8501/

        +

        + + + + +

        +

        UI に SambaNova API キーを設定した後、UI を操作したり、ドキュメントに関する質問をすることができます。

        +

        詳しくはSambaNova AI Starter Kitsのエンタープライズ知識検索公式ドキュメントをご参照ください。

        diff --git a/localization/v2.4.x/site/ja/menuStructure/ja.json b/localization/v2.4.x/site/ja/menuStructure/ja.json index 36f477287..cf5a6e7f2 100644 --- a/localization/v2.4.x/site/ja/menuStructure/ja.json +++ b/localization/v2.4.x/site/ja/menuStructure/ja.json @@ -1,6 +1,6 @@ [ { - "label": "About Milvus", + "label": "Milvusについて", "id": "about", "isMenu": true, "order": 0, @@ -305,13 +305,7 @@ "children": [] }, { - "label": "ユーザーと役割", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, - { - "label": "インメモリ・レプリカ", + "label": "インメモリーレプリカ", "id": "replica.md", "order": 11, "children": [] @@ -367,7 +361,7 @@ "children": [] }, { - "label": "GPUによるインデックス", + "label": "GPU付きインデックス", "id": "index-with-gpu.md", "order": 2, "children": [] @@ -641,7 +635,7 @@ ] }, { - "label": "Milvusマイグレーション", + "label": "Milvus移住", "id": "milvus_migration", "isMenu": true, "order": 5, @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "ユーザー、権限、役割", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "RBACを有効にする", "id": "rbac.md", @@ -1244,7 +1244,7 @@ "children": [] }, { - "label": "埋め込みモデル", + "label": "モデルの埋め込み", "id": "integrate-embeddings-models", "order": 1, "children": [ @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "ドックスGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "サンバ・ノヴァ", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "プライベートGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "メム0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "ナレッジ・テーブル", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "マトリョーシカ埋め込みによる漏斗探索", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "もっと見る", "id": "explore-more", diff --git a/localization/v2.4.x/site/ja/reference/disk_index.md b/localization/v2.4.x/site/ja/reference/disk_index.md index 17b6e2f55..0c7527c6c 100644 --- a/localization/v2.4.x/site/ja/reference/disk_index.md +++ b/localization/v2.4.x/site/ja/reference/disk_index.md @@ -130,7 +130,7 @@ DiskIndex: MaxDegreeVamanaグラフの最大次数。
        値を大きくすると想起率が高くなるが、インデックスのサイズと構築時間が増加する。[1, 512]56 -SearchListSize候補リストのサイズ。
        値を大きくするとインデックス構築に費やす時間が長くなるが、想起率は高くなる。
        インデックス構築時間を短縮する必要がない限り、MaxDegree より小さい値に設定する。[1, int32_max]100 +SearchListSize候補リストのサイズ。
        値が大きいほどインデックス構築にかかる時間が長くなるが、高い想起率が得られる。
        インデックス構築時間を短縮する必要がない限り、MaxDegree より小さい値に設定する。[1, int32_max]100 PQCodeBugetGBRatioPQコードのサイズ制限。
        値を大きくすると想起率が高くなるが、メモリ使用量が増加する。(0.0, 0.25]0.125 SearchCacheBudgetGBRatio生データに対するキャッシュされたノード番号の比率。
        値を大きくするとインデックス構築性能が向上するが、メモリ使用量は増加する。[0.0, 0.3)0.10 BeamWidthRatio検索反復あたりの最大 IO リクエスト数と CPU 数との比率。[1, max(128 / CPU数, 16)] を指定する。4.0 @@ -154,6 +154,6 @@ DiskIndex:
        • io_setup() failed; returned -11, errno=11:Resource temporarily unavailable エラーの対処法は?

          Linuxカーネルは非同期ノンブロッキングI/O(Asynchronous non-blocking I/O: AIO)機能を提供しており、プロセスが複数のI/O操作を同時に開始しても、そのいずれかが完了するのを待つ必要はありません。これは、処理とI/Oが重複するアプリケーションのパフォーマンスを向上させるのに役立ちます。

          -

          この性能は、procファイルシステム内の/proc/sys/fs/aio-max-nr 仮想ファイルを使用して調整できる。aio-max-nr パラメーターは、許容される同時リクエストの最大数を決定する。

          +

          この性能は、proc ファイルシステム内の/proc/sys/fs/aio-max-nr 仮想ファイルを使用して調整できる。aio-max-nr パラメーターは、許容される同時リクエストの最大数を決定する。

          aio-max-nr のデフォルトは65535 であるが、10485760 に設定することもできる。

        diff --git a/localization/v2.4.x/site/ja/reference/knowhere.json b/localization/v2.4.x/site/ja/reference/knowhere.json index ccebc5219..9c9dd7204 100644 --- a/localization/v2.4.x/site/ja/reference/knowhere.json +++ b/localization/v2.4.x/site/ja/reference/knowhere.json @@ -1 +1 @@ -{"codeList":[],"headingContent":"","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"MilvusアーキテクチャにおけるKnowhere","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Knowhereの利点","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Knowhereのコード構造","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Knowhere へのインデックスの追加","href":"Adding-indexes-to-Knowhere","type":2,"isActive":false},{"label":"次のステップ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":[],"headingContent":"Knowhere","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"MilvusアーキテクチャにおけるKnowhere","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Knowhereの利点","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Knowhereのコード構造","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Knowhere へのインデックスの追加","href":"Adding-indices-to-Knowhere","type":2,"isActive":false},{"label":"次のステップ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/reference/knowhere.md b/localization/v2.4.x/site/ja/reference/knowhere.md index b50b8dc5b..f8b48b4cf 100644 --- a/localization/v2.4.x/site/ja/reference/knowhere.md +++ b/localization/v2.4.x/site/ja/reference/knowhere.md @@ -1,7 +1,7 @@ --- id: knowhere.md -summary: ミルヴァスのノウウェアについて -title: ノーウェア +summary: MilvusでKnowhereについて学ぶ。 +title: Knowhere ---

        Knowhere

        このトピックでは、Milvusのコアとなるベクトル実行エンジンKnowhereについて紹介します。

        +

        Milvusのコアとなるベクトル実行エンジンKnowhereについて紹介します。

        概要

        KnowhereはMilvusの中核となるベクトル実行エンジンで、FaissHnswlibAnnoyを含む複数のベクトル類似性検索ライブラリを内蔵しています。また、Knowhereはヘテロジニアスコンピューティングをサポートするように設計されています。インデックス構築と検索要求をどのハードウェア(CPUまたはGPU)で実行するかを制御します。これがKnowhereの名前の由来である。将来のリリースでは、DPUやTPUを含む、より多くの種類のハードウェアがサポートされる予定です。

        +

        KnowhereはMilvusの中核となるベクトル実行エンジンで、FaissHnswlibAnnoyを含む複数のベクトル類似性検索ライブラリを内蔵しています。また、Knowhereはヘテロジニアスコンピューティングをサポートするように設計されています。インデックス構築と検索要求をどのハードウェア(CPUまたはGPU)で実行するかを制御する。これがKnowhereの名前の由来である。将来のリリースでは、DPUやTPUを含む、より多くの種類のハードウェアがサポートされる予定です。

        MilvusアーキテクチャにおけるKnowhere

        以下はKnowhereがFaissより優れている点です。

        BitsetViewのサポート

        Milvusは "ソフト削除 "を実現するためにビットセット機構を導入しています。ソフト削除されたベクトルはデータベースに存在しますが、ベクトルの類似性検索やクエリの際に計算されることはありません。

        -

        ビットセットの各ビットはインデックス付きベクトルに対応する。あるベクトルがビットセットで "1 "とマークされた場合、そのベクトルはソフト削除され、ベクトル検索には関与しないことを意味する。bitset パラメータは、CPU および GPU インデックスを含め、Knowhere で公開されているすべての Faiss インデックス照会 API に適用されます。

        +

        ビットセットの各ビットはインデックス付きベクトルに対応する。あるベクトルがビットセットで "1 "とマークされた場合、そのベクトルはソフト削除され、ベクトル検索には関与しないことを意味する。bitset パラメータは、CPU および GPU インデックスを含む、Knowhere で公開されているすべての Faiss インデックス照会 API に適用されます。

        bitset メカニズムの詳細については、bitset を参照してください。

        バイナリ・ベクトルのインデックス作成における複数の類似性メトリクスのサポート

        KnowhereはハミングJaccardTanimotoSuperstructureSubstructureをサポートしています。Jaccard と Tanimoto は 2 つのサンプル・セット間の類似性を測定するために使用でき、Superstructure と Substructure は化学構造の類似性を測定するために使用できます。

        -

        AVX512命令セットのサポート

        FaissがすでにサポートしているAArch64SSE4.2AVX2以外に、KnowhereはAVX512もサポートしています。AVX512はAVX2と比較して、インデックス構築とクエリの性能を20~30%向上させることができます。

        +

        AVX512命令セットのサポート

        FaissがすでにサポートしているAArch64SSE4.2AVX2以外に、KnowhereはAVX512もサポートしています。AVX512はAVX2と比較してインデックス構築とクエリの性能を20~30%向上させることができます。

        SIMD命令の自動選択

        Knowhereは、あらゆるCPUプロセッサ(オンプレミスとクラウドの両方のプラットフォーム)で適切なSIMD命令(SIMD SSE、AVX、AVX2、AVX512など)を自動的に呼び出すことをサポートしているため、ユーザーはコンパイル時にSIMDフラグ("-msse4 "など)を手動で指定する必要がありません。

        KnowhereはFaissのコードベースをリファクタリングして構築されています。SIMDアクセラレーションに依存する一般的な関数(類似度計算など)はファクタアウトされます。次に、各関数について4つのバージョン(すなわち、SSE、AVX、AVX2、AVX512)が実装され、それぞれが別々のソースファイルに入れられます。その後、ソースファイルは対応する SIMD フラグで個別にコンパイルされます。したがって、Knowhere は実行時に現在の CPU フラグに基づいて最適な SIMD 命令を自動的に選択し、フッキングを使用して適切な関数ポインタをリンクします。

        -

        その他の性能最適化

        Knowhereのパフォーマンス最適化については、「Milvus: A Purpose-Built Vector Data Management System」を参照してください。

        +

        その他の性能最適化

        Knowhereのパフォーマンス最適化については、Milvus: A Purpose-Built Vector Data Management Systemを参照してください。

        Knowhereのコード構造

        Milvusの計算には主にベクトル演算とスカラー演算が含まれます。Knowhereはベクトル・インデックスの操作のみを処理します。

        -

        インデックスは元のベクトルデータから独立したデータ構造です。一般的に、インデックスの作成には、インデックスの作成、データの学習、データの挿入、インデックスの構築という4つのステップが必要です。AIアプリケーションの中には、データセットの学習とベクトル探索が分離されているものもある。データセットのデータはまず学習され、類似性検索のためにMilvusのようなベクトルデータベースに挿入される。例えば、オープンデータセットsift1Mとsift1Bは、学習用データとテスト用データを区別している。

        +

        インデックスは元のベクトルデータから独立したデータ構造です。一般的に、インデックスの作成には、インデックスの作成、データの学習、データの挿入、インデックスの構築という4つのステップが必要です。AIアプリケーションの中には、データセットの学習とベクトル探索が分離されているものもある。データセットのデータはまず学習され、類似検索のためにmilvusのようなベクトルデータベースに挿入される。例えば、オープンデータセットsift1Mとsift1Bは、学習用データとテスト用データを区別している。

        しかし、Knowhereでは学習用データと検索用データは同じです。Knowhereはセグメント内のすべてのデータを学習し、学習済みデータを挿入してインデックスを作成します。

        DataObj基底クラス

        DataObj Size() は の唯一の仮想メソッドです。Indexクラスは 、"size_"というフィールドを継承しています。また、Index クラスには と の 2 つの仮想メソッドがあります。 から派生した クラスは、すべてのベクトル・インデックスの仮想基底クラスです。 は、 、 、 、 などのメソッドを提供します。DataObj DataObj Serialize() Load() Index VecIndex VecIndex Train() Query() GetStatistics() ClearStatistics()

        @@ -115,19 +115,19 @@ title: ノーウェア IDMAP

        厳密に言えば、IDMAP はインデックスではなく、ブルートフォース検索に使用されます。ベクトルがデータベースに挿入される際、データ学習もインデックス構築も必要ない。検索は挿入されたベクトル・データに対して直接行われる。

        しかし、コードの一貫性を保つために、IDMAPVecIndex クラスを継承し、その仮想インターフェースもすべて継承している。IDMAP の使い方は他のインデックスと同じである。

        -

        IVFインデックス

        +

        IVFインデックス

        IVF IVF

        -

        IVF(転置ファイル)インデックスは、最も頻繁に使用されるインデックスです。IVF クラスはVecIndexFaissBaseIndex から派生し、さらにIVFSQIVFPQ へと拡張されます。GPUIVFGPUIndexIVF から派生します。そしてGPUIVF はさらにGPUIVFSQGPUIVFPQ に拡張される。

        +

        IVF(転置ファイル)インデックスは最も頻繁に使用される。IVF クラスはVecIndexFaissBaseIndex から派生し、さらにIVFSQIVFPQ へと拡張される。GPUIVFGPUIndexIVF から派生する。そしてGPUIVF はさらにGPUIVFSQGPUIVFPQ に拡張される。

        IVFSQHybrid は、独自に開発したハイブリッド・インデックスである。粗い量子化器はGPUで実行され、バケット内の検索はCPUで実行される。このタイプのインデックスは、GPUの計算能力を活用することで、CPUとGPU間のメモリコピーの発生を減らすことができる。 は、 と同じ想起率を持つが、より優れた性能を持つ。IVFSQHybrid GPUIVFSQ

        BinaryIDMAPBinaryIVFFaissBaseBinaryIndexVecIndex から派生したものである。

        -

        サードパーティ・インデックス

        +

        サードパーティ・インデックス

        - third-party indexes + third-party indices サード・パーティ・インデックス

        -

        現在、Faiss以外のサードパーティインデックスは、ツリーベース・インデックスAnnoy とグラフベース・インデックスHNSW の2種類のみがサポートされている。こ れ ら 2 種類の一般的で頻繁に使用 さ れ る サ ド パーテ ィ イ ンデ ッ ク ス は、 いずれ もVecIndex から派生 し た も のです。

        -

        Knowhere へのインデックスの追加

        Knowhere に新しいインデックスを追加する場合、まず既存のインデックスを参照します:

          -
        • 量子化ベースのインデックスを追加するには、IVF_FLAT を参照してください。

        • -
        • グラフベースのインデックスを追加するには、HNSW を参照してください。

        • +
        • 量子化ベースのインデックスを追加するには、IVF_FLAT を参照。

        • +
        • グラフベースのインデックスを追加するには、HNSW を参照。

        • ツリーベースのインデックスを追加するには、Annoy を参照してください。

        既存のインデックスを参照した後、以下の手順に従って新しいインデックスを Knowhere に追加できます。

          -
        1. IndexEnum に新 し い イ ンデ ッ ク ス の名前を追加 し ます。デー タ 型は文字列です。

        2. +
        3. IndexEnum に新しいインデックスの名前を追加します。デー タ 型は文字列です。

        4. フ ァ イ ルConfAdapter.cpp に、 新 し い イ ンデ ッ ク ス にデー タ 検証チ ェ ッ ク を追加 し ます。検証チェックは、主にデータ学習とクエリのパラメータを検証するためのものです。

        5. 新しいインデックス用に新しいファイルを作成します。新しいインデックスの基底クラスには、VecIndexVecIndex の必要な仮想インタフェースを含める。

        6. 新しいインデックスのインデックス構築ロジックをVecIndexFactory::CreateVecIndex() に追加する。

        7. @@ -171,7 +171,7 @@ title: ノーウェア d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

          KnowhereがMilvusでどのように動作するかを学んだ後は、次のことも行ってください:

          +

          MilvusでKnowhereがどのように動作するのかを学んだ後は、次のことを行ってください:

          • Milvusがサポートする様々なタイプのインデックスについて学ぶ。

          • ビットセットメカニズムについて学ぶ。

          • diff --git a/localization/v2.4.x/site/ja/reference/schema.json b/localization/v2.4.x/site/ja/reference/schema.json index 6382336d3..9a3f810b7 100644 --- a/localization/v2.4.x/site/ja/reference/schema.json +++ b/localization/v2.4.x/site/ja/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"スキーマの管理","href":"Manage-Schema","type":1,"isActive":false},{"label":"フィールドスキーマ","href":"Field-schema","type":2,"isActive":false},{"label":"コレクションスキーマ","href":"Collection-schema","type":2,"isActive":false},{"label":"次のページ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"スキーマの管理","href":"Manage-Schema","type":1,"isActive":false},{"label":"フィールドスキーマ","href":"Field-schema","type":2,"isActive":false},{"label":"コレクションスキーマ","href":"Collection-schema","type":2,"isActive":false},{"label":"次のページ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/reference/schema.md b/localization/v2.4.x/site/ja/reference/schema.md index 8b135ca52..4585ca1d0 100644 --- a/localization/v2.4.x/site/ja/reference/schema.md +++ b/localization/v2.4.x/site/ja/reference/schema.md @@ -39,7 +39,10 @@ title: スキーマの管理

            フィールドスキーマプロパティ

            - + + + + @@ -75,12 +78,12 @@ title: スキーマの管理 - + - +
            プロパティ説明 Note
            プロパティ説明備考
            dim ベクトルの次元データ型:
            密なベクトル・フィールドでは必須。疎なベクトル・フィールドでは省略。
            データ型:
            密なベクトル・フィールドでは必須。疎なベクトル場では省略。
            is_partition_key このフィールドがパーティション・キー・フィールドであるかどうか。データ型:データ型:Boolean (true またはfalse)。データ型:Boolean (true またはfalse)。
            @@ -124,7 +127,7 @@ fields = [
          • JSON:JSON
          • 配列:配列
          -

          複合データ型としてのJSONが利用できます。JSONフィールドはキーと値のペアで構成される。各キーは文字列で、値は数値、文字列、ブーリアン値、配列、リストのいずれかです。詳細はJSON: a new data typeを参照。

          +

          複合データ型としてのJSONが利用できます。JSONフィールドはキーと値のペアで構成されます。各キーは文字列で、値は数値、文字列、ブーリアン値、配列、リストのいずれかです。詳細はJSON: a new data typeを参照。

        8. ベクター・フィールドのサポート

          • BINARY_VECTOR:バイナリ・データを0と1のシーケンスとして格納し、画像処理や情報検索でコンパクトな特徴表現に使用される。
          • @@ -154,7 +157,10 @@ fields = [

            コレクションスキーマのプロパティ

            - + + + + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

            スキーマを指定してコレクションを作成します:

            -
            from pymilvus import Collection
            +
            from pymilvus import Collection,connections
            +conn = connections.connect(host="127.0.0.1", port=19530)
             collection_name1 = "tutorial_1"
             collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
             
            diff --git a/localization/v2.4.x/site/ja/reference/users_and_roles.json b/localization/v2.4.x/site/ja/reference/users_and_roles.json index 31e0c0c58..e7494fe84 100644 --- a/localization/v2.4.x/site/ja/reference/users_and_roles.json +++ b/localization/v2.4.x/site/ja/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"ユーザとロール","href":"Users-and-Roles","type":1,"isActive":false},{"label":"主要概念","href":"Key-concepts","type":2,"isActive":false},{"label":"例権限の付与","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"デフォルトのユーザとロール","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"オブジェクト・タイプと権限のリスト","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"次のページ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"ユーザ、権限、ロール","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"主要概念","href":"Key-concepts","type":2,"isActive":false},{"label":"例権限の付与","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"デフォルトのユーザとロール","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"オブジェクト・タイプと権限のリスト","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"次のページ","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/reference/users_and_roles.md b/localization/v2.4.x/site/ja/reference/users_and_roles.md index 78e01ddb2..c94b67b8e 100644 --- a/localization/v2.4.x/site/ja/reference/users_and_roles.md +++ b/localization/v2.4.x/site/ja/reference/users_and_roles.md @@ -2,9 +2,9 @@ id: users_and_roles.md related_key: 'users, roles' summary: ロール・ベース・アクセス・コントロール(RBAC)におけるユーザー、ロール、オブジェクト、権限の定義について学びます。 -title: ユーザーと役割 +title: ユーザ、権限、ロール --- -

            ユーザとロール

            このトピックでは、Milvusにおけるロールベースアクセスコントロール(RBAC)の概要と、ユーザ、ロール、オブジェクト、権限の定義と関係について説明します。

            -

            次の図はオブジェクト、権限、ロール、ユーザの関係を示しています。

            +

            このトピックでは、Milvusにおけるロールベースアクセスコントロール(RBAC)の概要を説明し、ユーザ、ロール、オブジェクト、権限の定義と関係について詳しく説明します。

            +

            以下の図にオブジェクト、権限、ロール、ユーザの関係を示します。

            users_and_roles @@ -40,7 +40,7 @@ title: ユーザーと役割 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

            Milvusリソースへのアクセス制御を管理するためには、RBACの主要な構成要素であるオブジェクトタイプ、オブジェクト名、ユーザ、ロール、権限を理解することが重要です。

            +

            Milvusリソースへのアクセスコントロールを管理するためには、RBACの主要な構成要素であるオブジェクトタイプ、オブジェクト名、ユーザ、ロール、権限を理解することが重要です。

            • オブジェクトタイプ: 特権が割り当てられるオブジェクトのカテゴリ。オブジェクト タイプには次のようなものがあります:

                @@ -54,7 +54,7 @@ title: ユーザーと役割
              • オブジェクト・タイプがCollection の場合、オブジェクト名はコレクション名です。
              • オブジェクト・タイプがUser の場合、オブジェクト名はデータベース・ユーザの名前です。
            • -
            • ユーザ: Milvus と相互作用する個人またはアプリケーションで、ユーザ名と対応するパスワードで構成される。

            • +
            • ユーザー(User): Milvusと相互作用する個人またはアプリケーションで、ユーザー名と対応するパスワードから構成される。

            • 特権:実行可能なアクションとアクセス可能なリソースを定義する。権限はユーザに直接付与されるのではなく、ロールに割り当てられる。

            • ロール:ユーザーが特定のオブジェクトに対して持つ権限のセットを定義します。ロールがユーザにバインドされると、ユーザはそのロールに付与されたすべての特権を継承します。

            @@ -123,7 +123,7 @@ client.grantPrivilege(grantPrivilegeReq); >

            Milvus はデフォルトでroot ユーザーをデフォルトパスワードMilvus で作成します。root ユーザーにはadmin 権限が付与されます。これは、このroot ユーザーがすべてのリソースにアクセスでき、すべてのアクションを実行できることを意味します。

            -

            ユーザがpublic ロールに関連している場合、そのユーザには以下の権限が与えられます:

            +

            ユーザがpublic ロールと関連付けられている場合、そのユーザには以下の権限が与えられます:

            • DescribeCollection
            • ShowCollections
            • @@ -172,7 +172,7 @@ client.grantPrivilege(grantPrivilegeReq);
            - + diff --git a/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..c7b315c7e --- /dev/null +++ b/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"マトリョーシカ埋め込みによる漏斗探索","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"マトリョーシカ埋め込みモデルのロード","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"データセットの読み込み、項目の埋め込み、ベクトルデータベースの構築","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"漏斗探索の実行","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"漏斗探索と通常探索の比較","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"Ferris Bueller's Day Offのファネルサーチリコール失敗の調査","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"順序は重要か?接頭辞埋め込みと接尾辞埋め込み。","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"まとめ","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..a60c6bc70 --- /dev/null +++ b/localization/v2.4.x/site/ja/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,567 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + このノートブックでは、Milvusを使ったマトリョーシカ埋め込みを意味検索に使う方法を検討します。ファネル検索と呼ばれるアルゴリズムにより、埋め込み次元の小さなサブセットで類似検索を行うことができます。 +title: マトリョーシカ埋め込みによる漏斗探索 +--- +

            マトリョーシカ埋め込みによる漏斗探索

            効率的なベクトル検索システムを構築する際の重要な課題の1つは、許容可能なレイテンシとリコールを維持しながらストレージコストを管理することです。最新の埋め込みモデルは数百から数千次元のベクトルを出力するため、生のベクトルとインデックスに多大なストレージと計算オーバーヘッドが発生します。

            +

            従来は、インデックスを構築する直前に量子化や次元削減を行うことで、ストレージの容量を削減していました。例えば、積量子化(PQ)を使って精度を下げたり、主成分分析(PCA)を使って次元数を下げることで、ストレージを節約することができます。これらの方法はベクトル集合全体を分析し、ベクトル間の意味的関係を維持したまま、よりコンパクトなものを見つける。

            +

            効果的ではあるが、これらの標準的なアプローチは精度や次元数を一度だけ、しかも単一のスケールで削減する。しかし、複数の詳細なレイヤーを同時に維持し、ピラミッドのように精度を高めていくことができるとしたらどうだろう?

            +

            マトリョーシカ埋め込みが登場する。ロシアの入れ子人形にちなんで名付けられたこの巧妙な構造は(図を参照)、1つのベクトル内に複数のスケールの表現を埋め込む。従来の後処理手法とは異なり、マトリョーシカ埋め込みは最初の学習過程でこのマルチスケール構造を学習する。その結果は驚くべきもので、完全な埋め込みが入力セマンティクスを捉えるだけでなく、入れ子になった各サブセットの接頭辞(前半、4分の1など)が、詳細ではないものの、首尾一貫した表現を提供します。

            +
            +

            このノートブックでは、Milvusを使ったマトリョーシカ埋め込みを意味検索に使う方法を検討する。ファネル検索」と呼ばれるアルゴリズムにより、埋め込み次元の小さなサブセットで類似検索を行うことができます。

            +
            import functools
            +
            +from datasets import load_dataset
            +import numpy as np
            +import pandas as pd
            +import pymilvus
            +from pymilvus import MilvusClient
            +from pymilvus import FieldSchema, CollectionSchema, DataType
            +from sentence_transformers import SentenceTransformer
            +import torch
            +import torch.nn.functional as F
            +from tqdm import tqdm
            +
            +

            マトリョーシカ埋め込みモデルのロード

            のような標準的な埋め込みモデルを使う代わりに、Nomic社のモデルを使います。 sentence-transformers/all-MiniLM-L12-v2のような標準的な埋め込みモデルを使う代わりに,マトリョーシカ埋め込みを生成するために特別に訓練されたNomicのモデルを使います.

            +
            model = SentenceTransformer(
            +    # Remove 'device='mps' if running on non-Mac device
            +    "nomic-ai/nomic-embed-text-v1.5",
            +    trust_remote_code=True,
            +    device="mps",
            +)
            +
            +
            <All keys matched successfully>
            +
            +

            データセットの読み込み、項目の埋め込み、ベクトルデータベースの構築

            以下のコードは、ドキュメントページ"Movie Search with Sentence Transformers and Milvus "のコードを改変したものですまず、HuggingFaceからデータセットをロードする。このデータセットには約35kのエントリーが含まれており、それぞれがウィキペディアの記事を持つ映画に対応している。この例では、TitlePlotSummary フィールドを使用する。

            +
            ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
            +print(ds)
            +
            +
            Dataset({
            +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
            +    num_rows: 34886
            +})
            +
            +

            次に、milvus Liteデータベースに接続し、データスキーマを指定し、このスキーマでコレクションを作成する。非正規化埋め込みと埋め込みの最初の6番目は別々のフィールドに格納する。その理由は、マトリョーシカ埋め込みの最初の1/6は類似検索のために必要であり、残りの5/6は再ランク付けと検索結果の改善のために必要だからです。

            +
            embedding_dim = 768
            +search_dim = 128
            +collection_name = "movie_embeddings"
            +
            +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
            +
            +fields = [
            +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
            +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
            +    # First sixth of unnormalized embedding vector
            +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
            +    # Entire unnormalized embedding vector
            +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
            +]
            +
            +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
            +client.create_collection(collection_name=collection_name, schema=schema)
            +
            +

            Milvusは現在、埋込みデータの部分集合を検索することをサポートしていないので、埋込みデータを2つの部分に分割します:頭部はインデックスを付け検索するベクトルの初期部分集合を表し、尾部は残りの部分です。このモデルは余弦距離類似検索のために学習されたものなので、頭の埋め込みを正規化します。しかし、後でより大きな部分集合の類似度を計算するために、先頭の埋込みのノルムを保存する必要があります。

            +

            埋込みの最初の1/6を検索するためには、head_embedding フィールド上のベクトル検索インデックスを作成する必要があります。後ほど、「ファネル検索」と通常のベクトル検索の結果を比較しますので、完全な埋め込みに対する検索インデックスも作成します。

            +

            重要なのは、IP の距離尺度ではなく、COSINE の距離尺度を使うことです。そうしないと、埋め込みノルムを追跡する必要があり、実装が複雑になるからです(これは、ファネル検索のアルゴリズムが説明されれば、より理解できるようになるでしょう)。

            +
            index_params = client.prepare_index_params()
            +index_params.add_index(
            +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
            +)
            +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
            +client.create_index(collection_name, index_params)
            +
            +

            最後に、全35k映画のプロット要約をエンコードし、対応する埋め込みをデータベースに入力する。

            +
            for batch in tqdm(ds.batch(batch_size=512)):
            +    # This particular model requires us to prefix 'search_document:' to stored entities
            +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
            +
            +    # Output of embedding model is unnormalized
            +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
            +    head_embeddings = embeddings[:, :search_dim]
            +
            +    data = [
            +        {
            +            "title": title,
            +            "head_embedding": head.cpu().numpy(),
            +            "embedding": embedding.cpu().numpy(),
            +        }
            +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
            +    ]
            +    res = client.insert(collection_name=collection_name, data=data)
            +
            +
            100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
            +
            +

            それでは、マトリョーシカ埋め込み次元の最初の1/6を使って "漏斗検索 "を実行してみましょう。検索用に3つの映画を考えており、データベースへのクエリ用に私自身のプロット要約を作成した。クエリを埋め込み、head_embedding フィールドでベクトル検索を行い、128の結果候補を取り出す。

            +
            queries = [
            +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
            +    "A teenager fakes illness to get off school and have adventures with two friends.",
            +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
            +]
            +
            +
            +# Search the database based on input text
            +def embed_search(data):
            +    embeds = model.encode(data)
            +    return [x for x in embeds]
            +
            +
            +# This particular model requires us to prefix 'search_query:' to queries
            +instruct_queries = ["search_query: " + q.strip() for q in queries]
            +search_data = embed_search(instruct_queries)
            +
            +# Normalize head embeddings
            +head_search = [x[:search_dim] for x in search_data]
            +
            +# Perform standard vector search on first sixth of embedding dimensions
            +res = client.search(
            +    collection_name=collection_name,
            +    data=head_search,
            +    anns_field="head_embedding",
            +    limit=128,
            +    output_fields=["title", "head_embedding", "embedding"],
            +)
            +
            +

            この時点では、より小さなベクトル空間上で検索を実行したため、全空間上で検索するよりも待ち時間が短縮され、インデックスのストレージ要件も軽減されている可能性が高い。各クエリの上位5件を調べてみましょう:

            +
            for query, hits in zip(queries, res):
            +    rows = [x["entity"] for x in hits][:5]
            +
            +    print("Query:", query)
            +    print("Results:")
            +    for row in rows:
            +        print(row["title"].strip())
            +    print()
            +
            +
            Query: An archaeologist searches for ancient artifacts while fighting Nazis.
            +Results:
            +"Pimpernel" Smith
            +Black Hunters
            +The Passage
            +Counterblast
            +Dominion: Prequel to the Exorcist
            +
            +Query: A teenager fakes illness to get off school and have adventures with two friends.
            +Results:
            +How to Deal
            +Shorts
            +Blackbird
            +Valentine
            +Unfriended
            +
            +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
            +Results:
            +Ghostkeeper
            +Our Vines Have Tender Grapes
            +The Ref
            +Impact
            +The House in Marsh Road
            +
            +

            見てわかるように、検索中に埋め込みが切り捨てられた結果、リコールが低下しています。ファネル検索は、この問題を巧妙なトリックで解決します。埋め込み次元の残りを使って、候補リストの再ランク付けとプルーニングを行うことで、高価なベクトル検索を追加で実行することなく、検索パフォーマンスを回復することができます。

            +

            ファネル検索アルゴリズムの説明を簡単にするために、各クエリのMilvus検索ヒット数をPandasデータフレームに変換します。

            +
            def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
            +    """
            +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
            +
            +    """
            +    rows = [x["entity"] for x in hits]
            +    rows_dict = [
            +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
            +    ]
            +    return pd.DataFrame.from_records(rows_dict)
            +
            +
            +dfs = [hits_to_dataframe(hits) for hits in res]
            +
            +

            さて、ファネル検索を実行するために、我々は埋込みのますます大きなサブセットに対して反復します。各反復において、我々は新しい類似度に従って候補を再ランク付けし、最下位にランク付けされた候補の一部を削除する。

            +

            これを具体的にするために、前のステップでは、埋め込みとクエリの次元の1/6を使って128の候補を検索した。ファネル検索の最初のステップは、最初の1/3の次元を用いてクエリと候補の類似度を再計算することである。下位64個の候補は刈り込まれる。次に最初の2/3の次元、そして全ての次元でこのプロセスを繰り返し、32と16の候補に順次刈り込んでいく。

            +
            # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
            +def calculate_score(row, query_emb=None, dims=768):
            +    emb = F.normalize(row["embedding"][:dims], dim=-1)
            +    return (emb @ query_emb).item()
            +
            +
            +# You could also add a top-K parameter as a termination condition
            +def funnel_search(
            +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
            +) -> pd.DataFrame:
            +    # Loop over increasing prefixes of the embeddings
            +    for dims in scales:
            +        # Query vector must be normalized for each new dimensionality
            +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
            +
            +        # Score
            +        scores = df.apply(
            +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
            +        )
            +        df["scores"] = scores
            +
            +        # Re-rank
            +        df = df.sort_values(by="scores", ascending=False)
            +
            +        # Prune (in our case, remove half of candidates at each step)
            +        df = df.head(int(prune_ratio * len(df)))
            +
            +    return df
            +
            +
            +dfs_results = [
            +    {"query": query, "results": funnel_search(df, query_emb)}
            +    for query, df, query_emb in zip(queries, dfs, search_data)
            +]
            +
            +
            for d in dfs_results:
            +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
            +
            +
            An archaeologist searches for ancient artifacts while fighting Nazis. 
            + 0           "Pimpernel" Smith
            +1               Black Hunters
            +29    Raiders of the Lost Ark
            +34             The Master Key
            +51            My Gun Is Quick
            +Name: title, dtype: object 
            +
            +A teenager fakes illness to get off school and have adventures with two friends. 
            + 21               How I Live Now
            +32     On the Edge of Innocence
            +77             Bratz: The Movie
            +4                    Unfriended
            +108                  Simon Says
            +Name: title, dtype: object 
            +
            +A young couple with a kid look after a hotel during winter and the husband goes insane. 
            + 9         The Shining
            +0         Ghostkeeper
            +11     Fast and Loose
            +7      Killing Ground
            +12         Home Alone
            +Name: title, dtype: object 
            +
            +

            追加のベクトル検索を行うことなく、想起を回復させることができた!定性的には、これらの結果は "Raiders of the Lost Ark "と "The Shining "については、チュートリアルの"MilvusとSentence Transformersを使った映画検索 "の標準的なベクトル検索よりも高い想起率を示しているようです。しかし、このチュートリアルで後ほど紹介する "Ferris Bueller's Day Off "を見つけることはできない。(より定量的な実験とベンチマークについては論文Matryoshka Representation Learningを参照)

            +

            ファネル検索の結果を、同じ埋め込みモデルの同じデータセットに対する標準的なベクトル検索と比較してみましょう。完全な埋め込みに対して検索を行います。

            +
            # Search on entire embeddings
            +res = client.search(
            +    collection_name=collection_name,
            +    data=search_data,
            +    anns_field="embedding",
            +    limit=5,
            +    output_fields=["title", "embedding"],
            +)
            +
            +
            for query, hits in zip(queries, res):
            +    rows = [x["entity"] for x in hits]
            +
            +    print("Query:", query)
            +    print("Results:")
            +    for row in rows:
            +        print(row["title"].strip())
            +    print()
            +
            +
            Query: An archaeologist searches for ancient artifacts while fighting Nazis.
            +Results:
            +"Pimpernel" Smith
            +Black Hunters
            +Raiders of the Lost Ark
            +The Master Key
            +My Gun Is Quick
            +
            +Query: A teenager fakes illness to get off school and have adventures with two friends.
            +Results:
            +A Walk to Remember
            +Ferris Bueller's Day Off
            +How I Live Now
            +On the Edge of Innocence
            +Bratz: The Movie
            +
            +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
            +Results:
            +The Shining
            +Ghostkeeper
            +Fast and Loose
            +Killing Ground
            +Home Alone
            +
            +

            A teenager fakes illness to get off school... "の結果を除いて、ファネル検索の結果は完全埋め込み検索とほとんど同じである。

            +

            Ferris Bueller's Day Offのファネルサーチリコール失敗の調査

            なぜファネルサーチはFerris Bueller's Day Offの検索に成功しなかったのだろうか?元の候補リストにあったのか、間違ってフィルタリングされたのかを調べてみましょう。

            +
            queries2 = [
            +    "A teenager fakes illness to get off school and have adventures with two friends."
            +]
            +
            +
            +# Search the database based on input text
            +def embed_search(data):
            +    embeds = model.encode(data)
            +    return [x for x in embeds]
            +
            +
            +instruct_queries = ["search_query: " + q.strip() for q in queries2]
            +search_data2 = embed_search(instruct_queries)
            +head_search2 = [x[:search_dim] for x in search_data2]
            +
            +# Perform standard vector search on subset of embeddings
            +res = client.search(
            +    collection_name=collection_name,
            +    data=head_search2,
            +    anns_field="head_embedding",
            +    limit=256,
            +    output_fields=["title", "head_embedding", "embedding"],
            +)
            +
            +
            for query, hits in zip(queries, res):
            +    rows = [x["entity"] for x in hits]
            +
            +    print("Query:", queries2[0])
            +    for idx, row in enumerate(rows):
            +        if row["title"].strip() == "Ferris Bueller's Day Off":
            +            print(f"Row {idx}: Ferris Bueller's Day Off")
            +
            +
            Query: A teenager fakes illness to get off school and have adventures with two friends.
            +Row 228: Ferris Bueller's Day Off
            +
            +

            最初の候補リストが十分な大きさでなかったこと、つまり、目的のヒットが、最高レベルの粒度でクエリと十分類似していなかったことが問題であったことがわかります。128 から256 に変更すると、検索に成功する。リコールと待ち時間のトレードオフを経験的に評価するために、保留セットの候補数を設定する経験則を形成すべきである。

            +
            dfs = [hits_to_dataframe(hits) for hits in res]
            +
            +dfs_results = [
            +    {"query": query, "results": funnel_search(df, query_emb)}
            +    for query, df, query_emb in zip(queries2, dfs, search_data2)
            +]
            +
            +for d in dfs_results:
            +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
            +
            +
            A teenager fakes illness to get off school and have adventures with two friends. 
            +       A Walk to Remember
            +Ferris Bueller's Day Off
            +          How I Live Now
            +On the Edge of Innocence
            +        Bratz: The Movie
            +              Unfriended
            +              Simon Says 
            +
            +

            順序は重要か?接頭辞埋め込みと接尾辞埋め込み。

            再帰的に小さい接頭辞の埋め込みにうまくマッチングするように学習されたモデル。使用する次元の順番は重要でしょうか?例えば、埋め込み要素の接尾辞の部分集合を取ることもできるでしょうか?この実験では、マトリョーシカ埋め込みにおける次元の順序を逆にし、漏斗探索を行う。

            +
            client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
            +
            +fields = [
            +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
            +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
            +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
            +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
            +]
            +
            +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
            +client.create_collection(collection_name=collection_name, schema=schema)
            +
            +index_params = client.prepare_index_params()
            +index_params.add_index(
            +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
            +)
            +client.create_index(collection_name, index_params)
            +
            +
            huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
            +To disable this warning, you can either:
            +    - Avoid using `tokenizers` before the fork if possible
            +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
            +
            +
            for batch in tqdm(ds.batch(batch_size=512)):
            +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
            +
            +    # Encode and flip embeddings
            +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
            +    embeddings = torch.flip(embeddings, dims=[-1])
            +    head_embeddings = embeddings[:, :search_dim]
            +
            +    data = [
            +        {
            +            "title": title,
            +            "head_embedding": head.cpu().numpy(),
            +            "embedding": embedding.cpu().numpy(),
            +        }
            +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
            +    ]
            +    res = client.insert(collection_name=collection_name, data=data)
            +
            +
            100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
            +
            +
            # Normalize head embeddings
            +
            +flip_search_data = [
            +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
            +]
            +flip_head_search = [x[:search_dim] for x in flip_search_data]
            +
            +# Perform standard vector search on subset of embeddings
            +res = client.search(
            +    collection_name=collection_name,
            +    data=flip_head_search,
            +    anns_field="head_embedding",
            +    limit=128,
            +    output_fields=["title", "head_embedding", "embedding"],
            +)
            +
            +
            dfs = [hits_to_dataframe(hits) for hits in res]
            +
            +dfs_results = [
            +    {"query": query, "results": funnel_search(df, query_emb)}
            +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
            +]
            +
            +for d in dfs_results:
            +    print(
            +        d["query"],
            +        "\n",
            +        d["results"][:7]["title"].to_string(index=False, header=False),
            +        "\n",
            +    )
            +
            +
            An archaeologist searches for ancient artifacts while fighting Nazis. 
            +       "Pimpernel" Smith
            +          Black Hunters
            +Raiders of the Lost Ark
            +         The Master Key
            +        My Gun Is Quick
            +            The Passage
            +        The Mole People 
            +
            +A teenager fakes illness to get off school and have adventures with two friends. 
            +                       A Walk to Remember
            +                          How I Live Now
            +                              Unfriended
            +Cirque du Freak: The Vampire's Assistant
            +                             Last Summer
            +                                 Contest
            +                                 Day One 
            +
            +A young couple with a kid look after a hotel during winter and the husband goes insane. 
            +         Ghostkeeper
            +     Killing Ground
            +Leopard in the Snow
            +              Stone
            +          Afterglow
            +         Unfaithful
            +     Always a Bride 
            +
            +

            リコールは、予想通り、ファネル検索や通常の検索よりもはるかに低い(埋め込みモデルは、埋め込み次元の接頭辞ではなく、接頭辞の対比学習によって学習された)。

            +

            まとめ

            以下は、メソッド間の検索結果の比較である:

            +
            +
            +
            +我々はMilvusとマトリョーシカ埋め込みを用いて、"漏斗探索 "と呼ばれるより効率的な意味検索アルゴリズムを実行する方法を示した。また、アルゴリズムの再ランク付けと枝刈りステップの重要性と、初期候補リストが小さすぎる場合の失敗モードについても検討した。最後に、サブエンベッディングを形成する際に、次元の順序がいかに重要であるかを議論した。というか、モデルが特定の方法で学習されたからこそ、エンベッディングの接頭辞が意味を持つのです。これで、検索性能をあまり犠牲にすることなく、意味検索のストレージコストを削減するために、マトリョーシカ埋め込みとファネル検索を実装する方法がわかりました! diff --git a/localization/v2.4.x/site/ja/tutorials/tutorials-overview.md b/localization/v2.4.x/site/ja/tutorials/tutorials-overview.md index 77e36b81a..dbd7fa0eb 100644 --- a/localization/v2.4.x/site/ja/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/ja/tutorials/tutorials-overview.md @@ -26,9 +26,9 @@ title: チュートリアル概要
            - + - + @@ -42,6 +42,7 @@ title: チュートリアル概要 - + +
            プロパティ説明
            プロパティ説明注釈
            コレクションドロップパーティションドロップパーティション
            コレクションパーティションの表示パーティションを表示
            コレクションパーティションパーティションを持つ
            グローバルすべてこのテーブルのすべてのAPI操作許可
            グローバルすべてこのテーブルのすべてのAPI操作権限
            グローバルコレクションの作成コレクションの作成
            グローバルドロップコレクションドロップコレクション
            グローバルDescribeCollectionDescribeCollection
            MilvusでRAGを構築するRAGベクトル検索
            Milvusを使ったマルチモーダルRAGRAGベクトル検索, ダイナミックフィールド
            Milvusによる画像検索セマンティック検索ベクトル検索、ダイナミックフィールド
            Milvusによる画像検索セマンティック検索ベクトル検索, ダイナミックフィールド
            Milvusのハイブリッド検索ハイブリッド検索ハイブリッド検索, マルチベクトル, 密包埋, 疎包埋
            マルチベクトルによるマルチモーダル検索セマンティック検索マルチベクトル、ハイブリッド検索
            マルチベクトルを使ったマルチモーダル検索セマンティック検索マルチベクトル、ハイブリッド検索
            質問応答システム質問応答ベクトル検索
            推薦システム推薦システムベクトル検索
            ビデオ類似検索セマンティック検索ベクトル検索
            MilvusによるHDBSCANクラスタリングクイックスタートベクトル検索
            Milvusでマルチモーダル検索のためにColPaliを使うクイックスタートベクトル検索
            ベクトルの可視化クイックスタートベクトル検索
            Milvusによる映画推薦レコメンドシステムベクター検索
            Milvusによる映画推薦レコメンドシステムベクトル検索
            マトリョーシカ埋め込みによる漏斗探索クイックスタートベクトル検索
            diff --git a/localization/v2.4.x/site/ja/userGuide/manage-collections.json b/localization/v2.4.x/site/ja/userGuide/manage-collections.json index 87279fbe6..8feaab451 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/ja/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"コレクションの管理","href":"Manage-Collections","type":1,"isActive":false},{"label":"始める前に","href":"Before-you-start","type":2,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"コレクションの作成","href":"Create-Collection","type":2,"isActive":false},{"label":"コレクションの表示","href":"View-Collections","type":2,"isActive":false},{"label":"コレクションのロードとリリース","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"エイリアスの設定","href":"Set-up-aliases","type":2,"isActive":false},{"label":"プロパティの設定","href":"Set-Properties","type":2,"isActive":false},{"label":"コレクションを放棄する","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"コレクションの管理","href":"Manage-Collections","type":1,"isActive":false},{"label":"始める前に","href":"Before-you-start","type":2,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"コレクションの作成","href":"Create-Collection","type":2,"isActive":false},{"label":"コレクションの表示","href":"View-Collections","type":2,"isActive":false},{"label":"コレクションのロードとリリース","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"エイリアスの設定","href":"Set-up-aliases","type":2,"isActive":false},{"label":"プロパティの設定","href":"Set-Properties","type":2,"isActive":false},{"label":"コレクションを放棄する","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/userGuide/manage-collections.md b/localization/v2.4.x/site/ja/userGuide/manage-collections.md index 62d569c04..6f9406ed9 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/ja/userGuide/manage-collections.md @@ -571,7 +571,7 @@ indexParams.add(indexParamForVectorField); index_type - 特定のフィールドにデータを配置するために使用されるアルゴリズムの名前。適用可能なアルゴリズムについては、インメモリ・インデックスと オンディスク・インデックスを参照のこと。 + 特定のフィールドにデータを配置するために使用されるアルゴリズム名。適用可能なアルゴリズムについては、インメモリ・インデックスと オンディスク・インデックスを参照のこと。 metric_type @@ -605,7 +605,7 @@ indexParams.add(indexParamForVectorField); params - インデックス・タイプと関連する設定。詳細は「メモリ内インデックス」を参照。 + インデックス・タイプと関連する設定。詳細はインメモリインデックスを参照。 params.index_type @@ -866,7 +866,7 @@ $ curl -X POST "http://# } # }
        -

        上記で作成したコレクションは自動的にロードされません。以下のように、コレクションのインデックスを作成できます。別の方法でコレクションのインデックスを作成しても、コレクションは自動的にロード されません。詳細は、Load & Release Collection を参照してください。

        +

        上記で作成したコレクションは自動的にロードされません。以下のように、コレクションにインデックスを作成できます。別の方法でコレクションのインデックスを作成しても、コレクションは自動的にロード されません。詳細は、Load & Release Collection を参照してください。

        @@ -903,11 +903,11 @@ $ curl -X POST "http://collectionSchema - + - +

        これを空にすると、このコレクションはデフォルト設定で作成されます。カスタマイズしたスキーマでコレクションをセットアップするには、CollectionSchemaオブジェクトを作成し、それをここで参照する必要があります。

        これを空にすると、このコレクションはデフォルト設定で作成されます。カスタマイズしたスキーマでコレクションをセットアップするには、CollectionSchemaオブジェクトを作成し、ここでそれを参照する必要があります。
        indexParamsこのコレクション内のベクトル・フィールドにインデックスを構築するためのパラメータ。カスタマイズされたスキーマでコレクションをセットアップし、コレクションを自動的にメモリにロードするには、IndexParamオブジェクトのリストでIndexParamsオブジェクトを作成し、ここを参照します。このコレクション内のベクトル・フィールドにインデックスを構築するためのパラメータ。カスタマイズされたスキーマでコレクションをセットアップし、コレクションを自動的にメモリにロードするには、IndexParamオブジェクトのリストでIndexParamsオブジェクトを作成し、ここでそれを参照します。

        @@ -951,7 +951,7 @@ $ curl -X POST "http://schema.autoID
        -主フィールドの自動インクリメントを許可するかどうか。これをTrueに設定すると、プライマリ・フィールドは自動的にインクリメントされます。この場合、エラーを避けるために、プライマリ・フィールドを挿入するデータに含めるべきではありません。is_primaryをTrueに設定したフィールドにこのパラメータを設定します。 +主フィールドの自動インクリメントを許可するかどうか。これをTrueに設定すると、プライマリ・フィールドは自動的にインクリメントされます。この場合、エラーを避けるためにプライマリ・フィールドを挿入するデータに含めるべきではありません。is_primaryをTrueに設定したフィールドにこのパラメータを設定します。 schema.enableDynamicField @@ -1596,12 +1596,12 @@ $ curl -X POST "http://コレクションを部分的に読み込む(パブリックプレビュー)

        この機能は現在パブリックプレビュー中です。APIと機能は将来変更される可能性があります。

        -

        ロード要求を受け取ると、Milvusは全てのベクトルフィールドインデックスと全てのスカラーフィールドデータをメモリにロードします。検索やクエリに関与しないフィールドがある場合、それらをロードから除外してメモリ使用量を削減し、検索パフォーマンスを向上させることができます。

        +

        ロード要求を受け取ると、Milvusはすべてのベクトルフィールドインデックスとすべてのスカラーフィールドデータをメモリにロードします。検索やクエリに関与しないフィールドがある場合、それらをロードから除外してメモリ使用量を削減し、検索パフォーマンスを向上させることができます。

        # 7. Load the collection
         client.load_collection(
             collection_name="customized_setup_2",
        -    load_fields=["my_id", "my_vector"] # Load only the specified fields
        +    load_fields=["my_id", "my_vector"], # Load only the specified fields
             skip_load_dynamic_field=True # Skip loading the dynamic field
         )
         
        @@ -1618,7 +1618,7 @@ res = client.get_load_state(
         # }
         

        検索やクエリでフィルタリング条件や出力フィールドとして使用できるのは、load_fields にリストされたフィールドだけであることに注意してください。リストには常に主キーを含める必要があります。ロードから除外されたフィールド名はフィルタリングや出力に使用できません。

        -

        skip_load_dynamic_field=True 、ダイナミック・フィールドのロードをスキップすることができます。Milvusはダイナミックフィールドを1つのフィールドとして扱うため、ダイナミックフィールド内のすべてのキーが一緒にインクルードまたは除外されます。

        +

        skip_load_dynamic_field=True 、ダイナミック・フィールドのロードをスキップすることができます。Milvusはダイナミックフィールドを1つのフィールドとして扱うため、ダイナミックフィールド内のすべてのキーが一緒に含まれたり除外されたりします。

        コレクションの解放

        コレクションを解放するには release_collection()メソッドを使用します。

        diff --git a/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.json index dc20efe85..b88d4d1aa 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.json +++ b/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.json @@ -1 +1 @@ -{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"","anchorList":[{"label":"スカラーフィールドのインデックス","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"スカラーインデックスの種類","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"オートインデックス","href":"Auto-indexing","type":2,"isActive":false},{"label":"カスタム・インデックス","href":"Custom-indexing","type":2,"isActive":false},{"label":"結果の検証","href":"Verifying-the-result","type":2,"isActive":false},{"label":"制限","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"スカラーフィールドのインデックス","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"スカラインデックスの種類","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"オートインデックス","href":"Auto-indexing","type":2,"isActive":false},{"label":"カスタム・インデックス","href":"Custom-indexing","type":2,"isActive":false},{"label":"結果の検証","href":"Verifying-the-result","type":2,"isActive":false},{"label":"制限","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.md index 14ae7b404..f9980423d 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.md +++ b/localization/v2.4.x/site/ja/userGuide/manage-indexes/index-scalar-fields.md @@ -2,7 +2,7 @@ id: index-scalar-fields.md order: 2 summary: このガイドでは、整数や文字列などのフィールドに対するスカラー・インデックスの作成と設定について説明します。 -title: インデックス・スカラー・フィールド +title: スカラーフィールドのインデックス ---

        スカラーフィールドのインデックス

        Milvusでは、従来のデータベースインデックスと同様に、特定の非ベクトルフィールド値によるメタフィルタリングを高速化するためにスカラインデックスを使用します。このガイドでは、整数や文字列などのフィールドに対するスカラーインデックスの作成と設定について説明します。

        -

        スカラーインデックスの種類

        Milvusでは、スカラーインデックスは、従来のデータベースインデックスと同様に、特定の非ベクトルフィールド値によるメタフィルタリングを高速化するために使用されます。このガイドでは、整数や文字列などのフィールドに対するスカラーインデックスの作成と設定について説明します。

        +

        スカラインデックスの種類

        -

        オートインデックスを使用するには、index_typeパラメータを add_index()で index_type パラメータを省略し、Milvus がスカラ・フィールド・タイプに基づいてインデックス・タイプを推測できるようにします。

        +

        オートインデックスを使用するには、index_typeパラメータを add_index()でindex_typeパラメータを省略し、milvusがスカラーフィールドの型に基づいてインデックス型を推測できるようにします。

        -

        indexTypeパラメータを省略します。 IndexParamの indexType パラメータを省略する。

        +

        indexTypeパラメータを省略します。 IndexParamの indexType パラメータを省略し、 Milvus がスカラーフィールドの型に基づいてインデックスタイプを推測できるようにします。

        -

        index_typeパラメータを省略する。 createIndex()で index_type パラメータを省略する。

        +

        index_typeパラメータを省略する。 createIndex()の index_type パラメータを省略すると、Milvus はスカラーフィールドの型に基づいてインデックスタイプを推測することができます。

        スカラーデータ型とデフォルトのインデックス作成アルゴリズムのマッピングについては、スカラーフィールドのインデックス作成アルゴリズムを参照してください。

        @@ -71,7 +71,7 @@ client = MilvusClient( uri="http://localhost:19530" ) -index_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters +index_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters index_params.add_index( field_name="scalar_1", # Name of the scalar field to be indexed @@ -137,7 +137,7 @@ client.createIndex(createIndexReq);

        以下の例では、スカラー・フィールドscalar_2 に対して転置インデックスを作成しています。

        -
        index_params = client.create_index_params() #  Prepare an IndexParams object
        +
        index_params = MilvusClient.prepare_index_params() #  Prepare an IndexParams object
         
         index_params.add_index(
             field_name="scalar_2", # Name of the scalar field to be indexed
        @@ -179,7 +179,7 @@ client.createIndex(createIndexReq);
         

        メソッドとパラメータ

          -
        • create_index_params()

          +
        • prepare_index_params()

          IndexParamsオブジェクトを準備します。

        • add_index()

          IndexParamsオブジェクトにインデックス設定を追加します。

          @@ -203,7 +203,7 @@ client.createIndex(createIndexReq);
        • collection_name(string)

          インデックスを作成するコレクションの名前。

        • index_params

          -

          インデックス設定を含むIndexParamsオブジェクト。

        • +

          インデックス設定を含むIndexParamsオブジェクト。

      @@ -237,7 +237,7 @@ client.createIndex(createIndexReq);
    • index_type(string) 作成するスカラー・インデックスのタイプ。暗黙的インデックスの場合は、このパラメータを空にするか省略します。 カスタムインデックスの場合は、以下の値が有効です:
      • INVERTED: (推奨) 転置インデックスは、すべてのトークン化された単語をアルファベット順に並べた用語辞書で構成されます。詳細については、「スカラー・インデックス」を参照してください。
      • STL_SORT:標準テンプレート・ライブラリのソート・アルゴリズムを使用して、スカラー・フィールドをソートします。ブール値と数値フィールド(INT8、INT16、INT32、INT64、FLOAT、DOUBLEなど)をサポート。
      • -
      • トライ:高速なプレフィックス検索と取得のためのツリーデータ構造。VARCHAR フィールドをサポートしています。
      • +
      • トライ:高速なプレフィックス検索と取得のためのツリーデータ構造。VARCHAR フィールドをサポート。
    diff --git a/localization/v2.4.x/site/ja/userGuide/manage-partitions.json b/localization/v2.4.x/site/ja/userGuide/manage-partitions.json index 92c21d965..5851e4657 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-partitions.json +++ b/localization/v2.4.x/site/ja/userGuide/manage-partitions.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"パーティションの管理","href":"Manage-Partitions","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"パーティションのリスト","href":"List-Partitions","type":2,"isActive":false},{"label":"パーティションの作成","href":"Create-Partitions","type":2,"isActive":false},{"label":"特定のパーティションのチェック","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"パーティションのロードと解放","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"パーティションの削除","href":"Drop-Partitions","type":2,"isActive":false},{"label":"よくある質問","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"パーティションの管理","href":"Manage-Partitions","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"パーティションのリスト","href":"List-Partitions","type":2,"isActive":false},{"label":"パーティションの作成","href":"Create-Partitions","type":2,"isActive":false},{"label":"特定のパーティションのチェック","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"パーティションのロードと解放","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"パーティションの削除","href":"Drop-Partitions","type":2,"isActive":false},{"label":"よくある質問","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/userGuide/manage-partitions.md b/localization/v2.4.x/site/ja/userGuide/manage-partitions.md index c589cb19a..369440a03 100644 --- a/localization/v2.4.x/site/ja/userGuide/manage-partitions.md +++ b/localization/v2.4.x/site/ja/userGuide/manage-partitions.md @@ -60,10 +60,10 @@ title: パーティションの管理

    準備には MilvusClientでMilvusに接続し create_collection()を使用して、クイックセットアップモードでコレクションを作成します。

    -

    準備の場合 MilvusClientV2でMilvusに接続し createCollection()クイックセットアップモードでコレクションを作成します。

    +

    準備の場合 MilvusClientV2を使ってMilvusに接続し createCollection()クイックセットアップモードでコレクションを作成します。

    -

    準備のために MilvusClientでMilvusに接続し createCollection()クイックセットアップモードでコレクションを作成します。

    +

    準備のために MilvusClientでMilvusに接続し createCollection()コレクションをクイックセットアップで作成します。

    @@ -584,7 +584,7 @@ res = await client.パーティションのロード
    -

    コレクションのすべてのパーティションをロードするには、単に load_collection().コレクションの特定のパーティションをロードするには load_partitions().

    +

    コレクションのすべてのパーティションをロードするには、単に load_collection().コレクション内の特定のパーティションをロードするには load_partitions().

    コレクションのすべてのパーティションをロードするには、単に loadCollection().コレクションの特定のパーティションをロードするには loadPartitions().

    @@ -652,7 +652,7 @@ res = await client."partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionA" ) @@ -663,7 +663,7 @@ res = client.get_load_status( # "state": "<LoadState: Loaded>" # } -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionB" ) @@ -814,13 +814,13 @@ res = await client.// LoadStateNotLoad //
    -

    一度に複数のパーティションを解放するには、以下のようにします:

    +

    一度に複数のパーティションを解放するには、次のようにします:

    client.release_partitions(
         collection_name="quick_setup",
         partition_names=["_default", "partitionA", "partitionB"]
     )
     
    -res = client.get_load_status(
    +res = client.get_load_state(
         collection_name="quick_setup",
     )
     
    diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.json b/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.json
    index ceb4c26dc..e215034e4 100644
    --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.json
    +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.json
    @@ -1 +1 @@
    -{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n    host=\"10.102.7.3\", # Replace with your Milvus server IP\n    port=\"19530\"\n)\n\n# Create schema\nfields = [\n    FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n    FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n    FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n    \"metric_type\": \"L2\",\n    \"index_type\": \"IVF_FLAT\",\n    \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n    # generate random values for each field in the schema\n    film_id = random.randint(1, 1000)\n    film_vector = [ random.random() for _ in range(5) ]\n    poster_vector = [ random.random() for _ in range(5) ]\n\n    # create a dictionary for each entity\n    entity = {\n        \"film_id\": film_id,\n        \"filmVector\": film_vector,\n        \"posterVector\": poster_vector\n    }\n\n    # add the entity to the list\n    entities.append(entity)\n    \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n    \"data\": query_filmVector, # Query vector\n    \"anns_field\": \"filmVector\", # Vector field name\n    \"param\": {\n        \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n        \"params\": {\"nprobe\": 10}\n    },\n    \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n    \"data\": query_posterVector, # Query vector\n    \"anns_field\": \"posterVector\", # Vector field name\n    \"param\": {\n        \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n        \"params\": {\"nprobe\": 10}\n    },\n    \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2)  \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n    reqs, # List of AnnSearchRequests created in step 1\n    rerank, # Reranking strategy specified in step 2\n    limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"","anchorList":[{"label":"ハイブリッド検索","href":"Hybrid-Search","type":1,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"ステップ 1: 複数の AnnSearchRequest インスタンスの作成","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"ステップ2:再ランク付け戦略の設定","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"ステップ3:ハイブリッド検索を実行する","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"制限","href":"Limits","type":2,"isActive":false},{"label":"よくある質問","href":"FAQ","type":2,"isActive":false}]}
    \ No newline at end of file
    +{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n    host=\"127.0.0.1\", # Replace with your Milvus server IP\n    port=\"19530\"\n)\n\n# Create schema\nfields = [\n    FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n    FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n    FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n    \"metric_type\": \"L2\",\n    \"index_type\": \"IVF_FLAT\",\n    \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n    # generate random values for each field in the schema\n    film_id = random.randint(1, 1000)\n    film_vector = [ random.random() for _ in range(5) ]\n    poster_vector = [ random.random() for _ in range(5) ]\n\n    # create a dictionary for each entity\n    entity = {\n        \"film_id\": film_id,\n        \"filmVector\": film_vector,\n        \"posterVector\": poster_vector\n    }\n\n    # add the entity to the list\n    entities.append(entity)\n    \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n    \"data\": query_filmVector, # Query vector\n    \"anns_field\": \"filmVector\", # Vector field name\n    \"param\": {\n        \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n        \"params\": {\"nprobe\": 10}\n    },\n    \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n    \"data\": query_posterVector, # Query vector\n    \"anns_field\": \"posterVector\", # Vector field name\n    \"param\": {\n        \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n        \"params\": {\"nprobe\": 10}\n    },\n    \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2)  \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n    reqs, # List of AnnSearchRequests created in step 1\n    rerank, # Reranking strategy specified in step 2\n    limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"Hybrid Search","anchorList":[{"label":"ハイブリッド検索","href":"Hybrid-Search","type":1,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"ステップ 1: 複数の AnnSearchRequest インスタンスの作成","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"ステップ2:再ランク付け戦略の設定","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"ステップ3:ハイブリッド検索を実行する","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"制限","href":"Limits","type":2,"isActive":false},{"label":"よくある質問","href":"FAQ","type":2,"isActive":false}]}
    \ No newline at end of file
    diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.md b/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.md
    index f4298d65f..bd8d80dfa 100644
    --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.md
    +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/multi-vector-search.md
    @@ -19,7 +19,7 @@ title: ハイブリッド検索
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    Milvus2.4からマルチベクターサポートとハイブリッド検索フレームワークが導入された。異なる列のこれらのベクトルは、異なる埋め込みモデルに由来する、または異なる処理方法を経た、データの多様な側面を表しています。ハイブリッド検索の結果は、RRF(Reciprocal Rank Fusion)やWeighted Scoringなどのリランキング戦略を使って統合されます。再ランク付け戦略の詳細については、再ランク付けを参照してください。

    +

    Milvus2.4からマルチベクターサポートとハイブリッド検索フレームワークが導入された。異なる列のこれらのベクトルは、異なる埋め込みモデルに由来する、あるいは異なる処理方法を経た、データの多様な側面を表しています。ハイブリッド検索の結果は、RRF(Reciprocal Rank Fusion)やWeighted Scoringなどのリランキング戦略を使って統合されます。再ランク付け戦略の詳細については、再ランク付けを参照してください。

    この機能は、写真、音声、指紋などの様々な属性に基づいて、ベクトル・ライブラリ内で最も類似した人物を特定するような、包括的な検索シナリオで特に役立ちます。

    このチュートリアルでは、以下の方法を学びます:

      @@ -28,7 +28,7 @@ title: ハイブリッド検索
    • ハイブリッド検索を実行する hybrid_search()メソッドを使用してハイブリッド検索を実行する。

    -

    このページのコードスニペットはPyMilvus ORMモジュールを使ってMilvusとやりとりしています。新しいMilvusClient SDKを使ったコードスニペットは近日公開予定です。

    +

    このページのコードスニペットはPyMilvus ORMモジュールを使ってMilvusとやりとりします。新しいMilvusClient SDKを使ったコードスニペットは近日公開予定です。

    準備

    ハイブリッド検索を開始する前に、複数のベクトルフィールドを持つコレクションを持っていることを確認してください。現在、Milvusではコレクションごとにデフォルトで4つのベクターフィールドを導入していますが、proxy.maxVectorFieldNumの設定を変更することで最大10まで拡張することができます。

    +

    ハイブリッド検索を開始する前に、複数のベクトルフィールドを持つコレクションを持っていることを確認してください。現在、Milvusではコレクションあたりデフォルトで4つのベクターフィールドを導入していますが、proxy.maxVectorFieldNumの設定を変更することで最大10まで拡張することができます。

    以下は、filmVectorposterVector の2つのベクトルフィールドを持つtest_collection という名前のコレクションを作成し、ランダムエンティティを挿入する例です。

    from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType
     import random
     
     # Connect to Milvus
     connections.connect(
    -    host="10.102.7.3", # Replace with your Milvus server IP
    +    host="127.0.0.1", # Replace with your Milvus server IP
         port="19530"
     )
     
    @@ -152,7 +152,7 @@ reqs = [request_1, request_2]
     
  • AnnSearchRequest (オブジェクト)

    ANN 検索要求を表すクラス。各ハイブリッド検索は、一度に 1 から 1,024ANNSearchRequest オブジェクトを含むことができます。

  • data (list)

    -

    単一のAnnSearchRequest で検索するクエリーベクター。現在、このパラメータは単一のクエリベクタのみを含むリスト、例えば[[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]] を受け付ける。 将来、このパラメータは複数のクエリベクタを受け付けるように拡張される予定である。

  • +

    単一のAnnSearchRequest で検索するクエリーベクター。現在のところ、このパラメータは単一のクエリ・ベクタのみを含むリスト、例えば[[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]] を受け付ける。 将来的には、このパラメータは複数のクエリ・ベクタを受け付けるように拡張される予定である。

  • anns_field (文字列)

    単一のAnnSearchRequest で使用するベクトルフィールドの名前。

  • param (dict)

    @@ -179,7 +179,7 @@ reqs = [request_1, request_2]

    AnnSearchRequest 。インスタンスを作成したら、結果を結合して再ランク付けするための再ランク付け戦略を設定する。現在、WeightedRankerRRFRanker の2つのオプションがある。再ランク付け戦略の詳細については、再ランク付けを参照のこと。

    • 重み付きスコアリングを使用する

      -

      WeightedRanker を使用して、各ベクトルフィールドの検索結果に指定した重みで重要度を割り当てます。あるベクター・フィールドを他のベクター・フィールドより優先させる場合、WeightedRanker(value1, value2, ..., valueN) はそのことを複合検索結果に反映させることができます。

      +

      WeightedRanker を使用して、各ベクトルフィールドの検索結果に指定した重みで重要度を割り当てます。あるベクター・フィールドを他のベクター・フィールドより優先させる場合、WeightedRanker(value1, value2, ..., valueN) を使用することで、検索結果の組み合わせにこれを反映させることができます。

      from pymilvus import WeightedRanker
       # Use WeightedRanker to combine results with specified weights
       # Assign weights of 0.8 to text search and 0.2 to image search
      @@ -274,8 +274,8 @@ res = collection.hybrid_search(
             
           
      • ハイブリッド検索はどのような場合に推奨されますか?

        -

        ハイブリッド検索は、高い精度が要求される複雑な状況、特にエンティティが複数の多様なベクトルで表現できる場合に最適です。これは、文章のような同じデータが異なる埋め込みモデルで処理される場合や、マルチモーダル情報(個人の画像、指紋、声紋など)が様々なベクトル形式に変換される場合に当てはまります。これらのベクトルに重みを割り当てることで、それらの複合的な影響力により、検索結果の再現性を大幅に高め、有効性を向上させることができる。

      • -
      • 重み付きランカーはどのように異なるベクトルフィールド間の距離を正規化するのか?

        +

        ハイブリッド検索は、高い精度が要求される複雑な状況、特にエンティティが複数の多様なベクトルで表現できる場合に最適です。これは、文章などの同じデータが異なる埋め込みモデルで処理される場合や、マルチモーダル情報(個人の画像、指紋、声紋など)が様々なベクトル形式に変換される場合に当てはまります。これらのベクトルに重みを割り当てることで、それらの複合的な影響力により、検索結果の再現性を大幅に高め、有効性を向上させることができる。

      • +
      • 重み付きランカーはどのように異なるベクトルフィールド間の距離を正規化するのですか?

        重み付きランカーは、各フィールドに割り当てられた重みを使用して、ベクトルフィールド間の距離を正規化します。重みに従って各ベクトルフィールドの重要度を計算し、重みの大きいものを優先します。一貫性を確保するために、ANN検索リクエスト全体で同じメトリックタイプを使用することをお勧めします。この方法により、より重要であると判断されたベクトルが、全体的なランキングにより大きな影響を与えるようになります。

      • Cohere Ranker や BGE Ranker のような代替ランカーを使用することはできますか?

        現在のところ、提供されているランカーのみがサポートされています。将来のアップデートに向けて、追加のランカーを含める計画が進行中です。

      • diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.json index 7295bd689..524724f18 100644 --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"単一ベクトル検索","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"基本的な検索","href":"Basic-search","type":2,"isActive":false},{"label":"フィルター検索","href":"Filtered-search","type":2,"isActive":false},{"label":"範囲検索","href":"Range-search","type":2,"isActive":false},{"label":"グループ化検索","href":"Grouping-search","type":2,"isActive":false},{"label":"検索パラメータ","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"単一ベクトル検索","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"基本的な検索","href":"Basic-search","type":2,"isActive":false},{"label":"フィルター検索","href":"Filtered-search","type":2,"isActive":false},{"label":"範囲検索","href":"Range-search","type":2,"isActive":false},{"label":"グループ化検索","href":"Grouping-search","type":2,"isActive":false},{"label":"検索パラメータ","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.md index 406a15cbb..5e6c41102 100644 --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/single-vector-search.md @@ -66,10 +66,12 @@ title: 単一ベクトル検索

        以下のコードスニペットは、Milvusへの接続を確立し、コレクションを素早くセットアップするために既存のコードを再利用しています。

        -
        # 1. Set up a Milvus client
        +
        from pymilvus import MilvusClient
        +import random
        +
        +# 1. Set up a Milvus client
         client = MilvusClient(
        -    uri=CLUSTER_ENDPOINT,
        -    token=TOKEN 
        +    uri="http://localhost:19530"
         )
         
         # 2. Create a collection
        @@ -447,7 +449,7 @@ res = await client.Python  Java Node.js
         
        # Single vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             # Replace with your query vector
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
        @@ -500,7 +502,7 @@ res = await client.limit
        -      
        このパラメータとparamの offsetを組み合わせて使用すると、ページ分割が可能になる。
        この値とparamの offsetの和は16,384未満でなければならない。 +
        このパラメータとparamの offsetを組み合わせて使用すると、ページ分割が可能になる。
        この値とparamの offsetの和は、16,384未満でなければならない。 search_params @@ -522,7 +524,7 @@ res = await client.data
        -
        Milvus は指定されたものに最も類似したベクトル埋め込みを検索する。 +
        Milvusは指定されたものに最も類似したベクトル埋め込みを検索する。 topK @@ -548,7 +550,7 @@ res = await client.limit
        -
        このパラメータは、paramの offsetと組み合わせて使用することで、ページ分割を有効にすることができます。
        この値とparamの offsetの合計は、16,384未満でなければなりません。 +
        このパラメータとparamの offsetを組み合わせて使用すると、ページ分割が可能になります。
        この値とparamの offsetの和は、16,384未満でなければなりません。 @@ -635,13 +637,13 @@ res = await client.

        出力には、クエリベクトルに最も近い上位5つの近傍ベクトルが表示され、一意のIDと計算された距離も表示されます。

        一括ベクトル検索は、1回のリクエストで複数のクエリベクトルを検索できるようにすることで、単一ベクトル検索の概念を拡張します。このタイプの検索は、クエリベクターのセットに対して類似したベクトルを検索する必要があるシナリオに最適で、必要な時間と計算リソースを大幅に削減します。

        -

        一括ベクトル検索では、data フィールドに複数のクエリベクトルを含めることができます。システムはこれらのベクトルを並列に処理し、各クエリ・ベクトルに対して個別の結果セットを返し、各セットにはコレクション内で見つかった最も近い一致が含まれます。

        -

        以下は、2 つのクエリ・ベクターから、最も類似したエンティティの 2 つの異なるセットを検索する例です:

        +

        一括ベクトル検索では、data フィールドに複数のクエリベクトルを含めることができます。システムはこれらのベクトルを並列処理し、クエリ・ベクタごとに個別の結果セットを返し、各セットにはコレクション内で見つかった最も近い一致が含まれます。

        +

        以下は、2 つのクエリ・ベクタから、最も類似したエンティティの 2 つの異なるセットを検索する例です:

        # Bulk-vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[
                 [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
                 [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
        @@ -1226,7 +1228,7 @@ searchResp = client.search(searchReq);
            Python  Java Node.js
         
        # Search with output fields
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1369,12 +1371,12 @@ res = await client.\\% を使用します。
         

      したがって、"_version_" というテキストを検索する必要がある場合は、'like "\\_version\\_"' と書式を整え、アンダースコアがワイルドカードとしてではなく、検索語の一部として扱われるようにします。

      -

      結果が赤で始まる色でフィルタリングされます:

      +

      赤で始まる色を持つ結果をフィルタリングします:

      # Search with filter
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1481,7 +1483,7 @@ res = await client.Python  Java Node.js
       
      # Infix match on color field
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=5, # Max. number of search results to return
           search_params={"metric_type": "IP", "params": {}}, # Search parameters
      @@ -1582,7 +1584,7 @@ search_params = {
       }
       
       res = client.search(
      -    collection_name="test_collection", # Replace with the actual name of your collection
      +    collection_name="quick_setup", # Replace with the actual name of your collection
           data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
           limit=3, # Max. number of search results to return
           search_params=search_params, # Search parameters
      @@ -1717,7 +1719,7 @@ res = await client.# Connect to Milvus
       client = MilvusClient(uri='http://localhost:19530') # Milvus server address
      @@ -1786,7 +1788,7 @@ passage_ids = [result['entity'][1, 10, 3, 12, 9]
       

      与えられた出力では、"doc_11 "が検索結果を完全に支配し、他の文書からの質の高いパラグラフを覆い隠していることが観察できる。

      -

      もう一つ注意すべき点があります。デフォルトでは、grouping_searchは十分なグループ数があれば即座に結果を返しますが、その結果、各グループの検索結果数がgroup_sizeを満たさない可能性があります。各グループの検索結果数を気にするのであれば、上のコードのようにgroup_strict_size=Trueを設定してください。これにより、Milvusは各グループで十分な結果を得ようと努力するようになりますが、パフォーマンスは若干低下します。

      +

      もう一つ注意すべき点があります。デフォルトでは、grouping_searchは十分なグループ数があれば即座に結果を返しますが、その結果、各グループの検索結果数がgroup_sizeを満たさないことがあります。各グループの検索結果数を気にするのであれば、上のコードのようにgroup_strict_size=Trueを設定してください。これにより、Milvusは各グループで十分な結果を得ようと努力するようになりますが、パフォーマンスは若干低下します。

      制限事項

      • インデックス作成:このグループ化機能はHNSWIVF_FLAT、またはFLATタイプでインデックスされたコレクションに対してのみ機能します。詳細については、メモリ内インデックスを参照してください。

      • diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.json b/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.json index 8224db5b0..76a2430eb 100644 --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.json +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"イテレータ","href":"With-Iterators","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"イテレータを使った検索","href":"Search-with-iterator","type":2,"isActive":false},{"label":"イテレータを使用したクエリ","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection,connections\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"イテレータ","href":"With-Iterators","type":1,"isActive":false},{"label":"概要","href":"Overview","type":2,"isActive":false},{"label":"準備","href":"Preparations","type":2,"isActive":false},{"label":"イテレータを使った検索","href":"Search-with-iterator","type":2,"isActive":false},{"label":"イテレータを使用したクエリ","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.md b/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.md index 4068a129a..05742ea82 100644 --- a/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.md +++ b/localization/v2.4.x/site/ja/userGuide/search-query-get/with-iterators.md @@ -246,7 +246,7 @@ System.out.println(wrapper.getInsertCount()); -
        from pymilvus import Collection
        +
        from pymilvus import Collection,connections
         
         # 4. Search with iterator
         connections.connect(host="127.0.0.1", port=19530)
        @@ -377,7 +377,7 @@ System.out.println(results.size());
             
             
               limit
        -      
        値の既定値は-1 で、一致するすべてのエンティティが返されます。 +
        デフォルト値は-1 で、一致するすべてのエンティティが返されます。 diff --git a/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.json index 00a8c0b75..6fb54ca8b 100644 --- a/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"헬름 차트로 Milvus 클러스터 업그레이드하기","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"밀버스 헬름 차트 확인","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"롤링 업그레이드 수행","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"헬름을 사용하여 밀버스 업그레이드","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"메타데이터 마이그레이션","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"헬름 차트로 Milvus 클러스터 업그레이드하기","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"밀버스 헬름 차트 확인","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"롤링 업그레이드 수행","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"헬름을 사용하여 밀버스 업그레이드","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"메타데이터 마이그레이션","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.md index f831deee2..942d7af5a 100644 --- a/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/ko/adminGuide/upgrade_milvus_cluster-helm.md @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
      • Milvus 메타데이터를 마이그레이션합니다.
      • 새 이미지로 Milvus 구성 요소를 시작합니다.
      • -

        2. Milvus를 v2.1.x에서 2.4.15로 업그레이드합니다.

        다음 명령은 Milvus를 v2.1.4에서 2.4.15로 업그레이드한다고 가정합니다. 필요에 맞는 버전으로 변경하세요.

        +

        2. Milvus를 v2.1.x에서 2.2.0으로 업그레이드합니다.

        다음 명령은 Milvus를 v2.1.4에서 2.2.0으로 업그레이드한다고 가정합니다. 필요에 맞는 버전으로 변경하세요.

          -
        1. Milvus 인스턴스 이름, 소스 Milvus 버전, 대상 Milvus 버전을 지정합니다.

          -
          ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
          +
        2. 밀버스 인스턴스 이름, 소스 밀버스 버전, 대상 밀버스 버전을 지정합니다.

          +
          ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
           
        3. Milvus가 기본 K8s 네임스페이스에 설치되지 않은 경우 -n 로 네임스페이스를 지정합니다.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
           
        4. Milvus가 사용자 지정 rootpath 과 함께 설치된 경우 -r 으로 루트 경로를 지정합니다.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
           
        5. Milvus가 사용자 지정 image 과 함께 설치된 경우 이미지 태그를 -w 으로 지정합니다.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
           
        6. 마이그레이션이 완료된 후 마이그레이션 파드를 자동으로 제거하려면 -d true 을 설정합니다.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
           
        7. 마이그레이션이 실패하면 롤백하고 다시 마이그레이션하세요.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
          -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
          +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
           
        diff --git a/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.json index 5aaa7cab3..a7cc00102 100644 --- a/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"헬름으로 쿠버네티스에서 밀버스 실행하기","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"전제 조건","href":"Prerequisites","type":2,"isActive":false},{"label":"Milvus 헬름 차트 설치","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"온라인 설치","href":"Online-install","type":2,"isActive":false},{"label":"오프라인 설치","href":"Offline-install","type":2,"isActive":false},{"label":"실행 중인 Milvus 클러스터 업그레이드","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Milvus 제거","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"헬름으로 쿠버네티스에서 밀버스 실행하기","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"전제 조건","href":"Prerequisites","type":2,"isActive":false},{"label":"Milvus 헬름 차트 설치","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"온라인 설치","href":"Online-install","type":2,"isActive":false},{"label":"오프라인 설치","href":"Offline-install","type":2,"isActive":false},{"label":"실행 중인 Milvus 클러스터 업그레이드","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Milvus 제거","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.md index 612508f6c..44777eb93 100644 --- a/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/ko/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -83,11 +83,11 @@ NAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDI >

        밀버스 헬름 차트를 설치하기 전에 밀버스 헬름 리포지토리를 추가해야 합니다.

        -
        $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
        +
        $ helm repo add milvus https://github.com/zilliztech/milvus-helm
         
        -

        Milvus Helm Charts 리포지토리( https://milvus-io.github.io/milvus-helm/ )는 아카이브되어 있으며, 다음과 같이 https://zilliztech.github.io/milvus-helm/ 에서 추가 업데이트를 받을 수 있습니다:

        -
        helm repo add zilliztech https://zilliztech.github.io/milvus-helm
        +

        Milvus Helm Charts 리포지토리( https://github.com/milvus-io/milvus-helm )는 아카이브되어 있으며, 다음과 같이 https://github.com/zilliztech/milvus-helm 에서 추가 업데이트를 받을 수 있습니다:

        +
        helm repo add zilliztech https://github.com/zilliztech/milvus-helm
         helm repo update
         # upgrade existing helm release
         helm upgrade my-release zilliztech/milvus
        @@ -113,7 +113,7 @@ helm upgrade my-release zilliztech/milvus
                   d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
                 >
               
        -    

        1. 밀버스 클러스터 배포

        헬름 차트를 설치했으면, 쿠버네티스에서 밀버스를 시작할 수 있다. 이 섹션에서는 Milvus를 시작하는 단계를 안내합니다.

        +

        1. 밀버스 클러스터 배포

        헬름 차트를 설치했으면, 쿠버네티스에서 Milvus를 시작할 수 있다. 이 섹션에서는 Milvus를 시작하는 단계를 안내합니다.

        $ helm install my-release milvus/milvus
         

        위의 명령에서 my-release 은 릴리스 이름이고 milvus/milvus 은 로컬로 설치된 차트 리포지토리입니다. 다른 이름을 사용하려면 my-release 을 원하는 이름으로 바꾸세요.

        @@ -122,7 +122,7 @@ helm upgrade my-release zilliztech/milvus
        • 릴리스 이름에는 문자, 숫자 및 대시만 포함해야 합니다. 릴리스 이름에는 점을 사용할 수 없습니다.
        • 기본 명령줄은 헬름과 함께 Milvus를 설치하는 동안 클러스터 버전의 Milvus를 설치합니다. Milvus를 독립형으로 설치할 때는 추가 설정이 필요하다.
        • -
        • 쿠버네티스의 더 이상 사용되지 않는 API 마이그레이션 가이드에 따르면, v1 . 25부터 파드장애예산 정책/v1beta1 API 버전은 더 이상 제공되지 않는다. 대신 정책/v1 API 버전을 사용하도록 매니페스트와 API 클라이언트를 마이그레이션하는 것이 좋다.
          쿠버네티스 v1 . 25 이상에서 여전히 정책/v1beta1 버전의 파드디스럽션예산 API 버전을 사용하는 사용자를 위한 해결 방법으로, 대신 다음 명령을 실행하여 밀버스를 설치할 수 있다:
          . helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • +
        • 쿠버네티스의 더 이상 사용되지 않는 API 마이그레이션 가이드에 따르면, v1.25부터 파드장애예산 정책/v1beta1 API 버전은 더 이상 제공되지 않는다. 대신 정책/v1 API 버전을 사용하도록 매니페스트와 API 클라이언트를 마이그레이션하는 것이 좋다.
          쿠버네티스 v1.25 이상에서 여전히 파드디스럽션버짓의 정책/v1beta1 API 버전을 사용하는 사용자를 위한 해결 방법으로, 다음 명령을 실행하여 밀버스를 설치할 수 있다:
          . helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • 자세한 내용은 밀버스 헬름 차트와 헬름을 참고한다.
        @@ -188,7 +188,7 @@ my-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s

        1. Milvus 매니페스트 가져오기

        다음 명령을 실행하여 Milvus 매니페스트를 가져옵니다.

        $ helm template my-release milvus/milvus > milvus_manifest.yaml
         
        -

        위 명령은 Milvus 클러스터에 대한 차트 템플릿을 렌더링하고 출력을 milvus_manifest.yaml 이라는 매니페스트 파일에 저장합니다. 이 매니페스트를 사용하여 별도의 파드에 구성 요소 및 종속 요소와 함께 Milvus 클러스터를 설치할 수 있습니다.

        +

        위 명령은 Milvus 클러스터에 대한 차트 템플릿을 렌더링하고 그 출력을 milvus_manifest.yaml 이라는 매니페스트 파일에 저장합니다. 이 매니페스트를 사용하여 별도의 파드에 구성 요소 및 종속 요소와 함께 Milvus 클러스터를 설치할 수 있습니다.

        • 모든 Milvus 구성 요소가 단일 포드 내에 포함된 독립형 모드에서 Milvus 인스턴스를 설치하려면 대신 helm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml 을 실행하여 독립형 모드에서 Milvus 인스턴스에 대한 차트 템플릿을 렌더링해야 합니다.
        • @@ -276,13 +276,13 @@ $ helm upgrade my-release zilliztech/milvus
      • 헬름 차트를 사용하여 Milvus 업그레이드.

      • Milvus 클러스터 확장하기.

      • -
      • Milvu 클러스터를 클라우드에 배포하세요:

        +
      • Milvus 클러스터를 클라우드에 배포하세요:

      • -
      • Milvus 데이터 백업을 위한 오픈 소스 도구인 Milvus Backup을 살펴보세요.

      • +
      • Milvus 데이터 백업을 위한 오픈 소스 도구인 Milvus Backup을 살펴보세요.

      • Milvus 디버깅 및 동적 구성 업데이트를 위한 오픈 소스 도구인 Birdwatcher를 살펴보세요.

      • 직관적인 Milvus 관리를 위한 오픈 소스 GUI 도구인 Attu를 살펴보세요.

      • Prometheus로 Milvus 모니터링.

      • diff --git a/localization/v2.4.x/site/ko/integrations/integrations_overview.md b/localization/v2.4.x/site/ko/integrations/integrations_overview.md index e95983aca..07a608bd7 100644 --- a/localization/v2.4.x/site/ko/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/ko/integrations/integrations_overview.md @@ -46,14 +46,14 @@ title: 통합 개요 Milvus 및 MemGPT를 사용한 챗봇 에이전트에이전트Milvus, MemGPT Milvus와 함께 FastGPT를 배포하는 방법RAGMilvus, FastGPT Vanna 및 Milvus로 SQL 작성하기RAGMilvus, Vanna -밀부스 및 카멜과 RAGRAGMilvus, Camel +밀버스 및 카멜을 사용한 RAGRAGMilvus, Camel 에어바이트 & 밀버스: 오픈소스 데이터 이동 인프라데이터 연결Milvus, Airbyte 고급 비디오 검색: 시맨틱 검색을 위한 Twelve Labs와 Milvus 활용하기시맨틱 검색Milvus, Twelve Labs Milvus, vLLM, Llama 3.1로 RAG 구축하기RAGMilvus, vLLM, LlamaIndex 미스트랄 AI, 밀버스, 라마 에이전트를 사용한 멀티 에이전트 시스템에이전트Milvus, Mistral AI, LlamaIndex Milvus와 카프카 연결데이터 소스밀버스, 카프카 밀버스와 코타에몬 RAGRAG밀버스, 코타에몬 -검색 증강 세대: Apify로 웹 사이트를 크롤링하고 질문 답변을 위해 Milvus에 데이터 저장하기데이터 소스Milvus, Apify +검색 증강 세대: Apify로 웹사이트를 크롤링하고 질문 답변을 위해 Milvus에 데이터 저장하기데이터 소스Milvus, Apify DeepEval을 사용한 평가평가 및 관찰 가능성Milvus, DeepEval 아리제 피오닉스를 사용한 평가평가 및 관찰 가능성Milvus, 아리제 피닉스 Milvus로 Dify 배포오케스트레이션Milvus, Dify @@ -65,5 +65,9 @@ title: 통합 개요 Milvus와 비정형 데이터로 RAG 구축하기데이터 소스Milvus, 비정형 Milvus + PII 마스커로 RAG 구축하기데이터 소스Milvus, PII 마스커 PrivateGPT에서 Milvus 사용오케스트레이션벡터 검색 +Mem0 및 Milvus 시작하기에이전트Mem0, Milvus +Milvus를 사용한 지식 테이블지식 엔지니어링지식 테이블, Milvus +DocsGPT에서 Milvus 사용오케스트레이션DocsGPT, Milvus +삼바노바에서 Milvus 사용오케스트레이션Milvus, 삼바노바 diff --git a/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..9c1b1c81d --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Milvus를 사용한 지식 테이블","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"전제 조건","href":"Prerequisites","type":2,"isActive":false},{"label":"프로젝트 복제","href":"Cloning-the-project","type":2,"isActive":false},{"label":"환경 설정하기","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"앱 시작하기","href":"Starting-the-app","type":2,"isActive":false},{"label":"앱 중지","href":"Stopping-the-app","type":2,"isActive":false},{"label":"프로젝트에 액세스하기","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..41b7d6146 --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,144 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + 기본적으로 지식 테이블은 Milvus 데이터베이스를 사용하여 추출된 데이터를 저장하고 검색합니다. 이를 통해 사용자는 Milvus의 강력한 + 기능을 사용하여 데이터를 쉽게 검색, 필터링 및 분석할 수 있습니다. 이 튜토리얼에서는 지식 테이블과 Milvus를 시작하는 방법을 + 보여드리겠습니다. +title: Milvus를 사용한 지식 테이블 +--- +

        Milvus를 사용한 지식 테이블

        WhyHow AI에서 개발한Knowledge Table은 비정형 문서에서 정형 데이터를 쉽게 추출하고 탐색할 수 있도록 설계된 오픈 소스 패키지입니다. 사용자에게 스프레드시트와 같은 인터페이스를 제공하며 자연어 쿼리 인터페이스를 통해 표와 그래프와 같은 지식 표현을 만들 수 있습니다. 이 패키지에는 사용자 정의 가능한 추출 규칙, 서식 지정 옵션, 출처를 통한 데이터 추적 기능이 포함되어 있어 다양한 애플리케이션에 적용할 수 있습니다. 사용자 친화적인 인터페이스가 필요한 비즈니스 사용자와 효율적인 문서 처리를 위한 유연한 백엔드가 필요한 개발자 모두를 만족시킬 수 있도록 RAG 워크플로우와의 원활한 통합을 지원합니다.

        +

        기본적으로 지식 테이블은 Milvus 데이터베이스를 사용하여 추출된 데이터를 저장하고 검색합니다. 이를 통해 사용자는 Milvus의 강력한 기능을 사용하여 데이터를 쉽게 검색, 필터링 및 분석할 수 있습니다. 이 튜토리얼에서는 지식창고와 Milvus를 시작하는 방법을 보여드리겠습니다.

        +

        전제 조건

          +
        • Docker
        • +
        • 도커 컴포즈
        • +
        +

        프로젝트 복제

        $ git clone https://github.com/whyhow-ai/knowledge-table.git
        +
        +

        환경 설정하기

        프로젝트 루트 디렉터리에서 .env.example 파일을 찾을 수 있습니다. 이 파일을 .env 에 복사하고 필요한 환경 변수를 입력합니다.

        +

        Milvus의 경우 MILVUS_DB_URIMILVUS_DB_TOKEN 환경 변수를 설정해야 합니다. 다음은 몇 가지 팁입니다:

        +
        +
          +
        • MILVUS_DB_URI 을 로컬 파일(예:./milvus.db)로 설정하는 것이 가장 편리한 방법인데, Milvus Lite를 자동으로 활용하여 모든 데이터를 이 파일에 저장하기 때문입니다.
        • +
        • 백만 개 이상의 벡터와 같이 대규모 데이터가 있는 경우, Docker 또는 Kubernetes에서 더 성능이 뛰어난 Milvus 서버를 설정할 수 있습니다. 이 설정에서는 서버 주소와 포트를 URI로 사용하세요(예:http://localhost:19530). Milvus에서 인증 기능을 활성화하는 경우 토큰으로 "<사용자 이름>:<사용자 비밀번호>"를 사용하고, 그렇지 않은 경우 토큰을 설정하지 마세요.
        • +
        • 밀버스의 완전 관리형 클라우드 서비스인 질리즈 클라우드를 사용하려면, 질리즈 클라우드의 퍼블릭 엔드포인트와 API 키에 해당하는 MILVUS_DB_URIMILVUS_DB_TOKEN 를 조정하세요.
        • +
        +
        +

        Milvus 외에 다른 환경(예: OPENAI_API_KEY)도 설정해야 합니다. 각각 해당 웹사이트에서 받을 수 있습니다.

        +

        앱 시작하기

        $ docker-compose up -d --build
        +
        +

        앱 중지

        $ docker-compose down
        +
        +

        프로젝트에 액세스하기

        프론트엔드는 http://localhost:3000 에서, 백엔드는 http://localhost:8000 에서 액세스할 수 있습니다.

        +

        + + + + +

        +

        UI를 살펴보고 직접 문서를 작성해 볼 수 있습니다.

        +

        자세한 데모 사용법은 공식 지식 테이블 문서를 참조하세요.

        diff --git a/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..8b0af6f7c --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Mem0 및 Milvus 시작하기","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"준비 사항","href":"Preparation","type":2,"isActive":false},{"label":"Mem0 및 Milvus로 사용자 메모리 관리하기","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..4f995500e --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,214 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + 이 튜토리얼에서는 효율적인 저장 및 검색을 지원하는 고성능 오픈 소스 벡터 데이터베이스인 Milvus를 사용하여 메모리 추가, 검색, + 업데이트, 검색, 삭제 및 메모리 이력 추적과 같은 필수 Mem0 메모리 관리 작업을 다룹니다. 이 실습 소개에서는 기본적인 메모리 작업을 + 통해 Mem0 및 Milvus와 개인화된 AI 상호 작용을 구축하는 데 도움이 되는 방법을 안내합니다. +title: Mem0 및 Milvus 시작하기 +--- +

        Mem0 및 Milvus 시작하기

        +Open In Colab + + +GitHub Repository +

        +

        Mem0은 AI 애플리케이션을 위한 지능형 메모리 계층으로, 사용자 선호도를 유지하고 시간이 지나도 지속적으로 적응하여 개인화되고 효율적인 상호작용을 제공하도록 설계되었습니다. 챗봇과 AI 기반 도구에 이상적인 Mem0는 맥락을 인식하는 원활한 경험을 제공합니다.

        +

        이 튜토리얼에서는 효율적인 저장 및 검색을 지원하는 고성능 오픈 소스 벡터 데이터베이스인 Milvus를 사용하여 메모리 추가, 검색, 업데이트, 검색, 삭제 및 메모리 이력 추적과 같은 필수 Mem0 메모리 관리 작업에 대해 다룹니다. 이 실습 소개에서는 Mem0 및 Milvus를 사용하여 개인화된 AI 상호 작용을 구축하는 데 도움이 되는 기본적인 메모리 작업을 안내합니다.

        +

        준비 사항

        필요한 라이브러리 다운로드

        $ pip install mem0ai pymilvus
        +
        +
        +

        Google Colab을 사용하는 경우 방금 설치한 종속 요소를 사용하려면 런타임을 다시 시작해야 할 수 있습니다(화면 상단의 '런타임' 메뉴를 클릭하고 드롭다운 메뉴에서 '세션 다시 시작'을 선택).

        +
        +

        Milvus로 Mem0 구성하기

        이 예제에서는 OpenAI를 LLM으로 사용하겠습니다. 환경 변수로 OPENAI_API_KEY API 키를 준비해야 합니다.

        +
        import os
        +
        +os.environ["OPENAI_API_KEY"] = "sk-***********"
        +
        +

        이제 Milvus를 벡터 저장소로 사용하도록 Mem0을 구성할 수 있습니다.

        +
        # Define Config
        +from mem0 import Memory
        +
        +config = {
        +    "vector_store": {
        +        "provider": "milvus",
        +        "config": {
        +            "collection_name": "quickstart_mem0_with_milvus",
        +            "embedding_model_dims": "1536",
        +            "url": "./milvus.db",  # Use local vector database for demo purpose
        +        },
        +    },
        +    "version": "v1.1",
        +}
        +
        +m = Memory.from_config(config)
        +
        +
        +
        +
          +
        • 소규모 데이터나 프로토타이핑을 위해 로컬 벡터 데이터베이스만 필요한 경우, URL을 로컬 파일(예:./milvus.db)로 설정하는 것이 가장 편리한 방법인데, 이 파일에 모든 데이터를 저장하기 위해 Milvus Lite를 자동으로 활용하기 때문입니다.
        • +
        • 백만 개 이상의 벡터와 같이 대규모 데이터가 있는 경우, Docker 또는 Kubernetes에서 더 성능이 뛰어난 Milvus 서버를 설정할 수 있습니다. 이 설정에서는 서버 주소와 포트를 URI로 사용하세요(예:http://localhost:19530). Milvus에서 인증 기능을 활성화하는 경우 토큰으로 "<사용자 이름>:<사용자 비밀번호>"를 사용하고, 그렇지 않은 경우 토큰을 설정하지 마세요.
        • +
        • 밀버스의 완전 관리형 클라우드 서비스인 질리즈 클라우드를 사용하는 경우, 질리즈 클라우드의 퍼블릭 엔드포인트와 API 키에 해당하는 uritoken 을 조정하세요.
        • +
        +
        +
        +

        Mem0 및 Milvus로 사용자 메모리 관리하기

        메모리 추가하기

        add 함수는 Milvus에 비정형 텍스트를 메모리로 저장하여 특정 사용자 및 선택적 메타데이터와 연결합니다.

        +

        여기서는 "테니스 실력 향상을 위해 노력 중"이라는 앨리스의 메모리를 관련 메타데이터와 함께 Milvus에 추가하고 있습니다.

        +
        # Add a memory to user: Working on improving tennis skills
        +res = m.add(
        +    messages="I am working on improving my tennis skills.",
        +    user_id="alice",
        +    metadata={"category": "hobbies"},
        +)
        +
        +res
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Working on improving tennis skills',
        +   'event': 'ADD'}],
        + 'relations': []}
        +
        +

        메모리 업데이트하기

        add 함수의 반환값을 사용하여 메모리 ID를 검색하고 update 을 통해 이 메모리를 새 정보로 업데이트할 수 있습니다.

        +
        # Get memory_id
        +memory_id = res["results"][0]["id"]
        +
        +# Update this memory with new information: Likes to play tennis on weekends
        +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
        +
        +
        {'message': 'Memory updated successfully!'}
        +
        +

        사용자에 대한 모든 메모리 가져오기

        get_all 함수를 사용하여 삽입된 모든 메모리를 보거나 Milvus에서 user_id 으로 필터링할 수 있습니다.

        +

        이제 메모리가 "테니스 기술을 익히기 위해 노력 중"에서 "주말에 테니스를 좋아함"으로 변경된 것을 확인할 수 있습니다.

        +
        # Get all memory for the user Alice
        +m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'}]}
        +
        +

        메모리 업데이트 내역 보기

        history 함수를 통해 관심 있는 memory_id를 지정하여 메모리 업데이트 내역을 볼 수도 있습니다.

        +
        m.history(memory_id=memory_id)
        +
        +
        [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': None,
        +  'new_memory': 'Working on improving tennis skills',
        +  'event': 'ADD',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': None},
        + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': 'Working on improving tennis skills',
        +  'new_memory': 'Likes to play tennis on weekends',
        +  'event': 'UPDATE',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
        +
        +

        메모리 검색

        search 함수를 사용하여 사용자와 가장 관련성이 높은 메모리를 찾을 수 있습니다.

        +

        먼저 앨리스에 대한 메모리를 하나 더 추가해 보겠습니다.

        +
        new_mem = m.add(
        +    "I have a linear algebra midterm exam on November 20",
        +    user_id="alice",
        +    metadata={"category": "task"},
        +)
        +
        +

        이제 user_id를 지정하여 get_all 를 호출하여 사용자 Alice에 대한 메모리 항목이 실제로 2개가 있는지 확인합니다.

        +
        m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        이제 queryuser_id 을 제공하여 search 을 수행할 수 있습니다. 유사도 검색에는 기본적으로 L2 메트릭을 사용하므로 score 이 작을수록 유사도가 높다는 것을 의미합니다.

        +
        m.search(query="What are Alice's hobbies", user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'score': 1.2807445526123047,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'score': 1.728922724723816,
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        메모리 삭제

        해당 memory_id 을 제공하여 메모리를 delete 할 수도 있습니다.

        +

        '주말에 테니스를 좋아한다' 메모리는 memory_id 가 이미 검색되었으므로 삭제하고 get_all 으로 전화하여 삭제가 성공했는지 확인합니다.

        +
        m.delete(memory_id=memory_id)
        +
        +m.get_all("alice")
        +
        +
        {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        diff --git a/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..8c1b7134c --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"DocsGPT에서 Milvus 사용","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"요구 사항","href":"Requirements","type":2,"isActive":false},{"label":"리포지토리 복제","href":"Clone-the-repository","type":2,"isActive":false},{"label":"종속성 추가","href":"Add-dependency","type":2,"isActive":false},{"label":"환경 변수 설정","href":"Set-environment-variables","type":2,"isActive":false},{"label":"서비스 시작하기","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..b77e1c841 --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,140 @@ +--- +id: use_milvus_in_docsgpt.md +summary: 이 튜토리얼에서는 Milvus를 DocsGPT의 백엔드 벡터 데이터베이스로 사용하는 방법을 보여드리겠습니다. +title: DocsGPT에서 Milvus 사용 +--- +

        DocsGPT에서 Milvus 사용

        DocsGPT는 강력한 GPT 모델을 통합하여 프로젝트 문서에서 정보 검색을 간소화하는 고급 오픈 소스 솔루션입니다. 이를 통해 개발자는 프로젝트에 대한 질문에 대한 정확한 답변을 쉽게 얻을 수 있으므로 시간이 많이 걸리는 수동 검색을 하지 않아도 됩니다.

        +

        이 튜토리얼에서는 Milvus를 DocsGPT의 백엔드 벡터 데이터베이스로 사용하는 방법을 보여드리겠습니다.

        +
        +

        이 튜토리얼은 주로 DocsGPT 공식 설치 가이드를 참조합니다. 이 튜토리얼에 오래된 부분이 있는 경우 공식 가이드를 우선적으로 따르고 당사에 이슈를 생성할 수 있습니다.

        +
        +

        요구 사항

        Docker가 설치되어 있는지 확인합니다.

        +

        리포지토리 복제

        리포지토리를 복제하고 리포지토리로 이동합니다:

        +
        $ git clone https://github.com/arc53/DocsGPT.git
        +$ cd DocsGPT
        +
        +

        종속성 추가

        application 폴더 아래의 requirements.txt 파일에 langchain-milvus 종속성을 추가합니다:

        +
        $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
        +
        +

        환경 변수 설정

        docker-compose.yaml 파일의 backendworker 서비스에 대한 환경 변수에 VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... 를 다음과 같이 추가합니다:

        +
          backend:
        +    build: ./application
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +
          worker:
        +    build: ./application
        +    command: celery -A application.app.celery worker -l INFO -B
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +

        MILVUS_URI, MILVUS_TOKEN 의 경우, 완전 관리형 질리즈 클라우드(권장) 서비스를 사용하거나 수동으로 밀버스 서비스를 시작할 수 있습니다.

        +
          +
        • 완전 관리형 질리즈 클라우드 서비스의 경우: 질리즈 클라우드 서비스 사용을 권장합니다. 질리즈 클라우드에서 무료 체험 계정을 신청할 수 있습니다. 그 후 퍼블릭 엔드포인트와 API 키에 해당하는 MILVUS_URIMILVUS_TOKEN 을 받게 됩니다.

        • +
        • 수동으로 Milvus 서비스를 시작하려면: 밀버스 서비스를 설정하려면 밀버스 공식 문서에 따라 밀버스 서버를 설정한 후 해당 서버에서 MILVUS_URIMILVUS_TOKEN 을 받으면 됩니다. MILVUS_URIMILVUS_TOKEN 은 각각 http://<your_server_ip>:19530<your_username>:<your_password> 형식이어야 합니다.

        • +
        +

        서비스 시작하기

        실행을 클릭합니다: ./setup.sh

        +

        http://localhost:5173/ 으로 이동합니다.

        +

        UI를 살펴보고 문서에 대해 질문할 수 있습니다.

        +

        + + alt text + 대체 텍스트

        +

        서비스를 중지하려면 실행을 클릭합니다:

        +
        $ docker-compose down
        +
        +

        자세한 내용 및 고급 설정에 대한 자세한 내용은 DocsGPT 공식 문서를 참조하세요.

        diff --git a/localization/v2.4.x/site/ko/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/ko/integrations/use_milvus_in_private_gpt.md index b1f6db6c7..9df6d2699 100644 --- a/localization/v2.4.x/site/ko/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/ko/integrations/use_milvus_in_private_gpt.md @@ -65,13 +65,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        PrivateGPT를 사용하면 설정을 사용자 지정할 수 있습니다. 몇 가지 모듈 설정을 지정해야 합니다. 이 튜토리얼에서는 다음 모듈을 사용합니다:

        +

        PrivateGPT를 사용하면 LLM, 임베딩, 벡터 스토어, UI 등 일부 모듈의 설정을 사용자 정의할 수 있습니다.

        +

        이 튜토리얼에서는 다음 모듈을 사용합니다:

        • LLM: 올라마
        • -
        • 임베딩: Ollama
        • +
        • 임베딩 Ollama
        • 벡터 스토어: Milvus
        • UI: Gradio
        +

        다음 명령을 실행하여 poetry를 사용하여 필요한 모듈 종속성을 설치합니다:

        $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
         

        올라마 서비스 시작

        -

        사용할 모델을 설치합니다(기본값 settings-ollama.yaml 은 사용자 llama3.1 8b LLM(~4GB) 및 nomic-embed-text Embeddings(~275MB)로 구성됨).

        +

        사용할 모델을 설치합니다. 기본값 settings-ollama.yamlllama3.1 8b LLM(~4GB) 및 nomic-embed-text 임베딩(~275MB) 사용자로 구성됩니다.

        기본적으로 PrivateGPT는 필요에 따라 모델을 자동으로 가져옵니다. 이 동작은 ollama.autopull_models 속성을 수정하여 변경할 수 있습니다.

        어떤 경우든 수동으로 모델을 가져오려면 다음 명령을 실행하세요:

        $ ollama pull llama3.1
        @@ -131,8 +133,8 @@ $ ollama pull nomic-embed-text
         필드 옵션설명
         
         
        -uri기본값은 로컬 파일로 "local_data/private_gpt/milvus/milvus_local.db"로 설정되어 있으며, 도커 또는 k8s에서 더 성능이 좋은 Milvus 서버를 설정할 수도 있습니다(예: http://localhost:19530); Zilliz Cloud를 사용하려면 Zilliz Cloud의 엔드포인트 및 API 키로 uri와 토큰을 조정하세요.
        -토큰도커 또는 k8s에서 밀버스 서버와 페어링하거나 질리즈 클라우드의 API 키를 입력합니다.
        +uri기본값은 로컬 파일로 "local_data/private_gpt/milvus/milvus_local.db"로 설정되어 있으며, 도커 또는 k8s에서 더 성능이 좋은 Milvus 서버를 설정할 수도 있습니다(예: http://localhost:19530); Zilliz Cloud를 사용하려면 Zilliz Cloud의 공용 엔드포인트 및 API 키로 uri와 토큰을 조정하세요.
        +토큰도커 또는 k8s 또는 질리즈 클라우드 API 키로 밀버스 서버와 페어링합니다.
         collection_name컬렉션의 이름으로, 기본값은 "milvus_db"로 설정됩니다.
         overwrite컬렉션에 데이터가 있는 경우 덮어쓰기, 기본값은 True로 설정합니다.
         
        @@ -152,10 +154,10 @@ $ ollama pull nomic-embed-text
                   d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
                 >
               
        -    

        모든 설정이 완료되면 그라데이션 UI로 PrivateGPT를 실행할 수 있습니다.

        +

        모든 설정이 완료되면 Gradio UI로 PrivateGPT를 실행할 수 있습니다.

        PGPT_PROFILES=ollama make run
         
        -

        UI는http://0.0.0.0:8001 에서 사용할 수 있습니다.

        +

        UI는 http://0.0.0.0:8001 에서 사용할 수 있습니다.

        @@ -163,3 +165,4 @@ $ ollama pull nomic-embed-text

        UI를 사용해보고 문서에 대해 질문할 수 있습니다.

        +

        자세한 내용은 PrivateGPT 공식 문서를 참조하세요.

        diff --git a/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..62d9e7252 --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"삼바노바와 함께 Milvus 사용","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"전제 조건","href":"Prerequisites","type":2,"isActive":false},{"label":"리포지토리 복제","href":"Clone-the-repository","type":2,"isActive":false},{"label":"벡터 저장소 유형 변경","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"종속성 설치","href":"Install-dependencies","type":2,"isActive":false},{"label":"애플리케이션 시작","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..59a05998d --- /dev/null +++ b/localization/v2.4.x/site/ko/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,133 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + 이 튜토리얼에서는 삼바노바 AI 스타터 키트의 Milvus 통합 기능을 활용하여 기업 비공개 문서를 기반으로 검색 및 답변을 제공하는 + RAG(검색 증강 세대)와 유사한 엔터프라이즈 지식 검색 시스템을 구축합니다. +title: 삼바노바와 함께 Milvus 사용 +--- +

        삼바노바와 함께 Milvus 사용

        삼바노바는 고급 AI 및 딥러닝 기능의 배포를 가속화하는 혁신적인 AI 기술 플랫폼입니다. 기업용으로 설계된 이 플랫폼은 조직이 제너레이티브 AI를 활용하여 성능과 효율성을 향상시킬 수 있도록 지원합니다. 이 플랫폼은 삼바노바 스위트와 데이터스케일과 같은 최첨단 솔루션을 제공함으로써 기업이 데이터에서 가치 있는 인사이트를 추출하여 운영 개선을 주도하고 AI 환경에서 새로운 기회를 창출할 수 있도록 지원합니다.

        +

        삼바노바AI 스타터 키트는 개발자와 기업이 삼바노바를 통해 AI 기반 애플리케이션을 배포하는 데 도움이 되도록 설계된 오픈 소스 리소스 모음입니다. 이 키트는 다양한 AI 사용 사례를 쉽게 구현할 수 있는 실용적인 예제와 가이드를 제공하여 사용자가 삼바노바의 고급 기술을 보다 쉽게 활용할 수 있도록 지원합니다.

        +

        이 튜토리얼에서는 삼바노바 AI 스타터 키트의 Milvus 통합 기능을 활용하여 기업 비공개 문서를 기반으로 검색 및 답변을 제공하는 RAG(검색 증강 세대)와 유사한 엔터프라이즈 지식 검색 시스템을 구축합니다.

        +
        +

        이 튜토리얼은 주로 삼바노바 AI 스타터 키트 공식 가이드를 참조합니다. 이 튜토리얼에 오래된 부분이 있다고 생각되면 공식 가이드를 우선적으로 따르고 이슈를 생성할 수 있습니다.

        +
        +

        전제 조건

        Python >= 3.10 및 3.12 미만 버전을 사용하는 것이 좋습니다.

        +

        삼바노바 클라우드에 방문하여 삼바노바 API 키를 받습니다.

        +

        리포지토리 복제

        $ git clone https://github.com/sambanova/ai-starter-kit.git
        +$ d ai-starter-kit/enterprise_knowledge_retriever
        +
        +

        벡터 저장소 유형 변경

        create_vector_store() 에서 db_type='milvus' 을, load_vdb() 에서 src/document_retrieval.py 을 설정하여 벡터 저장소를 변경합니다.

        +
        ...
        +vectorstore = self.vectordb.create_vector_store(
        +    ..., db_type='milvus'
        +)
        +...
        +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
        +
        +

        종속성 설치

        다음 명령을 실행하여 필요한 종속성을 설치합니다:

        +
        python3 -m venv enterprise_knowledge_env
        +source enterprise_knowledge_env/bin/activate
        +pip install -r requirements.txt
        +
        +

        애플리케이션 시작

        다음 명령을 사용하여 애플리케이션을 시작합니다:

        +
        $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
        +
        +

        그 후 브라우저에 사용자 인터페이스가 표시됩니다:http://localhost:8501/

        +

        + + + + +

        +

        UI에서 삼바노바 API 키를 설정한 후, UI를 사용해보고 문서에 대해 질문할 수 있습니다.

        +

        자세한 내용은 삼바노바 AI 스타터 키트의 기업 지식 검색 공식 문서를 참조하세요.

        diff --git a/localization/v2.4.x/site/ko/menuStructure/ko.json b/localization/v2.4.x/site/ko/menuStructure/ko.json index 50c8f1af2..370d74e8c 100644 --- a/localization/v2.4.x/site/ko/menuStructure/ko.json +++ b/localization/v2.4.x/site/ko/menuStructure/ko.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "사용자 및 역할", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "인메모리 복제본", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "사용자, 권한 및 역할", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "RBAC 사용", "id": "rbac.md", @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "삼바노바", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivateGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "지식 표", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "마트료시카 임베딩을 사용한 퍼널 검색", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "자세히 알아보기", "id": "explore-more", diff --git a/localization/v2.4.x/site/ko/reference/knowhere.json b/localization/v2.4.x/site/ko/reference/knowhere.json index 13ee91d5f..1e99f5bca 100644 --- a/localization/v2.4.x/site/ko/reference/knowhere.json +++ b/localization/v2.4.x/site/ko/reference/knowhere.json @@ -1 +1 @@ -{"codeList":[],"headingContent":"","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"Milvus 아키텍처의 Knowhere","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Knowhere의 장점","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Knowhere 코드 구조","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Knowhere에 인덱스 추가하기","href":"Adding-indexes-to-Knowhere","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":[],"headingContent":"Knowhere","anchorList":[{"label":"Knowhere","href":"Knowhere","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"Milvus 아키텍처의 Knowhere","href":"Knowhere-in-the-Milvus-architecture","type":2,"isActive":false},{"label":"Knowhere의 장점","href":"Knowhere-advantages","type":2,"isActive":false},{"label":"Knowhere 코드 구조","href":"Knowhere-code-structure","type":2,"isActive":false},{"label":"Knowhere에 인덱스 추가하기","href":"Adding-indices-to-Knowhere","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/reference/knowhere.md b/localization/v2.4.x/site/ko/reference/knowhere.md index 4a4f8a7b1..b5c201f4e 100644 --- a/localization/v2.4.x/site/ko/reference/knowhere.md +++ b/localization/v2.4.x/site/ko/reference/knowhere.md @@ -34,7 +34,7 @@ title: Knowhere d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        Knowhere는 Milvus의 핵심 벡터 실행 엔진으로 Faiss, Hnswlib, Annoy 등 여러 벡터 유사성 검색 라이브러리가 통합되어 있습니다. 또한 Knowhere는 이기종 컴퓨팅을 지원하도록 설계되었습니다. 인덱스 구축과 검색 요청을 실행할 하드웨어(CPU 또는 GPU)를 제어합니다. 이것이 바로 작업을 실행할 위치를 파악한다는 의미에서 Knowhere라는 이름이 붙여진 이유입니다. 향후 릴리즈에서는 DPU와 TPU를 포함한 더 많은 유형의 하드웨어가 지원될 예정입니다.

        +

        Knowhere는 Milvus의 핵심 벡터 실행 엔진으로, Faiss, Hnswlib, Annoy 등 여러 벡터 유사성 검색 라이브러리를 통합하고 있습니다. 또한 Knowhere는 이기종 컴퓨팅을 지원하도록 설계되었습니다. 인덱스 구축과 검색 요청을 실행할 하드웨어(CPU 또는 GPU)를 제어합니다. 이것이 바로 작업을 실행할 위치를 파악한다는 의미에서 Knowhere라는 이름이 붙여진 이유입니다. 향후 릴리즈에서는 DPU와 TPU를 포함한 더 많은 유형의 하드웨어가 지원될 예정입니다.

        Milvus 아키텍처의 Knowhere

        다음은 Faiss에 비해 Knowhere의 장점입니다.

        -

        비셋뷰 지원

        Milvus는 "소프트 삭제"를 실현하기 위해 비트셋 메커니즘을 도입했습니다. 소프트 삭제된 벡터는 데이터베이스에 여전히 존재하지만 벡터 유사성 검색이나 쿼리 중에 계산되지 않습니다.

        +

        비트셋뷰 지원

        Milvus는 "소프트 삭제"를 실현하기 위해 비트셋 메커니즘을 도입했습니다. 소프트 삭제된 벡터는 데이터베이스에 여전히 존재하지만 벡터 유사성 검색이나 쿼리 중에 계산되지 않습니다.

        비트셋의 각 비트는 인덱싱된 벡터에 해당합니다. 벡터가 비트셋에서 "1"로 표시되어 있으면 이 벡터는 소프트 삭제된 벡터이며 벡터 검색 중에 포함되지 않는다는 의미입니다. bitset 매개변수는 CPU 및 GPU 인덱스를 포함하여 Knowhere에 노출된 모든 Faiss 인덱스 쿼리 API에 적용됩니다.

        비트셋 메커니즘에 대한 자세한 내용은 비트셋을 참조하세요.

        -

        바이너리 벡터 인덱싱을 위한 여러 유사성 메트릭 지원

        Knowhere는 해밍, Jaccard, 타니모토, 상부 구조하부 구조를 지원합니다. Jaccard와 Tanimoto는 두 샘플 세트 간의 유사도를 측정하는 데 사용할 수 있으며, 상부구조와 하부구조는 화학 구조의 유사도를 측정하는 데 사용할 수 있습니다.

        +

        바이너리 벡터 인덱싱을 위한 여러 유사성 메트릭 지원

        Knowhere는 해밍, Jaccard, 타니모토, 상부 구조 및 하부 구조를 지원합니다. Jaccard와 Tanimoto는 두 샘플 세트 간의 유사도를 측정하는 데 사용할 수 있으며, 상부구조와 하부구조는 화학 구조의 유사도를 측정하는 데 사용할 수 있습니다.

        AVX512 명령어 세트 지원

        Knowhere는 이미 Faiss에서 지원하는 명령어 세트인 AArch64, SSE4.2, AVX2 외에도 AVX512를 지원하여 인덱스 구축 및 쿼리 성능을 AVX2에 비해 20~30% 향상시킬 수 있습니다.

        자동 SIMD 명령어 선택

        Knowhere는 모든 CPU 프로세서(온프레미스 및 클라우드 플랫폼 모두)에서 적합한 SIMD 명령어(예: SIMD SSE, AVX, AVX2, AVX512)를 자동으로 호출할 수 있도록 지원하므로 사용자가 컴파일 중에 SIMD 플래그(예: "-msse4")를 수동으로 지정할 필요가 없습니다.

        Knowhere는 Faiss의 코드베이스를 리팩토링하여 구축되었습니다. SIMD 가속에 의존하는 일반적인 함수(예: 유사성 컴퓨팅)는 제외됩니다. 그런 다음 각 기능에 대해 네 가지 버전(즉, SSE, AVX, AVX2, AVX512)을 구현하고 각각 별도의 소스 파일에 넣습니다. 그런 다음 소스 파일은 해당 SIMD 플래그를 사용하여 개별적으로 추가로 컴파일됩니다. 따라서 런타임에 Knowhere는 현재 CPU 플래그를 기반으로 가장 적합한 SIMD 명령어를 자동으로 선택한 다음 후킹을 사용하여 올바른 함수 포인터를 연결할 수 있습니다.

        @@ -115,19 +115,19 @@ title: Knowhere IDMAP

        엄밀히 말하면 IDMAP 은 인덱스가 아니라 무차별 대입 검색에 사용됩니다. 벡터가 데이터베이스에 삽입되면 데이터 학습이나 인덱스 구축이 필요하지 않습니다. 검색은 삽입된 벡터 데이터에 대해 직접 수행됩니다.

        그러나 코드 일관성을 위해 IDMAP 역시 모든 가상 인터페이스가 포함된 VecIndex 클래스를 상속합니다. IDMAP 의 사용법은 다른 인덱스와 동일합니다.

        -

        IVF 인덱스

        +

        IVF 인덱스

        IVF IVF

        IVF(반전 파일) 인덱스는 가장 자주 사용됩니다. IVF 클래스는 VecIndexFaissBaseIndex 에서 파생되고 IVFSQIVFPQ 로 확장됩니다. GPUIVFGPUIndexIVF 에서 파생됩니다. 그리고 GPUIVFGPUIVFSQGPUIVFPQ 으로 더 확장됩니다.

        -

        IVFSQHybrid 는 자체 개발한 하이브리드 인덱스입니다. 거친 퀀타이저는 GPU에서 실행되고 버킷 검색은 CPU에서 수행됩니다. 이러한 유형의 인덱스는 GPU의 연산 능력을 활용하여 CPU와 GPU 간의 메모리 복사 발생을 줄일 수 있습니다. IVFSQHybridGPUIVFSQ 과 동일한 리콜률을 가지지만 성능이 더 우수합니다.

        +

        IVFSQHybrid 는 자체 개발한 하이브리드 인덱스입니다. CPU에서 버킷을 검색하는 동안 GPU에서 거친 양자화기가 실행됩니다. 이러한 유형의 인덱스는 GPU의 연산 능력을 활용하여 CPU와 GPU 간의 메모리 복사 발생을 줄일 수 있습니다. IVFSQHybridGPUIVFSQ 과 동일한 리콜률을 가지지만 더 나은 성능을 제공합니다.

        바이너리 인덱스의 베이스 클래스 구조는 상대적으로 더 간단합니다. BinaryIDMAPBinaryIVFFaissBaseBinaryIndexVecIndex 에서 파생됩니다.

        -

        서드파티 인덱스

        +

        서드파티 인덱스

        - third-party indexes + third-party indices 서드파티 인덱스

        -

        현재 Faiss를 제외하고 지원되는 타사 인덱스는 트리 기반 인덱스 Annoy 와 그래프 기반 인덱스 HNSW 의 두 가지 유형뿐입니다. 이 두 가지 일반적이고 자주 사용되는 서드파티 인덱스는 모두 VecIndex 에서 파생됩니다.

        -

        Knowhere에 인덱스 추가하기

        Milvus에서 Knowhere가 어떻게 작동하는지 배운 후에는 다음과 같이 하세요:

        diff --git a/localization/v2.4.x/site/ko/reference/schema.json b/localization/v2.4.x/site/ko/reference/schema.json index 8cf37686c..a3dc6edd4 100644 --- a/localization/v2.4.x/site/ko/reference/schema.json +++ b/localization/v2.4.x/site/ko/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"스키마 관리","href":"Manage-Schema","type":1,"isActive":false},{"label":"필드 스키마","href":"Field-schema","type":2,"isActive":false},{"label":"컬렉션 스키마","href":"Collection-schema","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"스키마 관리","href":"Manage-Schema","type":1,"isActive":false},{"label":"필드 스키마","href":"Field-schema","type":2,"isActive":false},{"label":"컬렉션 스키마","href":"Collection-schema","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/reference/schema.md b/localization/v2.4.x/site/ko/reference/schema.md index 08be59cc4..f44e17c65 100644 --- a/localization/v2.4.x/site/ko/reference/schema.md +++ b/localization/v2.4.x/site/ko/reference/schema.md @@ -39,13 +39,16 @@ title: 스키마 관리

        필드 스키마 속성

        - + + + + - + @@ -75,7 +78,7 @@ title: 스키마 관리 - + @@ -131,7 +134,7 @@ fields = [
      • FLOAT_VECTOR: 과학 컴퓨팅 및 머신 러닝에서 실수를 표현하는 데 일반적으로 사용되는 32비트 부동소수점 숫자를 저장합니다.
      • FLOAT16_VECTOR: 메모리 및 대역폭 효율성을 위해 딥러닝 및 GPU 계산에 사용되는 16비트 반정밀도 부동소수점 숫자를 저장합니다.
      • BFLOAT16_VECTOR: 정확도는 떨어지지만 Float32와 동일한 지수 범위를 가진 16비트 부동 소수점 숫자를 저장하며, 정확도에 큰 영향을 주지 않고 메모리 및 계산 요구 사항을 줄이기 위해 딥 러닝에서 널리 사용됩니다.
      • -
      • SPARSE_FLOAT_VECTOR: 희소 벡터를 표현하는 데 사용되는 0이 아닌 요소 목록과 해당 인덱스를 저장합니다. 자세한 내용은 스파스 벡터를 참조하세요.
      • +
      • SPARSE_FLOAT_VECTOR: 희소 벡터를 표현하는 데 사용되는 0이 아닌 요소 목록과 그에 해당하는 인덱스를 저장합니다. 자세한 내용은 스파스 벡터를 참조하세요.
      • Milvus는 컬렉션에서 여러 개의 벡터 필드를 지원합니다. 자세한 내용은 하이브리드 검색을 참조하세요.

        @@ -154,7 +157,10 @@ fields = [

        컬렉션 스키마 속성

        속성설명 참고
        속성설명참고
        name 생성할 컬렉션의 필드 이름데이터 유형: 문자열
        필수
        데이터 유형입니다: 문자열
        필수
        dtype
        dim 벡터의 차원데이터 유형: 정수 ∈[1, 32768]
        밀집 벡터 필드의 경우 필수입니다. 스파스 벡터 필드의 경우 생략합니다.
        데이터 유형: 정수 ∈[1, 32768]
        고밀도 벡터 필드의 경우 필수입니다. 스파스 벡터 필드의 경우 생략합니다.
        is_partition_key
        - + + + + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

        스키마를 지정한 컬렉션을 만듭니다:

        -
        from pymilvus import Collection
        +
        from pymilvus import Collection,connections
        +conn = connections.connect(host="127.0.0.1", port=19530)
         collection_name1 = "tutorial_1"
         collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
         
        diff --git a/localization/v2.4.x/site/ko/reference/users_and_roles.json b/localization/v2.4.x/site/ko/reference/users_and_roles.json index 18813dad7..70cde5be0 100644 --- a/localization/v2.4.x/site/ko/reference/users_and_roles.json +++ b/localization/v2.4.x/site/ko/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"사용자 및 역할","href":"Users-and-Roles","type":1,"isActive":false},{"label":"주요 개념","href":"Key-concepts","type":2,"isActive":false},{"label":"예시: 권한 부여하기","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"기본 사용자 및 역할","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"개체 유형 및 권한 목록","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"사용자, 권한 및 역할","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"주요 개념","href":"Key-concepts","type":2,"isActive":false},{"label":"예시: 권한 부여하기","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"기본 사용자 및 역할","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"개체 유형 및 권한 목록","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"다음 단계","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/reference/users_and_roles.md b/localization/v2.4.x/site/ko/reference/users_and_roles.md index cd9688eb0..a04da4b53 100644 --- a/localization/v2.4.x/site/ko/reference/users_and_roles.md +++ b/localization/v2.4.x/site/ko/reference/users_and_roles.md @@ -2,9 +2,9 @@ id: users_and_roles.md related_key: 'users, roles' summary: '역할 기반 액세스 제어(RBAC)에서 사용자, 역할, 개체 및 권한의 정의에 대해 알아보세요.' -title: 사용자 및 역할 +title: '사용자, 권한 및 역할' --- -

        사용자 및 역할

        Milvus 리소스에 대한 액세스 제어를 관리하려면 개체 유형, 개체 이름, 사용자, 역할 및 권한과 같은 RBAC의 주요 구성 요소를 이해하는 것이 중요합니다.

          -
        • 개체 유형: 권한이 할당되는 개체의 범주입니다. 개체 유형은 다음과 같습니다:

          +
        • 개체유형: 권한이 할당되는 개체의 범주입니다. 개체 유형은 다음과 같습니다:

          • Global: 시스템 전체 개체로, 사용자가 모든 컬렉션, 사용자 또는 시스템 전체 설정에 영향을 주는 작업을 수행할 수 있습니다.
          • Collection: 컬렉션별 개체 - 사용자가 특정 컬렉션 내에서 인덱스 만들기, 데이터 로드, 데이터 삽입 또는 삭제, 데이터 쿼리 등의 작업을 수행할 수 있도록 허용하는 개체입니다.
          • -
          • User: 사용자 관리와 관련된 개체로, 사용자가 사용자 자격 증명 업데이트 또는 사용자 세부 정보 보기와 같이 데이터베이스 사용자의 자격 증명 및 역할을 관리할 수 있습니다.
          • +
          • User: 사용자 관리와 관련된 개체로, 사용자가 사용자 자격 증명 업데이트 또는 사용자 세부 정보 보기와 같은 데이터베이스 사용자의 자격 증명 및 역할을 관리할 수 있습니다.
        • 개체 이름: 액세스를 제어할 개체의 특정 이름입니다. 예를 들어

            @@ -144,7 +144,7 @@ client.grantPrivilege(grantPrivilegeReq); d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

            다음 표에는 RBAC를 사용 설정할 때 선택할 수 있는 값이 나열되어 있습니다.

            +

            다음 표에는 RBAC를 사용 설정할 때 선택할 수 있는 값이 나열되어 있습니다.

        속성설명 참고
        속성설명참고
        diff --git a/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..9f0a26c0b --- /dev/null +++ b/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"마트료시카 임베딩을 사용한 퍼널 검색","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"마트료시카 임베딩 모델 로드","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"데이터 세트 로드, 항목 임베딩 및 벡터 데이터베이스 구축하기","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"퍼널 검색 수행하기","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"퍼널 검색과 일반 검색 비교","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"페리스 뷸러의 휴무일에 대한 퍼널 검색 리콜 실패 조사하기","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"순서가 중요한가요? 접두사 임베딩 대 접미사 임베딩.","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"요약","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..46f196d91 --- /dev/null +++ b/localization/v2.4.x/site/ko/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,568 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + 이 노트에서는 의미론적 검색을 위해 Milvus와 함께 Matryoshka 임베딩을 사용하는 방법을 살펴봅니다. "깔때기 검색"이라는 + 알고리즘을 통해 임베딩 차원의 작은 하위 집합에 대한 유사성 검색을 리콜률을 급격히 떨어뜨리지 않고 수행할 수 있는 방법을 설명합니다. +title: 마트료시카 임베딩을 사용한 퍼널 검색 +--- +

        마트료시카 임베딩을 사용한 퍼널 검색

        효율적인 벡터 검색 시스템을 구축할 때, 한 가지 핵심 과제는 허용 가능한 지연 시간과 리콜을 유지하면서 스토리지 비용을 관리하는 것입니다. 최신 임베딩 모델은 수백 또는 수천 개의 차원을 가진 벡터를 출력하기 때문에 원시 벡터와 인덱스에 상당한 스토리지와 계산 오버헤드를 발생시킵니다.

        +

        전통적으로, 인덱스 구축 직전에 양자화 또는 차원 축소 방법을 적용하여 저장소 요구 사항을 줄입니다. 예를 들어, 제품 정량화(PQ)를 사용해 정밀도를 낮추거나 주성분 분석(PCA)을 사용해 차원 수를 줄임으로써 저장 공간을 절약할 수 있습니다. 이러한 방법은 전체 벡터 집합을 분석하여 벡터 간의 의미 관계를 유지하는 더 간결한 벡터 집합을 찾습니다.

        +

        이러한 표준 접근 방식은 효과적이기는 하지만 정밀도나 차원을 단 한 번만 감소시킵니다. 하지만 점점 더 정밀하게 표현되는 피라미드처럼 여러 계층의 디테일을 동시에 유지할 수 있다면 어떨까요?

        +

        마트료시카 임베딩을 소개합니다. 러시아 중첩 인형(그림 참조)에서 이름을 따온 이 기발한 구조는 단일 벡터 내에 여러 스케일의 표현을 임베딩합니다. 기존의 사후 처리 방법과 달리, 마트료시카 임베딩은 초기 학습 과정에서 이 다중 스케일 구조를 학습합니다. 그 결과는 놀랍습니다. 전체 임베딩이 입력 의미를 포착할 뿐만 아니라 중첩된 각 하위 집합 접두사(전반부, 1/4 등)가 덜 상세하더라도 일관성 있는 표현을 제공합니다.

        +
        +

        이 노트에서는 의미 검색을 위해 Milvus와 함께 Matryoshka 임베딩을 사용하는 방법을 살펴봅니다. "깔때기 검색"이라는 알고리즘을 통해 임베딩 차원의 작은 하위 집합에 대한 유사성 검색을 수행하면서 회상률을 급격히 떨어뜨리지 않고도 검색을 수행할 수 있는 방법을 설명합니다.

        +
        import functools
        +
        +from datasets import load_dataset
        +import numpy as np
        +import pandas as pd
        +import pymilvus
        +from pymilvus import MilvusClient
        +from pymilvus import FieldSchema, CollectionSchema, DataType
        +from sentence_transformers import SentenceTransformer
        +import torch
        +import torch.nn.functional as F
        +from tqdm import tqdm
        +
        +

        마트료시카 임베딩 모델 로드

        다음과 같은 표준 임베딩 모델을 사용하는 대신 sentence-transformers/all-MiniLM-L12-v2와 같은 표준 임베딩 모델을 사용하는 대신, Matryoshka 임베딩을 생성하도록 특별히 훈련된 Nomic의 모델을 사용합니다.

        +
        model = SentenceTransformer(
        +    # Remove 'device='mps' if running on non-Mac device
        +    "nomic-ai/nomic-embed-text-v1.5",
        +    trust_remote_code=True,
        +    device="mps",
        +)
        +
        +
        <All keys matched successfully>
        +
        +

        데이터 세트 로드, 항목 임베딩 및 벡터 데이터베이스 구축하기

        다음 코드는 문서 페이지 "문장 트랜스포머와 밀버스를 사용한 영화 검색"의 코드를 수정한 것입니다. 먼저 HuggingFace에서 데이터 세트를 로드합니다. 여기에는 약 35,000개의 항목이 포함되어 있으며, 각 항목은 Wikipedia 문서가 있는 영화에 해당합니다. 이 예제에서는 TitlePlotSummary 필드를 사용하겠습니다.

        +
        ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
        +print(ds)
        +
        +
        Dataset({
        +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
        +    num_rows: 34886
        +})
        +
        +

        다음으로 Milvus Lite 데이터베이스에 연결하여 데이터 스키마를 지정하고 이 스키마로 컬렉션을 생성합니다. 정규화되지 않은 임베딩과 임베딩의 첫 번째 여섯 번째를 모두 별도의 필드에 저장합니다. 그 이유는 유사도 검색을 수행하기 위해 Matryoshka 임베딩의 첫 1/6이 필요하고, 검색 결과의 순위를 재조정하고 개선하기 위해 나머지 5/6의 임베딩이 필요하기 때문입니다.

        +
        embedding_dim = 768
        +search_dim = 128
        +collection_name = "movie_embeddings"
        +
        +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
        +
        +fields = [
        +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
        +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
        +    # First sixth of unnormalized embedding vector
        +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
        +    # Entire unnormalized embedding vector
        +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
        +]
        +
        +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
        +client.create_collection(collection_name=collection_name, schema=schema)
        +
        +

        Milvus는 현재 임베딩의 하위 집합에 대한 검색을 지원하지 않기 때문에 임베딩을 두 부분으로 나누어 헤드는 색인 및 검색할 벡터의 초기 하위 집합을 나타내고 테일은 나머지 부분입니다. 이 모델은 코사인 거리 유사성 검색을 위해 훈련되었으므로 헤드 임베딩을 정규화합니다. 그러나 나중에 더 큰 하위 집합에 대한 유사도를 계산하려면 헤드 임베딩의 규범을 저장해야 하므로 꼬리에 결합하기 전에 정규화를 해제할 수 있습니다.

        +

        임베딩의 첫 1/6을 통해 검색을 수행하려면 head_embedding 필드에 벡터 검색 인덱스를 생성해야 합니다. 나중에 '퍼널 검색'의 결과를 일반 벡터 검색과 비교할 것이므로 전체 임베딩에 대해서도 검색 인덱스를 구축할 것입니다.

        +

        중요한 것은 IP 거리 메트릭이 아닌 COSINE 을 사용하는 것인데, 그렇지 않으면 임베딩 규범을 추적해야 하므로 구현이 복잡해지기 때문입니다(퍼널 검색 알고리즘을 설명하면 더 이해가 쉬워질 것입니다).

        +
        index_params = client.prepare_index_params()
        +index_params.add_index(
        +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
        +)
        +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
        +client.create_index(collection_name, index_params)
        +
        +

        마지막으로 35,000개의 모든 영화에 대한 줄거리 요약을 인코딩하고 해당 임베딩을 데이터베이스에 입력합니다.

        +
        for batch in tqdm(ds.batch(batch_size=512)):
        +    # This particular model requires us to prefix 'search_document:' to stored entities
        +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
        +
        +    # Output of embedding model is unnormalized
        +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
        +    head_embeddings = embeddings[:, :search_dim]
        +
        +    data = [
        +        {
        +            "title": title,
        +            "head_embedding": head.cpu().numpy(),
        +            "embedding": embedding.cpu().numpy(),
        +        }
        +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
        +    ]
        +    res = client.insert(collection_name=collection_name, data=data)
        +
        +
        100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
        +
        +

        이제 마트료시카 임베딩 차원의 첫 1/6을 사용해 '퍼널 검색'을 구현해 보겠습니다. 검색할 영화 세 편을 염두에 두고 있으며 데이터베이스 쿼리를 위한 줄거리 요약을 직접 작성했습니다. 쿼리를 임베드한 다음 head_embedding 필드에서 벡터 검색을 수행하여 128개의 결과 후보를 검색합니다.

        +
        queries = [
        +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
        +    "A teenager fakes illness to get off school and have adventures with two friends.",
        +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
        +]
        +
        +
        +# Search the database based on input text
        +def embed_search(data):
        +    embeds = model.encode(data)
        +    return [x for x in embeds]
        +
        +
        +# This particular model requires us to prefix 'search_query:' to queries
        +instruct_queries = ["search_query: " + q.strip() for q in queries]
        +search_data = embed_search(instruct_queries)
        +
        +# Normalize head embeddings
        +head_search = [x[:search_dim] for x in search_data]
        +
        +# Perform standard vector search on first sixth of embedding dimensions
        +res = client.search(
        +    collection_name=collection_name,
        +    data=head_search,
        +    anns_field="head_embedding",
        +    limit=128,
        +    output_fields=["title", "head_embedding", "embedding"],
        +)
        +
        +

        이 시점에서 훨씬 더 작은 벡터 공간에서 검색을 수행했기 때문에 전체 공간에서 검색할 때보다 지연 시간이 줄어들고 인덱스에 대한 저장 공간 요구 사항이 줄어들었을 가능성이 높습니다. 각 쿼리에 대해 상위 5개 일치 항목을 살펴보겠습니다:

        +
        for query, hits in zip(queries, res):
        +    rows = [x["entity"] for x in hits][:5]
        +
        +    print("Query:", query)
        +    print("Results:")
        +    for row in rows:
        +        print(row["title"].strip())
        +    print()
        +
        +
        Query: An archaeologist searches for ancient artifacts while fighting Nazis.
        +Results:
        +"Pimpernel" Smith
        +Black Hunters
        +The Passage
        +Counterblast
        +Dominion: Prequel to the Exorcist
        +
        +Query: A teenager fakes illness to get off school and have adventures with two friends.
        +Results:
        +How to Deal
        +Shorts
        +Blackbird
        +Valentine
        +Unfriended
        +
        +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
        +Results:
        +Ghostkeeper
        +Our Vines Have Tender Grapes
        +The Ref
        +Impact
        +The House in Marsh Road
        +
        +

        보시다시피, 검색 중에 임베딩을 잘라낸 결과 리콜이 저하되었습니다. 퍼널 검색은 이 문제를 영리한 방법으로 해결합니다. 나머지 임베딩 차원을 사용하여 후보 목록의 순위를 재조정하고 잘라내어 비용이 많이 드는 벡터 검색을 추가로 실행하지 않고도 검색 성능을 회복할 수 있습니다.

        +

        퍼널 검색 알고리즘을 쉽게 설명하기 위해 각 쿼리에 대한 Milvus 검색 히트를 Pandas 데이터 프레임으로 변환합니다.

        +
        def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
        +    """
        +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
        +
        +    """
        +    rows = [x["entity"] for x in hits]
        +    rows_dict = [
        +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
        +    ]
        +    return pd.DataFrame.from_records(rows_dict)
        +
        +
        +dfs = [hits_to_dataframe(hits) for hits in res]
        +
        +

        이제 퍼널 검색을 수행하기 위해 임베딩의 점점 더 큰 하위 집합을 반복합니다. 반복할 때마다 새로운 유사성에 따라 후보의 순위를 재조정하고 가장 낮은 순위를 가진 일부 후보를 제거합니다.

        +

        이를 구체적으로 설명하기 위해 이전 단계에서는 임베딩 및 쿼리 차원의 1/6을 사용하여 128개의 후보를 검색했습니다. 퍼널 검색을 수행하는 첫 번째 단계는 첫 번째 1/3의 차원을 사용하여 쿼리와 후보 간의 유사성을 다시 계산하는 것입니다. 하위 64개의 후보가 제거됩니다. 그런 다음 처음 2/3의 차원과 모든 차원에 대해 이 프로세스를 반복하여 32개와 16개의 후보를 연속적으로 정리합니다.

        +
        # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
        +def calculate_score(row, query_emb=None, dims=768):
        +    emb = F.normalize(row["embedding"][:dims], dim=-1)
        +    return (emb @ query_emb).item()
        +
        +
        +# You could also add a top-K parameter as a termination condition
        +def funnel_search(
        +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
        +) -> pd.DataFrame:
        +    # Loop over increasing prefixes of the embeddings
        +    for dims in scales:
        +        # Query vector must be normalized for each new dimensionality
        +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
        +
        +        # Score
        +        scores = df.apply(
        +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
        +        )
        +        df["scores"] = scores
        +
        +        # Re-rank
        +        df = df.sort_values(by="scores", ascending=False)
        +
        +        # Prune (in our case, remove half of candidates at each step)
        +        df = df.head(int(prune_ratio * len(df)))
        +
        +    return df
        +
        +
        +dfs_results = [
        +    {"query": query, "results": funnel_search(df, query_emb)}
        +    for query, df, query_emb in zip(queries, dfs, search_data)
        +]
        +
        +
        for d in dfs_results:
        +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
        +
        +
        An archaeologist searches for ancient artifacts while fighting Nazis. 
        + 0           "Pimpernel" Smith
        +1               Black Hunters
        +29    Raiders of the Lost Ark
        +34             The Master Key
        +51            My Gun Is Quick
        +Name: title, dtype: object 
        +
        +A teenager fakes illness to get off school and have adventures with two friends. 
        + 21               How I Live Now
        +32     On the Edge of Innocence
        +77             Bratz: The Movie
        +4                    Unfriended
        +108                  Simon Says
        +Name: title, dtype: object 
        +
        +A young couple with a kid look after a hotel during winter and the husband goes insane. 
        + 9         The Shining
        +0         Ghostkeeper
        +11     Fast and Loose
        +7      Killing Ground
        +12         Home Alone
        +Name: title, dtype: object 
        +
        +

        추가 벡터 검색을 수행하지 않고도 리콜을 복원할 수 있었습니다! 질적으로 이러한 결과는 다른 임베딩 모델을 사용하는 튜토리얼 '밀버스와 문장 트랜스포머를 사용한 영화 검색'의 표준 벡터 검색보다 '로스트 아크의 침입자'와 '샤이닝'에 대한 리콜이 더 높은 것으로 보입니다. 하지만 "페리스 뷸러의 하루"는 찾을 수 없었는데, 이 부분은 나중에 노트북에서 다시 다룰 예정입니다. (더 많은 정량적 실험과 벤치마킹은 Matryoshka 표현 학습 논문을 참조하세요.)

        +

        동일한 임베딩 모델을 사용하는 동일한 데이터 세트에서 퍼널 검색의 결과를 표준 벡터 검색과 비교해 보겠습니다. 전체 임베딩에 대해 검색을 수행합니다.

        +
        # Search on entire embeddings
        +res = client.search(
        +    collection_name=collection_name,
        +    data=search_data,
        +    anns_field="embedding",
        +    limit=5,
        +    output_fields=["title", "embedding"],
        +)
        +
        +
        for query, hits in zip(queries, res):
        +    rows = [x["entity"] for x in hits]
        +
        +    print("Query:", query)
        +    print("Results:")
        +    for row in rows:
        +        print(row["title"].strip())
        +    print()
        +
        +
        Query: An archaeologist searches for ancient artifacts while fighting Nazis.
        +Results:
        +"Pimpernel" Smith
        +Black Hunters
        +Raiders of the Lost Ark
        +The Master Key
        +My Gun Is Quick
        +
        +Query: A teenager fakes illness to get off school and have adventures with two friends.
        +Results:
        +A Walk to Remember
        +Ferris Bueller's Day Off
        +How I Live Now
        +On the Edge of Innocence
        +Bratz: The Movie
        +
        +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
        +Results:
        +The Shining
        +Ghostkeeper
        +Fast and Loose
        +Killing Ground
        +Home Alone
        +
        +

        "한 십대가 학교를 빠지기 위해 병을 속이고..."에 대한 결과를 제외하면, 퍼널 검색의 경우 128차원의 검색 공간에서 퍼널 검색을 수행한 반면 일반 검색의 경우 768차원에서 검색을 수행했음에도 불구하고 전체 검색과 거의 동일한 결과를 얻을 수 있습니다.

        +

        페리스 뷸러의 휴무일에 대한 퍼널 검색 리콜 실패 조사하기

        왜 퍼널 검색이 페리스 뷸러의 휴일 검색에 성공하지 못했을까요? 원래 후보 목록에 있었던 것인지 아니면 실수로 필터링이 잘못되었는지 살펴보겠습니다.

        +
        queries2 = [
        +    "A teenager fakes illness to get off school and have adventures with two friends."
        +]
        +
        +
        +# Search the database based on input text
        +def embed_search(data):
        +    embeds = model.encode(data)
        +    return [x for x in embeds]
        +
        +
        +instruct_queries = ["search_query: " + q.strip() for q in queries2]
        +search_data2 = embed_search(instruct_queries)
        +head_search2 = [x[:search_dim] for x in search_data2]
        +
        +# Perform standard vector search on subset of embeddings
        +res = client.search(
        +    collection_name=collection_name,
        +    data=head_search2,
        +    anns_field="head_embedding",
        +    limit=256,
        +    output_fields=["title", "head_embedding", "embedding"],
        +)
        +
        +
        for query, hits in zip(queries, res):
        +    rows = [x["entity"] for x in hits]
        +
        +    print("Query:", queries2[0])
        +    for idx, row in enumerate(rows):
        +        if row["title"].strip() == "Ferris Bueller's Day Off":
        +            print(f"Row {idx}: Ferris Bueller's Day Off")
        +
        +
        Query: A teenager fakes illness to get off school and have adventures with two friends.
        +Row 228: Ferris Bueller's Day Off
        +
        +

        초기 후보 목록이 충분히 크지 않았거나, 오히려 원하는 검색어가 가장 높은 수준의 세부 수준에서 쿼리와 충분히 유사하지 않다는 것이 문제임을 알 수 있습니다. 128 에서 256 으로 변경하면 검색에 성공합니다. 리콜과 지연 시간 간의 균형을 경험적으로 평가하기 위해 홀드아웃 세트의 후보자 수를 설정하는 경험 법칙을 만들어야 합니다.

        +
        dfs = [hits_to_dataframe(hits) for hits in res]
        +
        +dfs_results = [
        +    {"query": query, "results": funnel_search(df, query_emb)}
        +    for query, df, query_emb in zip(queries2, dfs, search_data2)
        +]
        +
        +for d in dfs_results:
        +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
        +
        +
        A teenager fakes illness to get off school and have adventures with two friends. 
        +       A Walk to Remember
        +Ferris Bueller's Day Off
        +          How I Live Now
        +On the Edge of Innocence
        +        Bratz: The Movie
        +              Unfriended
        +              Simon Says 
        +
        +

        순서가 중요한가요? 접두사 임베딩 대 접미사 임베딩.

        이 모델은 재귀적으로 더 작은 접두사 임베딩을 잘 매칭하도록 학습되었습니다. 우리가 사용하는 차원의 순서가 중요할까요? 예를 들어, 접미사인 임베딩의 하위 집합도 사용할 수 있을까요? 이 실험에서는 마트료시카 임베딩의 차원 순서를 반대로 하여 깔때기 검색을 수행합니다.

        +
        client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
        +
        +fields = [
        +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
        +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
        +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
        +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
        +]
        +
        +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
        +client.create_collection(collection_name=collection_name, schema=schema)
        +
        +index_params = client.prepare_index_params()
        +index_params.add_index(
        +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
        +)
        +client.create_index(collection_name, index_params)
        +
        +
        huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
        +To disable this warning, you can either:
        +    - Avoid using `tokenizers` before the fork if possible
        +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
        +
        +
        for batch in tqdm(ds.batch(batch_size=512)):
        +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
        +
        +    # Encode and flip embeddings
        +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
        +    embeddings = torch.flip(embeddings, dims=[-1])
        +    head_embeddings = embeddings[:, :search_dim]
        +
        +    data = [
        +        {
        +            "title": title,
        +            "head_embedding": head.cpu().numpy(),
        +            "embedding": embedding.cpu().numpy(),
        +        }
        +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
        +    ]
        +    res = client.insert(collection_name=collection_name, data=data)
        +
        +
        100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
        +
        +
        # Normalize head embeddings
        +
        +flip_search_data = [
        +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
        +]
        +flip_head_search = [x[:search_dim] for x in flip_search_data]
        +
        +# Perform standard vector search on subset of embeddings
        +res = client.search(
        +    collection_name=collection_name,
        +    data=flip_head_search,
        +    anns_field="head_embedding",
        +    limit=128,
        +    output_fields=["title", "head_embedding", "embedding"],
        +)
        +
        +
        dfs = [hits_to_dataframe(hits) for hits in res]
        +
        +dfs_results = [
        +    {"query": query, "results": funnel_search(df, query_emb)}
        +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
        +]
        +
        +for d in dfs_results:
        +    print(
        +        d["query"],
        +        "\n",
        +        d["results"][:7]["title"].to_string(index=False, header=False),
        +        "\n",
        +    )
        +
        +
        An archaeologist searches for ancient artifacts while fighting Nazis. 
        +       "Pimpernel" Smith
        +          Black Hunters
        +Raiders of the Lost Ark
        +         The Master Key
        +        My Gun Is Quick
        +            The Passage
        +        The Mole People 
        +
        +A teenager fakes illness to get off school and have adventures with two friends. 
        +                       A Walk to Remember
        +                          How I Live Now
        +                              Unfriended
        +Cirque du Freak: The Vampire's Assistant
        +                             Last Summer
        +                                 Contest
        +                                 Day One 
        +
        +A young couple with a kid look after a hotel during winter and the husband goes insane. 
        +         Ghostkeeper
        +     Killing Ground
        +Leopard in the Snow
        +              Stone
        +          Afterglow
        +         Unfaithful
        +     Always a Bride 
        +
        +

        예상대로 퍼널 검색이나 일반 검색보다 리콜률이 훨씬 떨어집니다(임베딩 모델은 접미사가 아닌 임베딩 차원의 접두사에 대한 대조 학습을 통해 학습되었습니다).

        +

        요약

        다음은 여러 방법의 검색 결과를 비교한 것입니다:

        +
        +
        +
        +"퍼널 검색"이라는 보다 효율적인 시맨틱 검색 알고리즘을 수행하기 위해 Milvus와 함께 Matryoshka 임베딩을 사용하는 방법을 보여드렸습니다. 또한 알고리즘의 순위 재지정 및 가지치기 단계의 중요성과 초기 후보 목록이 너무 작을 때의 실패 모드에 대해서도 살펴봤습니다. 마지막으로, 하위 임베딩을 구성할 때 차원 순서가 얼마나 중요한지, 즉 모델이 학습된 것과 같은 방식이어야 하는지에 대해 논의했습니다. 또는 오히려 모델이 특정 방식으로 학습되었기 때문에 임베딩의 접두사가 의미가 있는 것입니다. 이제 검색 성능을 크게 저하시키지 않으면서도 시맨틱 검색의 저장 비용을 줄이기 위해 마트료시카 임베딩과 퍼널 검색을 구현하는 방법을 알게 되었습니다! diff --git a/localization/v2.4.x/site/ko/tutorials/tutorials-overview.md b/localization/v2.4.x/site/ko/tutorials/tutorials-overview.md index 871d0da4c..69145de95 100644 --- a/localization/v2.4.x/site/ko/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/ko/tutorials/tutorials-overview.md @@ -43,5 +43,6 @@ title: 튜토리얼 개요
        +
        개체 유형권한 이름클라이언트 측의 관련 API 설명
        Milvus로 다중 모달 검색에 ColPali 사용빠른 시작벡터 검색
        벡터 시각화빠른 시작벡터 검색
        Milvus를 사용한 영화 추천추천 시스템벡터 검색
        마트료시카 임베딩을 사용한 퍼널 검색빠른 시작벡터 검색
        diff --git a/localization/v2.4.x/site/ko/userGuide/manage-collections.json b/localization/v2.4.x/site/ko/userGuide/manage-collections.json index 4c914a9d3..1911d5f88 100644 --- a/localization/v2.4.x/site/ko/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/ko/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"컬렉션 관리","href":"Manage-Collections","type":1,"isActive":false},{"label":"시작하기 전에","href":"Before-you-start","type":2,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"컬렉션 만들기","href":"Create-Collection","type":2,"isActive":false},{"label":"컬렉션 보기","href":"View-Collections","type":2,"isActive":false},{"label":"컬렉션 로드 및 릴리스","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"별칭 설정","href":"Set-up-aliases","type":2,"isActive":false},{"label":"속성 설정","href":"Set-Properties","type":2,"isActive":false},{"label":"컬렉션 삭제","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"컬렉션 관리","href":"Manage-Collections","type":1,"isActive":false},{"label":"시작하기 전에","href":"Before-you-start","type":2,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"컬렉션 만들기","href":"Create-Collection","type":2,"isActive":false},{"label":"컬렉션 보기","href":"View-Collections","type":2,"isActive":false},{"label":"컬렉션 로드 및 릴리스","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"별칭 설정","href":"Set-up-aliases","type":2,"isActive":false},{"label":"속성 설정","href":"Set-Properties","type":2,"isActive":false},{"label":"컬렉션 삭제","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/userGuide/manage-collections.md b/localization/v2.4.x/site/ko/userGuide/manage-collections.md index 6f2c52b1b..c38a99f8d 100644 --- a/localization/v2.4.x/site/ko/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/ko/userGuide/manage-collections.md @@ -617,7 +617,7 @@ indexParams.add(indexParamForVectorField); -

        위의 코드 조각은 각각 벡터 필드와 스칼라 필드에 대한 인덱스 파라미터를 설정하는 방법을 보여줍니다. 벡터 필드의 경우 메트릭 유형과 인덱스 유형을 모두 설정합니다. 스칼라 필드의 경우 인덱스 유형만 설정합니다. 필터링에 자주 사용되는 벡터 필드와 스칼라 필드에 대한 인덱스를 만드는 것이 좋습니다.

        +

        위의 코드 조각은 각각 벡터 필드와 스칼라 필드에 대한 인덱스 매개 변수를 설정하는 방법을 보여줍니다. 벡터 필드의 경우 메트릭 유형과 인덱스 유형을 모두 설정합니다. 스칼라 필드의 경우 인덱스 유형만 설정합니다. 필터링에 자주 사용되는 벡터 필드와 스칼라 필드에 대한 인덱스를 만드는 것이 좋습니다.

        3단계: 컬렉션 만들기

        컬렉션과 인덱스 파일을 따로 만들거나, 만들 때 인덱스가 동시에 로드된 컬렉션을 만들 수 있습니다.

        create_collection()을 사용하여 지정된 스키마 및 인덱스 매개변수로 컬렉션을 생성하고 get_load_state()를 사용하여 컬렉션의 로드 상태를 확인합니다.

        @@ -881,11 +881,11 @@ $ curl -X POST "http://schema
        -이 컬렉션의 스키마입니다.
        이를 없음으로 설정하면 이 컬렉션이 기본 설정으로 만들어집니다.
        사용자 정의 스키마로 컬렉션을 설정하려면 CollectionSchema 개체를 만들어 여기에서 참조해야 합니다. 이 경우 Milvus는 요청에 포함된 다른 모든 스키마 관련 설정을 무시합니다. +이 컬렉션의 스키마입니다.
        이를 없음으로 설정하면 이 컬렉션이 기본 설정으로 생성됩니다.
        사용자 정의 스키마로 컬렉션을 설정하려면 CollectionSchema 객체를 만들어 여기에서 참조해야 합니다. 이 경우 Milvus는 요청에 포함된 다른 모든 스키마 관련 설정을 무시합니다. index_params -이 컬렉션의 벡터 필드에 인덱스를 구축하기 위한 매개변수입니다. 사용자 정의 스키마로 컬렉션을 설정하고 컬렉션을 메모리에 자동으로 로드하려면 IndexParams 개체를 만들고 여기에서 참조해야 합니다.
        이 컬렉션의 벡터 필드에 대한 인덱스를 최소한 추가해야 합니다. 나중에 인덱스 매개변수를 설정하려는 경우 이 매개변수를 건너뛸 수도 있습니다. +이 컬렉션의 벡터 필드에 인덱스를 구축하기 위한 매개변수입니다. 사용자 정의 스키마로 컬렉션을 설정하고 컬렉션을 메모리에 자동으로 로드하려면 IndexParams 개체를 만들고 여기에서 참조해야 합니다.
        이 컬렉션의 벡터 필드에 대한 인덱스는 최소한 추가해야 합니다. 나중에 인덱스 매개변수를 설정하려는 경우 이 매개변수를 건너뛸 수도 있습니다.

        @@ -1482,7 +1482,7 @@ System.out.println(listCollectionsRes.getCollectionNames()); >

        컬렉션을 로드하는 과정에서 Milvus는 컬렉션의 인덱스 파일을 메모리에 로드합니다. 반대로 컬렉션을 해제할 때는 Milvus가 메모리에서 인덱스 파일을 언로드합니다. 컬렉션에서 검색을 수행하기 전에 컬렉션이 로드되었는지 확인하세요.

        -

        컬렉션 로드하기

        +

        컬렉션 로드

        컬렉션을 로드하려면 컬렉션 이름을 지정하여 load_collection() 메서드를 사용하여 컬렉션 이름을 지정합니다. 또한 replica_number 을 설정하여 컬렉션이 로드될 때 쿼리 노드에 생성할 데이터 세그먼트의 인메모리 복제본 수를 결정할 수 있습니다.

        • Milvus 독립형: replica_number 의 최대 허용 값은 1입니다.
        • @@ -1601,7 +1601,7 @@ $ curl -X POST "http://# 7. Load the collection client.load_collection( collection_name="customized_setup_2", - load_fields=["my_id", "my_vector"] # Load only the specified fields + load_fields=["my_id", "my_vector"], # Load only the specified fields skip_load_dynamic_field=True # Skip loading the dynamic field ) @@ -1735,7 +1735,7 @@ $ curl -X POST "http:// -

          컬렉션에 별칭을 지정하여 컬렉션을 특정 맥락에서 더 의미 있게 만들 수 있습니다. 컬렉션에 별칭을 여러 개 지정할 수 있지만 여러 컬렉션이 별칭을 공유할 수는 없습니다.

          +

          컬렉션에 별칭을 지정하여 컬렉션을 특정 맥락에서 더 의미 있게 만들 수 있습니다. 컬렉션에 여러 개의 별칭을 지정할 수 있지만 여러 컬렉션이 하나의 별칭을 공유할 수는 없습니다.

          별칭 만들기

          별칭을 만들려면 컬렉션 이름과 create_alias() 메서드를 사용하여 컬렉션 이름과 별칭을 지정합니다.

          @@ -2240,7 +2240,7 @@ $ curl -X POST "http://dropAlias() 메서드를 사용하여 별칭을 지정합니다.

        -

        컬렉션에 대한 별칭을 삭제하려면 POST /v2/vectordb/aliases/drop API 엔드포인트를 사용하면 됩니다.

        +

        컬렉션의 별칭을 삭제하려면 컬렉션의 POST /v2/vectordb/aliases/drop API 엔드포인트를 사용하면 됩니다.

        @@ -2334,7 +2334,7 @@ $ curl -X POST "http://

        이 섹션의 코드 스니펫은 PyMilvus ORM 모듈을 사용하여 Milvus와 상호 작용합니다. 새로운 MilvusClient SDK가 포함된 코드 스니펫은 곧 제공될 예정입니다.

        -

        TTL 설정

        컬렉션의 데이터에 대한 TTL(Time-To-Live)을 설정하여 데이터가 자동으로 삭제되기 전에 유지되어야 하는 기간을 지정합니다.

        +

        TTL 설정

        컬렉션에 있는 데이터의 TTL(Time-To-Live)을 설정하여 데이터가 자동으로 삭제되기 전에 유지되어야 하는 기간을 지정합니다.

        from pymilvus import Collection, connections
         
         # Connect to Milvus server
        diff --git a/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.json
        index 3cb8d7f5b..baf09fa40 100644
        --- a/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.json
        +++ b/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.json
        @@ -1 +1 @@
        -{"codeList":["# Auto indexing\nclient = MilvusClient(\n    uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n    field_name=\"scalar_1\", # Name of the scalar field to be indexed\n    index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n    index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n  collection_name=\"test_scalar_index\", # Specify the collection name\n  index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n    .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n    .indexName(\"default_index\") // Name of the index to be created\n    .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n    .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n    .collectionName(\"test_scalar_index\") // Specify the collection name\n    .indexParams(indexParams)\n    .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n    collection_name: \"test_scalar_index\", // Specify the collection name\n    field_name: \"scalar_1\", // Name of the scalar field to be indexed\n    index_name: \"default_index\", // Name of the index to be created\n    index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() #  Prepare an IndexParams object\n\nindex_params.add_index(\n    field_name=\"scalar_2\", # Name of the scalar field to be indexed\n    index_type=\"INVERTED\", # Type of index to be created\n    index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n  collection_name=\"test_scalar_index\", # Specify the collection name\n  index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n    .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n    .indexName(\"inverted_index\") // Name of the index to be created\n    .indexType(\"INVERTED\") // Type of index to be created\n    .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n    .collectionName(\"test_scalar_index\") // Specify the collection name\n    .indexParams(indexParams)\n    .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n    collection_name: \"test_scalar_index\", // Specify the collection name\n    field_name: \"scalar_1\", // Name of the scalar field to be indexed\n    index_name: \"inverted_index\", // Name of the index to be created\n    index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n    collection_name=\"test_scalar_index\"  # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n    .collectionName(\"test_scalar_index\")  // Specify the collection name\n    .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n//     \"default_index\",\n//     \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n    collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n//     \"default_index\",\n//     \"inverted_index\"\n// ]   \n"],"headingContent":"","anchorList":[{"label":"스칼라 필드 인덱스","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"스칼라 인덱싱의 유형","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"자동 인덱싱","href":"Auto-indexing","type":2,"isActive":false},{"label":"사용자 정의 인덱싱","href":"Custom-indexing","type":2,"isActive":false},{"label":"결과 확인","href":"Verifying-the-result","type":2,"isActive":false},{"label":"제한","href":"Limits","type":2,"isActive":false}]}
        \ No newline at end of file
        +{"codeList":["# Auto indexing\nclient = MilvusClient(\n    uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n    field_name=\"scalar_1\", # Name of the scalar field to be indexed\n    index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n    index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n  collection_name=\"test_scalar_index\", # Specify the collection name\n  index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n    .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n    .indexName(\"default_index\") // Name of the index to be created\n    .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n    .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n    .collectionName(\"test_scalar_index\") // Specify the collection name\n    .indexParams(indexParams)\n    .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n    collection_name: \"test_scalar_index\", // Specify the collection name\n    field_name: \"scalar_1\", // Name of the scalar field to be indexed\n    index_name: \"default_index\", // Name of the index to be created\n    index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() #  Prepare an IndexParams object\n\nindex_params.add_index(\n    field_name=\"scalar_2\", # Name of the scalar field to be indexed\n    index_type=\"INVERTED\", # Type of index to be created\n    index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n  collection_name=\"test_scalar_index\", # Specify the collection name\n  index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n    .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n    .indexName(\"inverted_index\") // Name of the index to be created\n    .indexType(\"INVERTED\") // Type of index to be created\n    .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n    .collectionName(\"test_scalar_index\") // Specify the collection name\n    .indexParams(indexParams)\n    .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n    collection_name: \"test_scalar_index\", // Specify the collection name\n    field_name: \"scalar_1\", // Name of the scalar field to be indexed\n    index_name: \"inverted_index\", // Name of the index to be created\n    index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n    collection_name=\"test_scalar_index\"  # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n    .collectionName(\"test_scalar_index\")  // Specify the collection name\n    .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n//     \"default_index\",\n//     \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n    collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n//     \"default_index\",\n//     \"inverted_index\"\n// ]   \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"스칼라 필드 인덱스","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"스칼라 인덱싱의 유형","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"자동 인덱싱","href":"Auto-indexing","type":2,"isActive":false},{"label":"사용자 정의 인덱싱","href":"Custom-indexing","type":2,"isActive":false},{"label":"결과 확인","href":"Verifying-the-result","type":2,"isActive":false},{"label":"제한","href":"Limits","type":2,"isActive":false}]}
        \ No newline at end of file
        diff --git a/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.md
        index cdd293afe..03b95fbc1 100644
        --- a/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.md
        +++ b/localization/v2.4.x/site/ko/userGuide/manage-indexes/index-scalar-fields.md
        @@ -2,7 +2,7 @@
         id: index-scalar-fields.md
         order: 2
         summary: '이 가이드에서는 정수, 문자열 등과 같은 필드에 대한 스칼라 인덱스를 만들고 구성하는 방법을 안내합니다.'
        -title: 인덱스 스칼라 필드
        +title: 스칼라 필드 인덱스
         ---
         

        스칼라 필드 인덱스

        -

        자동 인덱싱을 사용하려면 인덱스 유형 매개변수를 생략하세요. add_index()에서 인덱스 유형 매개변수를 생략하면 Milvus가 스칼라 필드 유형에 따라 인덱스 유형을 유추할 수 있습니다.

        +

        자동 인덱싱을 사용하려면 인덱스 유형 매개변수를 생략하세요. add_index()에서 인덱스 유형 매개변수를 생략하면 Milvus가 스칼라 필드 유형을 기반으로 인덱스 유형을 유추할 수 있습니다.

        자동 인덱싱을 사용하려면, 에서 indexType 매개변수를 생략하세요. IndexParam에서 인덱스 유형 매개변수를 생략하여 Milvus가 스칼라 필드 유형을 기반으로 인덱스 유형을 유추할 수 있도록 합니다.

        @@ -71,7 +71,7 @@ client = MilvusClient( uri="http://localhost:19530" ) -index_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters +index_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters index_params.add_index( field_name="scalar_1", # Name of the scalar field to be indexed @@ -137,7 +137,7 @@ client.createIndex(createIndexReq);

        아래 예제는 스칼라 필드 scalar_2 에 대한 반전 인덱스를 생성합니다.

        -
        index_params = client.create_index_params() #  Prepare an IndexParams object
        +
        index_params = MilvusClient.prepare_index_params() #  Prepare an IndexParams object
         
         index_params.add_index(
             field_name="scalar_2", # Name of the scalar field to be indexed
        @@ -179,7 +179,7 @@ client.createIndex(createIndexReq);
         

        메서드 및 매개변수

          -
        • create_index_params()

          +
        • prepare_index_params()

          IndexParams 객체를 준비합니다.

        • add_index()

          IndexParams 객체에 인덱스 구성을 추가합니다.

          diff --git a/localization/v2.4.x/site/ko/userGuide/manage-partitions.json b/localization/v2.4.x/site/ko/userGuide/manage-partitions.json index 6d439c520..962d7f356 100644 --- a/localization/v2.4.x/site/ko/userGuide/manage-partitions.json +++ b/localization/v2.4.x/site/ko/userGuide/manage-partitions.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"파티션 관리","href":"Manage-Partitions","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비","href":"Preparations","type":2,"isActive":false},{"label":"목록 파티션","href":"List-Partitions","type":2,"isActive":false},{"label":"파티션 만들기","href":"Create-Partitions","type":2,"isActive":false},{"label":"특정 파티션 확인","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"파티션 로드 및 해제","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"파티션 삭제","href":"Drop-Partitions","type":2,"isActive":false},{"label":"FAQ","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"파티션 관리","href":"Manage-Partitions","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비","href":"Preparations","type":2,"isActive":false},{"label":"목록 파티션","href":"List-Partitions","type":2,"isActive":false},{"label":"파티션 만들기","href":"Create-Partitions","type":2,"isActive":false},{"label":"특정 파티션 확인","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"파티션 로드 및 해제","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"파티션 삭제","href":"Drop-Partitions","type":2,"isActive":false},{"label":"FAQ","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/userGuide/manage-partitions.md b/localization/v2.4.x/site/ko/userGuide/manage-partitions.md index 04139f7d6..f55245395 100644 --- a/localization/v2.4.x/site/ko/userGuide/manage-partitions.md +++ b/localization/v2.4.x/site/ko/userGuide/manage-partitions.md @@ -652,7 +652,7 @@ res = await client."partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionA" ) @@ -663,7 +663,7 @@ res = client.get_load_status( # "state": "<LoadState: Loaded>" # } -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionB" ) @@ -820,7 +820,7 @@ res = await client."_default", "partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", ) diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.json b/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.json index dbd5063c4..684497baf 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.json +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.json @@ -1 +1 @@ -{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"10.102.7.3\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"","anchorList":[{"label":"하이브리드 검색","href":"Hybrid-Search","type":1,"isActive":false},{"label":"준비 사항","href":"Preparations","type":2,"isActive":false},{"label":"1단계: 여러 개의 AnnSearchRequest 인스턴스 만들기","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"2단계: 재랭크 전략 구성하기","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"3단계: 하이브리드 검색 수행","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"제한","href":"Limits","type":2,"isActive":false},{"label":"FAQ","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"127.0.0.1\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"Hybrid Search","anchorList":[{"label":"하이브리드 검색","href":"Hybrid-Search","type":1,"isActive":false},{"label":"준비 사항","href":"Preparations","type":2,"isActive":false},{"label":"1단계: 여러 개의 AnnSearchRequest 인스턴스 만들기","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"2단계: 재랭크 전략 구성하기","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"3단계: 하이브리드 검색 수행","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"제한","href":"Limits","type":2,"isActive":false},{"label":"FAQ","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.md b/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.md index d2c5d455a..44e64b3c7 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.md +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/multi-vector-search.md @@ -19,7 +19,7 @@ title: 하이브리드 검색 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

          Milvus 2.4부터 다중 벡터 지원과 하이브리드 검색 프레임워크가 도입되어 사용자가 여러 개의 벡터 필드(최대 10개)를 하나의 컬렉션으로 가져올 수 있게 되었습니다. 서로 다른 열에 있는 이러한 벡터는 서로 다른 임베딩 모델에서 비롯되거나 서로 다른 처리 방법을 거친 데이터의 다양한 측면을 나타냅니다. 하이브리드 검색의 결과는 상호 순위 융합(RRF) 및 가중치 점수 등의 순위 재조정 전략을 사용해 통합됩니다. 순위 재조정 전략에 대해 자세히 알아보려면 순위 재조정을 참조하세요.

          +

          Milvus 2.4부터 다중 벡터 지원과 하이브리드 검색 프레임워크가 도입되어 사용자가 여러 개의 벡터 필드(최대 10개)를 하나의 컬렉션으로 가져올 수 있게 되었습니다. 서로 다른 열에 있는 이러한 벡터는 서로 다른 임베딩 모델에서 비롯되거나 서로 다른 처리 방법을 거친 데이터의 다양한 측면을 나타냅니다. 하이브리드 검색의 결과는 상호 순위 융합(RRF) 및 가중치 점수 등의 순위 재조정 전략을 사용해 통합됩니다. 순위 재조정 전략에 대해 자세히 알아보려면 순위 재조정을 참조하세요.

          이 기능은 사진, 음성, 지문 등과 같은 다양한 속성을 기반으로 벡터 라이브러리에서 가장 유사한 사람을 식별하는 등 포괄적인 검색 시나리오에서 특히 유용합니다.

          이 튜토리얼에서는 그 방법을 배웁니다:

            @@ -52,7 +52,7 @@ title: 하이브리드 검색 # Connect to Milvus connections.connect( - host="10.102.7.3", # Replace with your Milvus server IP + host="127.0.0.1", # Replace with your Milvus server IP port="19530" ) @@ -152,7 +152,7 @@ reqs = [request_1, request_2]
          • AnnSearchRequest (객체)

            ANN 검색 요청을 나타내는 클래스입니다. 각 하이브리드 검색에는 한 번에 1개에서 1,024개의 ANNSearchRequest 개체가 포함될 수 있습니다.

          • data (목록)

            -

            단일 AnnSearchRequest 에서 검색할 쿼리 벡터입니다. 현재 이 매개변수는 단일 쿼리 벡터만 포함된 목록(예: [[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]])을 허용합니다. 향후 이 매개변수는 여러 쿼리 벡터를 허용하도록 확장될 예정입니다.

          • +

            단일 AnnSearchRequest 에서 검색할 쿼리 벡터입니다. 현재 이 매개변수는 단일 쿼리 벡터(예: [[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]])만 포함된 목록을 허용합니다. 향후 이 매개변수는 여러 쿼리 벡터를 허용하도록 확장될 예정입니다.

          • anns_field (문자열)

            단일 AnnSearchRequest 에 사용할 벡터 필드의 이름입니다.

          • param (딕셔너리)

            @@ -274,7 +274,7 @@ res = collection.hybrid_search(
            • 하이브리드 검색은 어떤 시나리오에서 권장되나요?

              -

              하이브리드 검색은 높은 정확도가 요구되는 복잡한 상황, 특히 엔티티가 여러 개의 다양한 벡터로 표현될 수 있는 경우에 이상적입니다. 이는 문장과 같은 동일한 데이터가 서로 다른 임베딩 모델을 통해 처리되거나 개인의 이미지, 지문, 음성 등 복합적인 정보가 다양한 벡터 형식으로 변환되는 경우에 적용됩니다. 이러한 벡터에 가중치를 부여하면 그 영향력이 결합되어 기억력을 크게 향상시키고 검색 결과의 효율성을 높일 수 있습니다.

            • +

              하이브리드 검색은 높은 정확도가 요구되는 복잡한 상황, 특히 엔티티가 여러 개의 다양한 벡터로 표현될 수 있는 경우에 이상적입니다. 이는 문장과 같은 동일한 데이터가 서로 다른 임베딩 모델을 통해 처리되거나 개인의 이미지, 지문, 음성 지문과 같은 다중 모드 정보가 다양한 벡터 형식으로 변환되는 경우에 적용됩니다. 이러한 벡터에 가중치를 부여하면 그 영향력이 결합되어 기억력을 크게 향상시키고 검색 결과의 효율성을 높일 수 있습니다.

            • 가중치 랭킹러는 서로 다른 벡터 필드 간의 거리를 어떻게 정규화하나요?

              가중치 랭커는 각 필드에 할당된 가중치를 사용하여 벡터 필드 간의 거리를 정규화합니다. 가중치에 따라 각 벡터 필드의 중요도를 계산하여 가중치가 높은 필드의 우선순위를 지정합니다. 일관성을 보장하기 위해 ANN 검색 요청 전체에 동일한 메트릭 유형을 사용하는 것이 좋습니다. 이 방법을 사용하면 더 중요하다고 판단되는 벡터가 전체 순위에 더 큰 영향을 미치게 됩니다.

            • 코히어 랭커나 BGE 랭커와 같은 대체 랭커를 사용할 수 있나요?

              diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.json index c7a0372b0..70411eb91 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"단일 벡터 검색","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비 사항","href":"Preparations","type":2,"isActive":false},{"label":"기본 검색","href":"Basic-search","type":2,"isActive":false},{"label":"필터 검색","href":"Filtered-search","type":2,"isActive":false},{"label":"범위 검색","href":"Range-search","type":2,"isActive":false},{"label":"그룹 검색","href":"Grouping-search","type":2,"isActive":false},{"label":"검색 매개변수","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"단일 벡터 검색","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비 사항","href":"Preparations","type":2,"isActive":false},{"label":"기본 검색","href":"Basic-search","type":2,"isActive":false},{"label":"필터 검색","href":"Filtered-search","type":2,"isActive":false},{"label":"범위 검색","href":"Range-search","type":2,"isActive":false},{"label":"그룹 검색","href":"Grouping-search","type":2,"isActive":false},{"label":"검색 매개변수","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.md index 9b169ecf5..7fa9adbc1 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/single-vector-search.md @@ -19,10 +19,10 @@ title: 단일 벡터 검색 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

              데이터를 삽입하고 나면 다음 단계는 Milvus에서 컬렉션에 대한 유사도 검색을 수행하는 것입니다.

              +

              데이터를 삽입한 다음 단계는 Milvus에서 컬렉션에 대한 유사도 검색을 수행하는 것입니다.

              Milvus에서는 컬렉션의 벡터 필드 수에 따라 두 가지 유형의 검색을 수행할 수 있습니다:

                -
              • 단일 벡터 검색: 컬렉션에 벡터 필드가 하나만 있는 경우, 가장 유사한 엔티티를 찾기 위해 search() 메서드를 사용하여 가장 유사한 엔티티를 찾습니다. 이 방법은 쿼리 벡터를 컬렉션의 기존 벡터와 비교하여 가장 가까운 일치 항목의 ID와 그 사이의 거리를 반환합니다. 선택적으로 결과의 벡터 값과 메타데이터도 반환할 수 있습니다.
              • +
              • 단일 벡터 검색: 컬렉션에 벡터 필드가 하나만 있는 경우, 가장 유사한 엔티티를 찾기 위해 search() 메서드를 사용하여 가장 유사한 엔티티를 찾습니다. 이 방법은 쿼리 벡터를 컬렉션에 있는 기존 벡터와 비교하여 가장 가까운 일치 항목의 ID와 그 사이의 거리를 반환합니다. 선택적으로 결과의 벡터 값과 메타데이터도 반환할 수 있습니다.
              • 하이브리드 검색: 두 개 이상의 벡터 필드가 있는 컬렉션의 경우에는 hybrid_search() 메서드를 사용합니다. 이 방법은 여러 개의 근사 이웃(ANN) 검색 요청을 수행하고 그 결과를 결합하여 순위를 다시 매긴 후 가장 관련성이 높은 일치 항목을 반환합니다.

              이 가이드는 Milvus에서 단일 벡터 검색을 수행하는 방법에 중점을 두고 있습니다. 하이브리드 검색에 대한 자세한 내용은 하이브리드 검색을 참조하세요.

              @@ -41,12 +41,12 @@ title: 단일 벡터 검색 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

              다양한 요구 사항을 충족하는 다양한 검색 유형이 있습니다:

              +

              다양한 요구 사항을 충족하기 위한 다양한 검색 유형이 있습니다:

              • 기본 검색: 단일 벡터 검색, 일괄 벡터 검색, 파티션 검색, 지정된 출력 필드를 사용한 검색이 포함됩니다.

              • 필터링된 검색: 스칼라 필드를 기반으로 필터링 기준을 적용하여 검색 결과를 구체화합니다.

              • 범위 검색: 쿼리 벡터로부터 특정 거리 범위 내의 벡터를 찾습니다.

              • -
              • 그룹 검색: 특정 필드를 기준으로 검색 결과를 그룹화하여 결과의 다양성을 보장합니다.

              • +
              • 그룹화 검색: 특정 필드를 기준으로 검색 결과를 그룹화하여 결과의 다양성을 보장합니다.

              준비 사항

              아래 코드 스니펫은 기존 코드를 재구성하여 Milvus에 연결하고 컬렉션을 빠르게 설정합니다.

              -
              # 1. Set up a Milvus client
              +
              from pymilvus import MilvusClient
              +import random
              +
              +# 1. Set up a Milvus client
               client = MilvusClient(
              -    uri=CLUSTER_ENDPOINT,
              -    token=TOKEN 
              +    uri="http://localhost:19530"
               )
               
               # 2. Create a collection
              @@ -447,7 +449,7 @@ res = await client.Python  Java Node.js
        # Single vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             # Replace with your query vector
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
        @@ -544,7 +546,7 @@ res = await client.data
        -      벡터 임베딩의 목록.
        Milvus는 지정된 벡터 임베딩과 가장 유사한 벡터 임베딩을 검색합니다. + 벡터 임베딩 목록.
        Milvus는 지정된 벡터 임베딩과 가장 유사한 벡터 임베딩을 검색합니다. limit @@ -641,7 +643,7 @@ res = await client.Python Java Node.js
        # Bulk-vector search
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[
                 [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
                 [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
        @@ -1226,7 +1228,7 @@ searchResp = client.search(searchReq);
            Python  Java Node.js
        # Search with output fields
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1374,7 +1376,7 @@ res = await client.Python  Java Node.js
         
        # Search with filter
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1481,7 +1483,7 @@ res = await client.파이썬  자바 Node.js
         
        # Infix match on color field
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=5, # Max. number of search results to return
             search_params={"metric_type": "IP", "params": {}}, # Search parameters
        @@ -1582,7 +1584,7 @@ search_params = {
         }
         
         res = client.search(
        -    collection_name="test_collection", # Replace with the actual name of your collection
        +    collection_name="quick_setup", # Replace with the actual name of your collection
             data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
             limit=3, # Max. number of search results to return
             search_params=search_params, # Search parameters
        @@ -1829,7 +1831,7 @@ search_parameters = {
         매개변수 이름매개변수 설명
         
         
        -metric_type벡터 임베딩 간의 유사성을 측정하는 방법입니다.
        사용 가능한 값은 IP, L2, COSINE, JACCARD, HAMMING 이며 기본값은 로드된 인덱스 파일의 값입니다. +metric_type벡터 임베딩 간의 유사성을 측정하는 방법입니다.
        사용 가능한 값은 IP, L2, COSINE, JACCARD, HAMMING 이며, 기본값은 로드된 인덱스 파일의 값입니다. params.nprobe검색 중에 쿼리할 단위 수입니다.
        값은 [1, nlist[1]] 범위에 속합니다. params.level검색 정밀도 수준.
        가능한 값은 1, 2, 3 이며 기본값은 1 입니다. 값이 높을수록 더 정확한 결과를 얻을 수 있지만 성능이 느려집니다. params.radius검색 공간의 외부 경계를 정의합니다. 쿼리 벡터로부터 이 거리 내에 있는 벡터만 잠재적 일치 항목으로 간주됩니다.
        값 범위는 metric_type 매개변수에 의해 결정됩니다. 예를 들어 metric_typeL2 으로 설정된 경우 유효한 값 범위는 [0, ∞] 입니다. metric_typeCOSINE 로 설정된 경우 유효한 값 범위는 [-1, 1] 입니다. 자세한 내용은 유사성 지표를 참조하세요. @@ -1838,6 +1840,6 @@ search_parameters = {

        참고

        -

        [1] 인덱싱 후 클러스터 단위 수입니다. 컬렉션을 인덱싱할 때 Milvus는 벡터 데이터를 여러 클러스터 단위로 세분화하며, 그 수는 실제 인덱스 설정에 따라 달라집니다.

        +

        [1] 인덱싱 후 클러스터 단위 수입니다. 컬렉션을 색인할 때 Milvus는 벡터 데이터를 여러 개의 클러스터 단위로 세분화하며, 그 수는 실제 색인 설정에 따라 달라집니다.

        [2] 검색에서 반환할 엔티티의 수입니다.

        diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.json b/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.json index 3ceaccc68..ffdd11d87 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.json +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"이터레이터 사용","href":"With-Iterators","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비 단계","href":"Preparations","type":2,"isActive":false},{"label":"반복기를 사용한 검색","href":"Search-with-iterator","type":2,"isActive":false},{"label":"반복기를 사용한 쿼리","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection,connections\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"이터레이터 사용","href":"With-Iterators","type":1,"isActive":false},{"label":"개요","href":"Overview","type":2,"isActive":false},{"label":"준비 단계","href":"Preparations","type":2,"isActive":false},{"label":"반복기를 사용한 검색","href":"Search-with-iterator","type":2,"isActive":false},{"label":"반복기를 사용한 쿼리","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.md b/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.md index 9fee57e7f..f33a986a3 100644 --- a/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.md +++ b/localization/v2.4.x/site/ko/userGuide/search-query-get/with-iterators.md @@ -19,7 +19,7 @@ title: 이터레이터 사용 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        Milvus는 대량의 엔티티를 반복할 수 있는 검색 및 쿼리 반복기를 제공합니다. Milvus는 TopK를 16384로 제한하므로 사용자는 반복기를 사용하여 일괄 모드에서 컬렉션의 많은 수 또는 전체 엔티티를 반환할 수 있습니다.

        +

        Milvus는 대량의 엔티티를 반복할 수 있는 검색 및 쿼리 반복기를 제공합니다. Milvus는 TopK를 16384로 제한하므로 사용자는 일괄 모드에서 컬렉션의 많은 수 또는 전체 엔티티를 반환하는 데 반복기를 사용할 수 있습니다.

        개요

        4. Migrar os metadados

        Uma grande mudança no Milvus 2.2 é a estrutura de metadados dos índices de segmento. Por conseguinte, é necessário utilizar o Helm para migrar os metadados durante a atualização do Milvus da v2.1.x para a v2.2.0. Eis um script para migrar os metadados em segurança.

        -

        Este script só se aplica ao Milvus instalado em um cluster K8s. Se ocorrer um erro durante o processo, reverta primeiro para a versão anterior com a operação de reversão.

        +

        Este script se aplica apenas ao Milvus instalado em um cluster K8s. Se ocorrer um erro durante o processo, reverta primeiro para a versão anterior com a operação de reversão.

        A tabela seguinte lista as operações que pode efetuar para a meta-migração.

        @@ -231,29 +231,29 @@ my-release-pulsar-zookeeper-2

        1. Migrar os metadados

        1. Descarregar o script de migração.
        2. Parar os componentes do Milvus. Qualquer sessão em direto no Milvus etcd pode causar uma falha na migração.
        3. -
        4. Crie uma cópia de segurança dos metadados do Milvus.
        5. +
        6. Crie uma cópia de segurança para os metadados do Milvus.
        7. Migrar os metadados do Milvus.
        8. Inicie os componentes do Milvus com uma nova imagem.
        -

        2. Atualizar o Milvus da v2.1.x para a 2.4.15

        Os comandos a seguir assumem que você atualizou o Milvus da v2.1.4 para a 2.4.15. Altere-os para as versões que atendam às suas necessidades.

        +

        2. Atualizar o Milvus da v2.1.x para a 2.2.0

        Os comandos a seguir assumem que você atualizou o Milvus da v2.1.4 para a 2.2.0. Altere-os para as versões que atendam às suas necessidades.

          -
        1. Especifique o nome da instância do Milvus, a versão de origem do Milvus e a versão de destino do Milvus.

          -
          ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
          +
        2. Especifique o nome da instância do Milvus, a versão do Milvus de origem e a versão do Milvus de destino.

          +
          ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
           
        3. Especifique o espaço de nomes com -n se o seu Milvus não estiver instalado no espaço de nomes K8s predefinido.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
           
        4. Especifique o caminho da raiz com -r se o seu Milvus estiver instalado com o rootpath personalizado.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
           
        5. Especifique a tag de imagem com -w se o seu Milvus estiver instalado com um image personalizado.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
           
        6. Defina -d true se pretender remover automaticamente o pod de migração após a conclusão da migração.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
           
        7. Reverter e migrar novamente se a migração falhar.

          -
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
          -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
          +
          ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
          +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
           
        diff --git a/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.json index a4797f7ff..65ce6cfec 100644 --- a/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"","anchorList":[{"label":"Executar o Milvus no Kubernetes com o Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Pré-requisitos","href":"Prerequisites","type":2,"isActive":false},{"label":"Instalar o Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Instalação online","href":"Online-install","type":2,"isActive":false},{"label":"Instalação offline","href":"Offline-install","type":2,"isActive":false},{"label":"Atualizar o cluster do Milvus em execução","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Desinstalar o Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"O que vem a seguir","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"Executar o Milvus no Kubernetes com o Helm","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Pré-requisitos","href":"Prerequisites","type":2,"isActive":false},{"label":"Instalar o Milvus Helm Chart","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"Instalação online","href":"Online-install","type":2,"isActive":false},{"label":"Instalação offline","href":"Offline-install","type":2,"isActive":false},{"label":"Atualizar o cluster do Milvus em execução","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"Desinstalar o Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"O que vem a seguir","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.md index f23e9e59f..3bf77f479 100644 --- a/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/pt/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -83,11 +83,11 @@ NAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDI >

        Antes de instalar o Milvus Helm Charts, é necessário adicionar o repositório Milvus Helm.

        -
        $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
        +
        $ helm repo add milvus https://github.com/zilliztech/milvus-helm
         
        -

        O repositório do Milvus Helm Charts em https://milvus-io.github.io/milvus-helm/ foi arquivado e pode obter mais actualizações em https://zilliztech.github.io/milvus-helm/ da seguinte forma:

        -
        helm repo add zilliztech https://zilliztech.github.io/milvus-helm
        +

        O repositório do Milvus Helm Charts em https://github.com/milvus-io/milvus-helm foi arquivado e pode obter mais actualizações em https://github.com/zilliztech/milvus-helm da seguinte forma:

        +
        helm repo add zilliztech https://github.com/zilliztech/milvus-helm
         helm repo update
         # upgrade existing helm release
         helm upgrade my-release zilliztech/milvus
        @@ -122,14 +122,14 @@ helm upgrade my-release zilliztech/milvus
           
        • O nome da versão deve conter apenas letras, números e traços. Não são permitidos pontos no nome da versão.
        • A linha de comando padrão instala a versão de cluster do Milvus durante a instalação do Milvus com o Helm. São necessárias outras definições durante a instalação do Milvus autónomo.
        • -
        • De acordo com o guia de migração de API obsoleta do Kubernetes, a versão da API policy/v1beta1 do PodDisruptionBudget não é mais servida a partir da v1.25. Sugere-se que você migre manifestos e clientes de API para usar a versão de API policy/v1.
          Como solução alternativa para os usuários que ainda usam a versão da API policy/v1beta1 do PodDisruptionBudget no Kubernetes v1.25 e posterior, você pode executar o seguinte comando para instalar o Milvus:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • +
        • De acordo com o guia de migração de APIs obsoletas do Kubernetes, a versão da API policy/v1beta1 do PodDisruptionBudget não é mais servida a partir da versão 1.25. Sugere-se que você migre manifestos e clientes de API para usar a versão de API policy/v1.
          Como solução alternativa para os usuários que ainda usam a versão da API policy/v1beta1 do PodDisruptionBudget no Kubernetes v1.25 e posterior, você pode executar o seguinte comando para instalar o Milvus:
          helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
        • Consulte Gráfico de Helm do Milvus e Helm para obter mais informações.

        2. Verificar o status do cluster do Milvus

        Execute o seguinte comando para verificar o estado de todos os pods no seu cluster Milvus.

        $ kubectl get pods
         
        -

        Quando todos os pods estiverem em execução, a saída do comando acima deve ser semelhante à seguinte:

        +

        Quando todos os pods estiverem em execução, a saída do comando acima deverá ser semelhante à seguinte:

        NAME                                             READY  STATUS   RESTARTS  AGE
         my-release-etcd-0                                1/1    Running   0        3m23s
         my-release-etcd-1                                1/1    Running   0        3m23s
        @@ -276,14 +276,14 @@ $ helm upgrade my-release zilliztech/milvus
         
         
      • Atualizar o Milvus usando o Helm Chart.

      • Escalar seu cluster Milvus.

      • -
      • Implantar seu cluster Milvu em nuvens:

        +
      • Implantar seu cluster Milvus em nuvens:

      • Explore o Milvus Backup, uma ferramenta de código aberto para backups de dados do Milvus.

      • -
      • Explore o Birdwatcher, uma ferramenta de código aberto para depuração do Milvus e actualizações dinâmicas de configuração.

      • +
      • Explore o Birdwatcher, uma ferramenta de código aberto para depuração do Milvus e actualizações de configuração dinâmica.

      • Explore o Attu, uma ferramenta GUI de código aberto para gerenciamento intuitivo do Milvus.

      • Monitore o Milvus com o Prometheus.

      • diff --git a/localization/v2.4.x/site/pt/integrations/integrations_overview.md b/localization/v2.4.x/site/pt/integrations/integrations_overview.md index b408400ab..934ae6cb7 100644 --- a/localization/v2.4.x/site/pt/integrations/integrations_overview.md +++ b/localization/v2.4.x/site/pt/integrations/integrations_overview.md @@ -67,5 +67,9 @@ title: Visão geral das integrações
        + + + +
        Construir um RAG com Milvus e fontes de dados não estruturadosEstruturadasMilvus, Não estruturado
        Construir um RAG com Milvus + Mascarador de PIIFontes de dadosMilvus, mascarador de PII
        Utilizar o Milvus no PrivateGPTOchestraçãopesquisa vetorial
        Introdução ao Mem0 e ao MilvusAgentesMem0, Milvus
        Tabela de conhecimento com MilvusEngenharia do conhecimentoTabela de Conhecimentos, Milvus
        Utilizar o Milvus no DocsGPTOchestraçãoDocsGPT, Milvus
        Utilizar o Milvus com o SambaNovaOrquestraçãoMilvus, SambaNova
        diff --git a/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.json b/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.json new file mode 100644 index 000000000..cf06d02e3 --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/whyhow-ai/knowledge-table.git\n","$ docker-compose up -d --build\n","$ docker-compose down\n"],"headingContent":"Knowledge Table with Milvus","anchorList":[{"label":"Tabela de conhecimentos com Milvus","href":"Knowledge-Table-with-Milvus","type":1,"isActive":false},{"label":"Pré-requisitos","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonando o projeto","href":"Cloning-the-project","type":2,"isActive":false},{"label":"Configurar o ambiente","href":"Set-up-the-environment","type":2,"isActive":false},{"label":"Iniciar a aplicação","href":"Starting-the-app","type":2,"isActive":false},{"label":"Parar a aplicação","href":"Stopping-the-app","type":2,"isActive":false},{"label":"Aceder ao projeto","href":"Accessing-the-project","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.md b/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.md new file mode 100644 index 000000000..e6d734ced --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/knowledge_table_with_milvus.md @@ -0,0 +1,146 @@ +--- +id: knowledge_table_with_milvus.md +summary: >- + Por defeito, a Knowledge Table utiliza a base de dados Milvus para armazenar e + recuperar os dados extraídos. Isto permite aos utilizadores pesquisar, filtrar + e analisar facilmente os dados utilizando as poderosas funcionalidades do + Milvus. Neste tutorial, mostraremos como começar a usar a Knowledge Table e o + Milvus. +title: Tabela de conhecimentos com Milvus +--- +

        Tabela de conhecimentos com Milvus

        A Knowledge Table, desenvolvida pela WhyHow AI, é um pacote de código aberto concebido para facilitar a extração e a exploração de dados estruturados a partir de documentos não estruturados. Fornece aos utilizadores uma interface semelhante a uma folha de cálculo e permite a criação de representações de conhecimentos, como tabelas e gráficos, através de uma interface de consulta em linguagem natural. O pacote inclui regras de extração personalizáveis, opções de formatação e rastreabilidade de dados através da proveniência, tornando-o adaptável a diversas aplicações. Suporta uma integração perfeita nos fluxos de trabalho RAG, satisfazendo tanto os utilizadores empresariais que necessitam de uma interface de fácil utilização como os programadores que necessitam de um backend flexível para um processamento eficiente de documentos.

        +

        Por defeito, a Knowledge Table utiliza a base de dados Milvus para armazenar e recuperar os dados extraídos. Isto permite aos utilizadores pesquisar, filtrar e analisar facilmente os dados utilizando as poderosas funcionalidades do Milvus. Neste tutorial, mostraremos como começar a usar a Knowledge Table e o Milvus.

        +

        Pré-requisitos

          +
        • Docker
        • +
        • Docker Compose
        • +
        +

        Clonando o projeto

        $ git clone https://github.com/whyhow-ai/knowledge-table.git
        +
        +

        Configurar o ambiente

        Você encontrará o arquivo .env.example no diretório raiz do projeto. Copie este ficheiro para .env e preencha as variáveis de ambiente necessárias.

        +

        Para o Milvus, deve definir as variáveis de ambiente MILVUS_DB_URI e MILVUS_DB_TOKEN. Seguem-se algumas sugestões:

        +
        +
          +
        • Definir o MILVUS_DB_URI como um ficheiro local, por exemplo,./milvus.db, é o método mais conveniente, uma vez que utiliza automaticamente o Milvus Lite para armazenar todos os dados neste ficheiro.
        • +
        • Se tiver uma grande escala de dados, digamos mais de um milhão de vectores, pode configurar um servidor Milvus mais eficiente em Docker ou Kubernetes. Nesta configuração, use o endereço e a porta do servidor como seu uri, por exemplo,http://localhost:19530. Se você ativar o recurso de autenticação no Milvus, use "<seu_nome_de_usuário>:<sua_senha>" como o token, caso contrário, não defina o token.
        • +
        • Se pretender utilizar o Zilliz Cloud, o serviço de cloud totalmente gerido para o Milvus, ajuste os endereços MILVUS_DB_URI e MILVUS_DB_TOKEN, que correspondem ao Public Endpoint e à chave Api no Zilliz Cloud.
        • +
        +
        +

        Para além do Milvus, deve também definir outros ambientes, por exemplo, OPENAI_API_KEY. Pode obter cada um destes ambientes nos respectivos sites.

        +

        Iniciar a aplicação

        $ docker-compose up -d --build
        +
        +

        Parar a aplicação

        $ docker-compose down
        +
        +

        Aceder ao projeto

        O frontend pode ser acedido em http://localhost:3000, e o backend pode ser acedido em http://localhost:8000.

        +

        + + + + +

        +

        Pode brincar com a interface do utilizador e experimentar com os seus próprios documentos.

        +

        Para mais demonstrações de utilização, pode consultar a documentação oficial da Knowledge Table.

        diff --git a/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..25725e1b1 --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"Introdução ao Mem0 e ao Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"Preparação","href":"Preparation","type":2,"isActive":false},{"label":"Gerir as memórias do utilizador com o Mem0 e o Milvus","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..a896c884a --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,218 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + Neste tutorial, cobriremos as operações essenciais de gerenciamento de memória + do Mem0 - adicionar, recuperar, atualizar, pesquisar, excluir e rastrear o + histórico de memória - usando o Milvus, um banco de dados vetorial de alto + desempenho e de código aberto que possibilita o armazenamento e a recuperação + eficientes. Esta introdução prática guiá-lo-á através de operações de memória + fundamentais para o ajudar a criar interações de IA personalizadas com o Mem0 + e o Milvus. +title: Introdução ao Mem0 e ao Milvus +--- +

        Introdução ao Mem0 e ao Milvus

        +Open In Colab + + +GitHub Repository +

        +

        O Mem0 é uma camada de memória inteligente para aplicações de IA, concebida para proporcionar interações personalizadas e eficientes, retendo as preferências do utilizador e adaptando-se continuamente ao longo do tempo. Ideal para chatbots e ferramentas orientadas por IA, o Mem0 cria experiências perfeitas e conscientes do contexto.

        +

        Neste tutorial, abordaremos as operações essenciais de gerenciamento de memória do Mem0 - adicionando, recuperando, atualizando, pesquisando, excluindo e rastreando o histórico de memória - usando o Milvus, um banco de dados vetorial de alto desempenho e de código aberto que possibilita o armazenamento e a recuperação eficientes. Esta introdução prática guiá-lo-á através de operações de memória fundamentais para o ajudar a criar interações de IA personalizadas com o Mem0 e o Milvus.

        +

        Preparação

        Descarregar as bibliotecas necessárias

        $ pip install mem0ai pymilvus
        +
        +
        +

        Se estiver a utilizar o Google Colab, para ativar as dependências que acabou de instalar, poderá ter de reiniciar o tempo de execução (clique no menu "Tempo de execução" na parte superior do ecrã e selecione "Reiniciar sessão" no menu pendente).

        +
        +

        Configurar o Mem0 com o Milvus

        Neste exemplo, vamos utilizar o OpenAI como LLM. Deve preparar a chave api OPENAI_API_KEY como uma variável de ambiente.

        +
        import os
        +
        +os.environ["OPENAI_API_KEY"] = "sk-***********"
        +
        +

        Agora, podemos configurar o Mem0 para usar o Milvus como o armazenamento de vetores

        +
        # Define Config
        +from mem0 import Memory
        +
        +config = {
        +    "vector_store": {
        +        "provider": "milvus",
        +        "config": {
        +            "collection_name": "quickstart_mem0_with_milvus",
        +            "embedding_model_dims": "1536",
        +            "url": "./milvus.db",  # Use local vector database for demo purpose
        +        },
        +    },
        +    "version": "v1.1",
        +}
        +
        +m = Memory.from_config(config)
        +
        +
        +
        +
          +
        • Se só precisar de uma base de dados vetorial local para dados de pequena escala ou prototipagem, definir o uri como um ficheiro local, por exemplo./milvus.db, é o método mais conveniente, uma vez que utiliza automaticamente o Milvus Lite para armazenar todos os dados neste ficheiro.
        • +
        • Se tiver uma grande escala de dados, digamos mais de um milhão de vectores, pode configurar um servidor Milvus mais eficiente em Docker ou Kubernetes. Nesta configuração, use o endereço e a porta do servidor como seu uri, por exemplo,http://localhost:19530. Se ativar a funcionalidade de autenticação no Milvus, utilize "<your_username>:<your_password>" como token, caso contrário não defina o token.
        • +
        • Se utilizar o Zilliz Cloud, o serviço de nuvem totalmente gerido para o Milvus, ajuste os endereços uri e token, que correspondem ao Public Endpoint e à chave API no Zilliz Cloud.
        • +
        +
        +
        +

        Gerir as memórias do utilizador com o Mem0 e o Milvus

        Adicionar uma memória

        A função add armazena texto não estruturado no Milvus como uma memória, associando-o a um utilizador específico e a metadados opcionais.

        +

        Aqui, estamos a adicionar a memória da Alice, "working on improving my tennis skills", juntamente com metadados relevantes para o contexto do Milvus.

        +
        # Add a memory to user: Working on improving tennis skills
        +res = m.add(
        +    messages="I am working on improving my tennis skills.",
        +    user_id="alice",
        +    metadata={"category": "hobbies"},
        +)
        +
        +res
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Working on improving tennis skills',
        +   'event': 'ADD'}],
        + 'relations': []}
        +
        +

        Atualizar uma memória

        Podemos utilizar o valor de retorno da função add para obter o ID da memória, permitindo-nos atualizar esta memória com novas informações através de update.

        +
        # Get memory_id
        +memory_id = res["results"][0]["id"]
        +
        +# Update this memory with new information: Likes to play tennis on weekends
        +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
        +
        +
        {'message': 'Memory updated successfully!'}
        +
        +

        Obter todas as memórias de um utilizador

        Podemos utilizar a função get_all para visualizar todas as memórias inseridas ou filtrar por user_id no Milvus.

        +

        Repare que podemos ver que a memória foi alterada de "Trabalhar para melhorar as capacidades de ténis" para "Gosta de jogar ténis aos fins-de-semana".

        +
        # Get all memory for the user Alice
        +m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'}]}
        +
        +

        Ver o histórico de actualizações da memória

        Também podemos ver o histórico de actualizações da memória especificando o memory_id em que estamos interessados através da função history.

        +
        m.history(memory_id=memory_id)
        +
        +
        [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': None,
        +  'new_memory': 'Working on improving tennis skills',
        +  'event': 'ADD',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': None},
        + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
        +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +  'old_memory': 'Working on improving tennis skills',
        +  'new_memory': 'Likes to play tennis on weekends',
        +  'event': 'UPDATE',
        +  'created_at': '2024-11-01T19:33:44.116920-07:00',
        +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
        +
        +

        Procurar memória

        Podemos utilizar a função search para procurar a memória mais relacionada com o utilizador.

        +

        Vamos começar por adicionar outra memória para a Alice.

        +
        new_mem = m.add(
        +    "I have a linear algebra midterm exam on November 20",
        +    user_id="alice",
        +    metadata={"category": "task"},
        +)
        +
        +

        Agora, chamamos get_all especificando o user_id para verificar se temos de facto 2 entradas de memória para a utilizadora Alice.

        +
        m.get_all(user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        Podemos executar search agora fornecendo query e user_id. Note-se que, por defeito, estamos a utilizar a métrica L2 para a pesquisa de semelhanças, pelo que um score mais pequeno significa maior semelhança.

        +
        m.search(query="What are Alice's hobbies", user_id="alice")
        +
        +
        {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
        +   'memory': 'Likes to play tennis on weekends',
        +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
        +   'metadata': None,
        +   'score': 1.2807445526123047,
        +   'created_at': '2024-11-01T19:33:44.116920-07:00',
        +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
        +   'user_id': 'alice'},
        +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'score': 1.728922724723816,
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        +

        Apagar memória

        Também podemos delete uma memória fornecendo o memory_id correspondente.

        +

        Vamos apagar a memória "Gosta de jogar ténis aos fins-de-semana", uma vez que o seu memory_id já foi recuperado, e chamar get_all para verificar se a eliminação foi bem sucedida.

        +
        m.delete(memory_id=memory_id)
        +
        +m.get_all("alice")
        +
        +
        {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
        +   'memory': 'Has a linear algebra midterm exam on November 20',
        +   'hash': '575182f46965111ca0a8279c44920ea2',
        +   'metadata': {'category': 'task'},
        +   'created_at': '2024-11-01T19:33:57.271657-07:00',
        +   'updated_at': None,
        +   'user_id': 'alice'}]}
        +
        diff --git a/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..b2543d63e --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"Utilizar o Milvus no DocsGPT","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"Requisitos","href":"Requirements","type":2,"isActive":false},{"label":"Clonar o repositório","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Adicionar dependência","href":"Add-dependency","type":2,"isActive":false},{"label":"Definir variáveis de ambiente","href":"Set-environment-variables","type":2,"isActive":false},{"label":"Iniciar os serviços","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..4b824b4d6 --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,142 @@ +--- +id: use_milvus_in_docsgpt.md +summary: >- + Neste tutorial, vamos mostrar-lhe como utilizar o Milvus como base de dados de + vectores backend para o DocsGPT. +title: Utilizar o Milvus no DocsGPT +--- +

        Utilizar o Milvus no DocsGPT

        O DocsGPT é uma solução avançada de código aberto que simplifica a procura de informações na documentação do projeto através da integração de poderosos modelos GPT. Permite que os programadores obtenham facilmente respostas precisas às suas perguntas sobre um projeto, eliminando as demoradas pesquisas manuais.

        +

        Neste tutorial, vamos mostrar-lhe como utilizar o Milvus como base de dados vetorial backend para o DocsGPT.

        +
        +

        Este tutorial tem como principal referência o guia de instalação oficial do DocsGPT. Se achar que este tutorial tem partes desactualizadas, pode dar prioridade ao seguimento do guia oficial e criar uma questão para nós.

        +
        +

        Requisitos

        Certifique-se de que tem o Docker instalado

        +

        Clonar o repositório

        Clone o repositório e navegue até ele:

        +
        $ git clone https://github.com/arc53/DocsGPT.git
        +$ cd DocsGPT
        +
        +

        Adicionar dependência

        Acrescente a dependência langchain-milvus ao ficheiro requirements.txt na pasta application:

        +
        $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
        +
        +

        Definir variáveis de ambiente

        Adicione VECTOR_STORE=milvus, MILVUS_URI=..., MILVUS_TOKEN=... às variáveis de ambiente para os serviços backend e worker no arquivo docker-compose.yaml, da seguinte forma:

        +
          backend:
        +    build: ./application
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +
          worker:
        +    build: ./application
        +    command: celery -A application.app.celery worker -l INFO -B
        +    environment:
        +      - VECTOR_STORE=milvus
        +      - MILVUS_URI=...
        +      - MILVUS_TOKEN=...
        +
        +

        Para os serviços MILVUS_URI e MILVUS_TOKEN, pode utilizar o serviço Zilliz Cloud(recomendado) totalmente gerido ou o serviço Milvus iniciado manualmente.

        +
          +
        • Para o serviço Zillz Cloud totalmente gerido: Recomendamos a utilização do serviço Zilliz Cloud. Pode registar-se para obter uma conta de avaliação gratuita no Zilliz Cloud. Depois disso, receberá os endereços MILVUS_URI e MILVUS_TOKEN, que correspondem ao Ponto de Extremidade Público e à chave API.

        • +
        • Para o serviço Milvus iniciado manualmente: Se pretender configurar um serviço Milvus, pode seguir a documentação oficial do Milvus para configurar um servidor Milvus e, em seguida, obter MILVUS_URI e MILVUS_TOKEN do servidor. Os endereços MILVUS_URI e MILVUS_TOKEN devem estar no formato http://<your_server_ip>:19530 e <your_username>:<your_password>, respetivamente.

        • +
        +

        Iniciar os serviços

        Executar: ./setup.sh

        +

        Em seguida, navegue para http://localhost:5173/.

        +

        Pode brincar com a interface do utilizador e fazer perguntas sobre os seus documentos.

        +

        + + alt text + texto alternativo

        +

        Se pretender parar os serviços, execute:

        +
        $ docker-compose down
        +
        +

        Para obter mais detalhes e configurações mais avançadas, consulte a documentação oficial do DocsGPT.

        diff --git a/localization/v2.4.x/site/pt/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/pt/integrations/use_milvus_in_private_gpt.md index 532818cbc..f397fa2ad 100644 --- a/localization/v2.4.x/site/pt/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/pt/integrations/use_milvus_in_private_gpt.md @@ -67,13 +67,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

        O PrivateGPT permite a personalização da configuração. Precisamos especificar algumas configurações de módulos. Neste tutorial, usaremos os seguintes módulos:

        +

        O PrivateGPT permite a personalização da configuração de alguns módulos, por exemplo, LLM, Embeddings, Vetor Stores, UI.

        +

        Neste tutorial, usaremos os seguintes módulos:

        • LLM: Ollama
        • Embeddings: Ollama
        • Vetor Stores: Milvus
        • UI: Gradio
        +

        Execute o seguinte comando para usar o poetry para instalar as dependências do módulo necessário:

        $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
         

        Iniciar o serviço Ollama

        Aceda a ollama.ai e siga as instruções para instalar o Ollama no seu computador.

        Após a instalação, certifique-se de que a aplicação de ambiente de trabalho Ollama está fechada.

        -

        Agora, inicie o serviço Ollama (este iniciará um servidor de inferência local, servindo tanto o LLM como os Embeddings):

        +

        Agora, inicie o serviço Ollama (ele iniciará um servidor de inferência local, servindo tanto o LLM quanto o Embeddings):

        $ ollama serve
         
        -

        Instale os modelos a utilizar, por defeito settings-ollama.yaml está configurado para o utilizador llama3.1 8b LLM (~4GB) e nomic-embed-text Embeddings (~275MB)

        +

        Instale os modelos a utilizar, o settings-ollama.yaml predefinido está configurado para o utilizador llama3.1 8b LLM (~4GB) e nomic-embed-text Embeddings (~275MB)

        Por defeito, o PrivateGPT extrai automaticamente os modelos conforme necessário. Este comportamento pode ser alterado modificando a propriedade ollama.autopull_models.

        Em qualquer caso, se quiser extrair modelos manualmente, execute os seguintes comandos:

        $ ollama pull llama3.1
        @@ -133,10 +135,10 @@ $ ollama pull nomic-embed-text
         Campo OpçãoDescrição
         
         
        -uriA predefinição é definida para "local_data/private_gpt/milvus/milvus_local.db" como um ficheiro local; também pode configurar um servidor Milvus com melhor desempenho no docker ou k8s, por exemplo, http://localhost:19530, como o seu uri; para utilizar o Zilliz Cloud, ajuste o uri e o token para Endpoint e Api key no Zilliz Cloud.
        +uriA predefinição é definida para "local_data/private_gpt/milvus/milvus_local.db" como um ficheiro local; também pode configurar um servidor Milvus com melhor desempenho no docker ou k8s, por exemplo, http://localhost:19530, como o seu uri; Para utilizar o Zilliz Cloud, ajuste o uri e o token para o Public Endpoint e a chave API no Zilliz Cloud.
         tokenEmparelhar com o servidor Milvus no docker ou k8s ou com a chave api da nuvem Zilliz.
         nome_da_colecçãoO nome da coleção, definido por defeito como "milvus_db".
        -overwriteSubstitui os dados na coleção se existirem, definido por padrão como True.
        +sobrescreverSubstitui os dados na coleção se existirem, definido por padrão como True.
         
         
         

        Iniciar o PrivateGPT

        Quando todas as definições estiverem concluídas, pode executar o PrivateGPT com uma interface de utilizador gradio.

        +

        Quando todas as definições estiverem concluídas, pode executar o PrivateGPT com uma IU do Gradio.

        PGPT_PROFILES=ollama make run
         
        -

        A interface do usuário estará disponível emhttp://0.0.0.0:8001.

        +

        A interface do utilizador estará disponível em http://0.0.0.0:8001.

        @@ -165,3 +167,4 @@ $ ollama pull nomic-embed-text

        Pode brincar com a IU e fazer perguntas sobre os seus documentos.

        +

        Para obter mais detalhes, consulte a documentação oficial do PrivateGPT.

        diff --git a/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..f8a83f779 --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"Utilizar o Milvus com o SambaNova","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"Pré-requisitos","href":"Prerequisites","type":2,"isActive":false},{"label":"Clonar o repositório","href":"Clone-the-repository","type":2,"isActive":false},{"label":"Alterar o tipo de armazenamento de vetores","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"Instalar dependências","href":"Install-dependencies","type":2,"isActive":false},{"label":"Iniciar a aplicação","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..2b15a5224 --- /dev/null +++ b/localization/v2.4.x/site/pt/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,135 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + Este tutorial aproveita a integração do Milvus no SambaNova AI Starter Kits + para construir um sistema de recuperação de conhecimento empresarial, + semelhante ao RAG (Retrieval-Augmented Generation), para recuperar e responder + com base nos documentos privados da empresa. +title: Utilizar o Milvus com o SambaNova +--- +

        Utilizar o Milvus com o SambaNova

        O SambaNova é uma plataforma tecnológica de IA inovadora que acelera a implementação de capacidades avançadas de IA e de aprendizagem profunda. Concebida para utilização empresarial, permite às organizações tirar partido da IA generativa para um melhor desempenho e eficiência. Ao fornecer soluções de ponta como o SambaNova Suite e o DataScale, a plataforma permite que as empresas extraiam informações valiosas dos seus dados, impulsionando melhorias operacionais e promovendo novas oportunidades no cenário da IA.

        +

        Os SambaNova AI Starter Kits são um conjunto de recursos de código aberto concebidos para ajudar os programadores e as empresas a implementar aplicações orientadas para a IA com o SambaNova. Estes kits fornecem exemplos práticos e guias que facilitam a implementação de vários casos de utilização de IA, tornando mais fácil para os utilizadores aproveitarem a tecnologia avançada do SambaNova.

        +

        Este tutorial aproveita a integração do Milvus no SambaNova AI Starter Kits para criar um sistema de recuperação de conhecimento empresarial, semelhante ao RAG (Retrieval-Augmented Generation), para recuperar e responder com base nos documentos privados da empresa.

        +
        +

        Este tutorial tem como referência principal o guia oficial do SambaNova AI Starter Kits. Se achar que este tutorial tem partes desactualizadas, pode dar prioridade a seguir o guia oficial e criar um problema para nós.

        +
        +

        Pré-requisitos

        Recomendamos o uso de Python >= 3.10 e < 3.12.

        +

        Visite o SambaNova Cloud para obter uma chave de API do SambaNova.

        +

        Clonar o repositório

        $ git clone https://github.com/sambanova/ai-starter-kit.git
        +$ d ai-starter-kit/enterprise_knowledge_retriever
        +
        +

        Alterar o tipo de armazenamento de vetores

        Altere o armazenamento de vetores definindo db_type='milvus' nas funções create_vector_store() e load_vdb() em src/document_retrieval.py.

        +
        ...
        +vectorstore = self.vectordb.create_vector_store(
        +    ..., db_type='milvus'
        +)
        +...
        +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
        +
        +

        Instalar dependências

        Instale as dependências necessárias executando o seguinte comando:

        +
        python3 -m venv enterprise_knowledge_env
        +source enterprise_knowledge_env/bin/activate
        +pip install -r requirements.txt
        +
        +

        Iniciar a aplicação

        Utilize o seguinte comando para iniciar a aplicação:

        +
        $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
        +
        +

        Depois disso, verá a interface do utilizador no seu browser:http://localhost:8501/

        +

        + + + + +

        +

        Depois de definir a sua chave de API do SambaNova na IU, pode brincar com a IU e fazer perguntas sobre os seus documentos.

        +

        Para obter mais detalhes, consulte a documentação oficial do Enterprise Knowledge Retrieval of SambaNova AI Starter Kits.

        diff --git a/localization/v2.4.x/site/pt/menuStructure/pt.json b/localization/v2.4.x/site/pt/menuStructure/pt.json index ce0a7e1f4..a61cc1ece 100644 --- a/localization/v2.4.x/site/pt/menuStructure/pt.json +++ b/localization/v2.4.x/site/pt/menuStructure/pt.json @@ -138,7 +138,7 @@ "children": [] }, { - "label": "Carta do leme", + "label": "Mapa do leme", "id": "install_cluster-helm-gpu.md", "order": 1, "children": [] @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "Utilizadores e funções", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "Réplica na memória", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "Utilizadores, privilégios e funções", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "Ativar RBAC", "id": "rbac.md", @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "DocsGPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "SambaNova", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivadoGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "Tabela de conhecimentos", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "Pesquisa de funil com embeddings Matryoshka", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "Explorar mais", "id": "explore-more", diff --git a/localization/v2.4.x/site/pt/reference/disk_index.md b/localization/v2.4.x/site/pt/reference/disk_index.md index 2dfa9468b..c54c23e06 100644 --- a/localization/v2.4.x/site/pt/reference/disk_index.md +++ b/localization/v2.4.x/site/pt/reference/disk_index.md @@ -47,7 +47,7 @@ Atualmente, um campo vetorial apenas suporta um tipo de índice. O Milvus exclui
      • A instância do Milvus é executada no Ubuntu 18.04.6 ou numa versão posterior.
      • O caminho de dados do Milvus deve ser montado em um SSD NVMe para obter desempenho total:
        • Para uma instância Milvus Standalone, o caminho de dados deve ser /var/lib/milvus/data no contentor onde a instância é executada.
        • -
        • Para uma instância Milvus Cluster, o caminho de dados deve ser /var/lib/milvus/data nos contentores onde os QueryNodes e IndexNodes são executados.
        • +
        • Para uma instância de Milvus Cluster, o caminho de dados deve ser /var/lib/milvus/data nos contentores onde são executados os QueryNodes e os IndexNodes.

      Limites

      O Knowhere é o principal motor de execução de vectores do Milvus que incorpora várias bibliotecas de pesquisa de semelhanças vectoriais, incluindo Faiss, Hnswlib e Annoy. O Knowhere foi também concebido para suportar a computação heterogénea. Controla em que hardware (CPU ou GPU) executar a criação de índices e os pedidos de pesquisa. É assim que o Knowhere recebe o seu nome - saber onde executar as operações. Mais tipos de hardware, incluindo DPU e TPU, serão suportados em versões futuras.

      +

      O Knowhere é o principal mecanismo de execução de vetores do Milvus, que incorpora várias bibliotecas de pesquisa de similaridade de vetores, incluindo Faiss, Hnswlib e Annoy. O Knowhere foi também concebido para suportar a computação heterogénea. Controla em que hardware (CPU ou GPU) executar a criação de índices e os pedidos de pesquisa. É assim que o Knowhere recebe o seu nome - saber onde executar as operações. Mais tipos de hardware, incluindo DPU e TPU, serão suportados em versões futuras.

      Knowhere na arquitetura Milvus

      A seguir estão as vantagens do Knowhere sobre o Faiss.

      +

      A seguir estão as vantagens do Knowhere em relação ao Faiss.

      Suporte para BitsetView

      Milvus introduz um mecanismo de bitset para realizar a "eliminação suave". Um vetor apagado suavemente continua a existir na base de dados, mas não será computado durante uma pesquisa ou consulta de semelhança de vectores.

      Cada bit num conjunto de bits corresponde a um vetor indexado. Se um vetor estiver marcado como "1" no conjunto de bits, significa que esse vetor foi eliminado de forma suave e não será envolvido durante uma pesquisa de vectores. O parâmetro bitset é aplicado a todas as APIs de consulta de índice Faiss expostas no Knowhere, incluindo índices de CPU e GPU.

      Para obter mais informações sobre o mecanismo de bitset, consulte bitset.

      Suporte a várias métricas de similaridade para indexação de vetores binários

      O Knowhere oferece suporte a Hamming, Jaccard, Tanimoto, Superestrutura e Subestrutura. Jaccard e Tanimoto podem ser usados para medir a similaridade entre dois conjuntos de amostras, enquanto Superestrutura e Subestrutura podem ser usados para medir a similaridade de estruturas químicas.

      -

      Suporte para o conjunto de instruções AVX512

      Para além do AArch64, do SSE4.2 e do AVX2, os conjuntos de instruções já suportados pelo Faiss, o Knowhere também suporta o AVX512, que pode melhorar o desempenho da criação de índices e da consulta em 20% a 30% em comparação com o AVX2.

      +

      Suporte para o conjunto de instruções AVX512

      Para além do AArch64, do SSE4.2 e do AVX2, os conjuntos de instruções já suportados pelo Faiss, o Knowhere também suporta o AVX512, que pode melhorar o desempenho da construção e consulta de índices em 20% a 30% em comparação com o AVX2.

      Seleção automática de instruções SIMD

      O Knowhere suporta a invocação automática das instruções SIMD adequadas (por exemplo, SIMD SSE, AVX, AVX2 e AVX512) em qualquer processador de CPU (plataformas locais e em nuvem), para que os usuários não precisem especificar manualmente o sinalizador SIMD (por exemplo, "-msse4") durante a compilação.

      O Knowhere é construído refatorando a base de código do Faiss. As funções comuns (por exemplo, cálculo de semelhanças) que dependem de acelerações SIMD são eliminadas. Em seguida, para cada função, são implementadas quatro versões (ou seja, SSE, AVX, AVX2, AVX512) e cada uma é colocada num ficheiro fonte separado. Em seguida, os ficheiros de origem são compilados individualmente com o sinalizador SIMD correspondente. Portanto, em tempo de execução, o Knowhere pode escolher automaticamente as instruções SIMD mais adequadas com base nos sinalizadores atuais da CPU e, em seguida, vincular os ponteiros de função corretos usando hooking.

      Outras otimizações de desempenho

      Leia Milvus: um sistema de gerenciamento de dados vetoriais criado para fins específicos para obter mais informações sobre a otimização de desempenho do Knowhere.

      @@ -109,25 +109,25 @@ title: Conhecer
    • GPUIndex é a classe de base para todos os índices Faiss GPU.

    • OffsetBaseIndex é a classe de base para todos os índices auto-desenvolvidos. Dado que apenas os IDs dos vectores são armazenados num ficheiro de índice, o tamanho do ficheiro para vectores de 128 dimensões pode ser reduzido em 2 ordens de grandeza.

    -

    +

    IDMAP IDMAP

    -

    Em termos técnicos, IDMAP não é um índice, mas sim utilizado para pesquisa de força bruta. Quando os vectores são inseridos na base de dados, não é necessário treinar os dados nem construir um índice. As pesquisas serão realizadas diretamente nos dados vectoriais inseridos.

    +

    Em termos técnicos, IDMAP não é um índice, mas sim utilizado para pesquisa de força bruta. Quando os vectores são inseridos na base de dados, não é necessário treinar os dados nem construir um índice. As pesquisas serão efectuadas diretamente nos dados vectoriais inseridos.

    No entanto, por uma questão de coerência de código, IDMAP também herda a classe VecIndex com todas as suas interfaces virtuais. A utilização de IDMAP é idêntica à dos outros índices.

    -

    Índices IVF

    +

    Índices IVF

    IVF FIV

    -

    Os índices IVF (inverted file - ficheiro invertido) são os mais frequentemente utilizados. A classe IVF é derivada de VecIndex e FaissBaseIndex, e estende-se a IVFSQ e IVFPQ. GPUIVF é derivada de GPUIndex e IVF. Depois, GPUIVF estende-se a GPUIVFSQ e GPUIVFPQ.

    -

    IVFSQHybrid é um índice híbrido desenvolvido pelo próprio utilizador. O quantizador grosseiro é executado na GPU enquanto a pesquisa no balde é efectuada na CPU. Este tipo de índice pode reduzir a ocorrência de cópias de memória entre a CPU e a GPU, tirando partido do poder de computação da GPU. IVFSQHybrid tem a mesma taxa de recuperação que GPUIVFSQ, mas apresenta um melhor desempenho.

    -

    A estrutura da classe de base para os índices binários é relativamente mais simples. BinaryIDMAP e BinaryIVF são derivados de FaissBaseBinaryIndex e VecIndex.

    -

    Índices de terceiros

    +

    Os índices IVF (ficheiro invertido) são os mais frequentemente utilizados. A classe IVF é derivada de VecIndex e FaissBaseIndex, e estende-se a IVFSQ e IVFPQ. GPUIVF é derivada de GPUIndex e IVF. Depois, GPUIVF estende-se a GPUIVFSQ e GPUIVFPQ.

    +

    IVFSQHybrid é um índice híbrido desenvolvido pelo próprio utilizador. Um quantizador grosseiro é executado na GPU enquanto a pesquisa no balde é efectuada na CPU. Este tipo de índice pode reduzir a ocorrência de cópias de memória entre a CPU e a GPU, tirando partido do poder de computação da GPU. IVFSQHybrid tem a mesma taxa de recuperação que GPUIVFSQ, mas apresenta um melhor desempenho.

    +

    A estrutura da classe de base para índices binários é relativamente mais simples. BinaryIDMAP e BinaryIVF são derivados de FaissBaseBinaryIndex e VecIndex.

    +

    Índices de terceiros

    - third-party indexes + third-party indices índices de terceiros

    -

    Atualmente, só são suportados dois tipos de índices de terceiros para além do Faiss: índice baseado em árvores Annoy e índice baseado em gráficos HNSW. Estes dois índices de terceiros comuns e frequentemente utilizados são ambos derivados de VecIndex.

    -

    Adicionar índices ao Knowhere

  • Para adicionar índices baseados em árvores, consulte Annoy.

  • -

    Depois de consultar o índice existente, pode seguir os passos abaixo para adicionar um novo índice a Knowhere.

    +

    Depois de fazer referência ao índice existente, pode seguir os passos abaixo para adicionar um novo índice ao Knowhere.

      -
    1. Adicione o nome do novo índice em IndexEnum. O tipo de dados é string.

    2. +
    3. Adicione o nome do novo índice em IndexEnum. O tipo de dados é uma cadeia de caracteres.

    4. Adicione uma verificação de validação de dados ao novo índice no ficheiro ConfAdapter.cpp. A verificação de validação destina-se principalmente a validar os parâmetros de formação e consulta de dados.

    5. Crie um novo ficheiro para o novo índice. A classe de base do novo índice deve incluir VecIndex, e a interface virtual necessária de VecIndex.

    6. Adicione a lógica de construção do índice para o novo índice em VecIndexFactory::CreateVecIndex().

    7. diff --git a/localization/v2.4.x/site/pt/reference/schema.json b/localization/v2.4.x/site/pt/reference/schema.json index e2ce4ba9d..1afd3cf5e 100644 --- a/localization/v2.4.x/site/pt/reference/schema.json +++ b/localization/v2.4.x/site/pt/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gerir o esquema","href":"Manage-Schema","type":1,"isActive":false},{"label":"Esquema de campo","href":"Field-schema","type":2,"isActive":false},{"label":"Esquema de coleção","href":"Collection-schema","type":2,"isActive":false},{"label":"O que se segue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"Gerir o esquema","href":"Manage-Schema","type":1,"isActive":false},{"label":"Esquema de campo","href":"Field-schema","type":2,"isActive":false},{"label":"Esquema de coleção","href":"Collection-schema","type":2,"isActive":false},{"label":"O que se segue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/reference/schema.md b/localization/v2.4.x/site/pt/reference/schema.md index 404afcf60..7179ddc17 100644 --- a/localization/v2.4.x/site/pt/reference/schema.md +++ b/localization/v2.4.x/site/pt/reference/schema.md @@ -39,7 +39,10 @@ title: Gerir o esquema

      Propriedades do esquema de campo

      - + + + + @@ -154,7 +157,10 @@ fields = [

      Propriedades do esquema de coleção

      PropriedadesDescrição Nota
      PropriedadesDescrição do campoNota
      - + + + + @@ -170,7 +176,7 @@ fields = [ - + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

      Crie uma coleção com o esquema especificado:

      -
      from pymilvus import Collection
      +
      from pymilvus import Collection,connections
      +conn = connections.connect(host="127.0.0.1", port=19530)
       collection_name1 = "tutorial_1"
       collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
       
      @@ -239,6 +246,6 @@ collection, ins_res = Collection.construct_from_dataframe( diff --git a/localization/v2.4.x/site/pt/reference/users_and_roles.json b/localization/v2.4.x/site/pt/reference/users_and_roles.json index 37bd2d62d..d64ffc053 100644 --- a/localization/v2.4.x/site/pt/reference/users_and_roles.json +++ b/localization/v2.4.x/site/pt/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"Utilizadores e Funções","href":"Users-and-Roles","type":1,"isActive":false},{"label":"Conceitos-chave","href":"Key-concepts","type":2,"isActive":false},{"label":"Exemplo: Concessão de privilégios","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utilizadores e funções predefinidos","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Lista de tipos de objectos e privilégios","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"O que se segue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"Utilizadores, privilégios e funções","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"Conceitos-chave","href":"Key-concepts","type":2,"isActive":false},{"label":"Exemplo: Concessão de privilégios","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"Utilizadores e funções predefinidos","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"Lista de tipos de objectos e privilégios","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"O que se segue","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/reference/users_and_roles.md b/localization/v2.4.x/site/pt/reference/users_and_roles.md index 3b04bdb1e..5ddcd6a1c 100644 --- a/localization/v2.4.x/site/pt/reference/users_and_roles.md +++ b/localization/v2.4.x/site/pt/reference/users_and_roles.md @@ -4,9 +4,9 @@ related_key: 'users, roles' summary: >- Saiba mais sobre a definição de utilizadores, funções, objectos e privilégios no controlo de acesso baseado em funções (RBAC). -title: Utilizadores e funções +title: 'Utilizadores, privilégios e funções' --- -

      Utilizadores e Funções

      Este tópico fornece uma visão geral do Controlo de Acesso Baseado em Funções (RBAC) em Milvus, detalhando as definições e relações entre utilizadores, funções, objectos e privilégios.

      +

      Este tópico fornece uma visão geral do Controle de Acesso Baseado em Função (RBAC) em Milvus, detalhando as definições e relações entre usuários, funções, objetos e privilégios.

      A figura a seguir ilustra a relação entre objetos, privilégios, funções e usuários.

      @@ -107,7 +107,7 @@ client.grantPrivilege(grantPrivilegeReq);

      Para obter mais informações sobre APIs relacionadas a privilégios, consulte grantPrivilege e revokePrivilege.

      -

      Para obter mais informações sobre as APIs relacionadas com privilégios, consulte grantPrivilege e revokePrivilege.

      +

      Para obter mais informações sobre APIs relacionadas com privilégios, consulte grantPrivilege e revokePrivilege.

      Utilizadores e funções predefinidos

      A tabela seguinte lista os valores que pode selecionar ao ativar o RBAC.

      +

      A tabela seguinte lista os valores que pode escolher ao ativar o RBAC.

      PropriedadesDescrição Nota
      PropriedadesDescrição das propriedadesNota
      partition_key_field Nome de um campo concebido para atuar como chave de partição.Tipo de dados: String.
      Facultativo
      Tipo de dados String.
      Facultativo
      enable_dynamic_field
      diff --git a/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.json b/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.json new file mode 100644 index 000000000..746d5d66d --- /dev/null +++ b/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.json @@ -0,0 +1 @@ +{"codeList":["import functools\n\nfrom datasets import load_dataset\nimport numpy as np\nimport pandas as pd\nimport pymilvus\nfrom pymilvus import MilvusClient\nfrom pymilvus import FieldSchema, CollectionSchema, DataType\nfrom sentence_transformers import SentenceTransformer\nimport torch\nimport torch.nn.functional as F\nfrom tqdm import tqdm\n","model = SentenceTransformer(\n # Remove 'device='mps' if running on non-Mac device\n \"nomic-ai/nomic-embed-text-v1.5\",\n trust_remote_code=True,\n device=\"mps\",\n)\n","ds = load_dataset(\"vishnupriyavr/wiki-movie-plots-with-summaries\", split=\"train\")\nprint(ds)\n","embedding_dim = 768\nsearch_dim = 128\ncollection_name = \"movie_embeddings\"\n\nclient = MilvusClient(uri=\"./wiki-movie-plots-matryoshka.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n # First sixth of unnormalized embedding vector\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n # Entire unnormalized embedding vector\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n","index_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nindex_params.add_index(field_name=\"embedding\", index_type=\"FLAT\", metric_type=\"COSINE\")\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n # This particular model requires us to prefix 'search_document:' to stored entities\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Output of embedding model is unnormalized\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","queries = [\n \"An archaeologist searches for ancient artifacts while fighting Nazis.\",\n \"A teenager fakes illness to get off school and have adventures with two friends.\",\n \"A young couple with a kid look after a hotel during winter and the husband goes insane.\",\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\n# This particular model requires us to prefix 'search_query:' to queries\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries]\nsearch_data = embed_search(instruct_queries)\n\n# Normalize head embeddings\nhead_search = [x[:search_dim] for x in search_data]\n\n# Perform standard vector search on first sixth of embedding dimensions\nres = client.search(\n collection_name=collection_name,\n data=head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits][:5]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:\n \"\"\"\n Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.\n\n \"\"\"\n rows = [x[\"entity\"] for x in hits]\n rows_dict = [\n {\"title\": x[\"title\"], \"embedding\": torch.tensor(x[\"embedding\"])} for x in rows\n ]\n return pd.DataFrame.from_records(rows_dict)\n\n\ndfs = [hits_to_dataframe(hits) for hits in res]\n","# An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)\ndef calculate_score(row, query_emb=None, dims=768):\n emb = F.normalize(row[\"embedding\"][:dims], dim=-1)\n return (emb @ query_emb).item()\n\n\n# You could also add a top-K parameter as a termination condition\ndef funnel_search(\n df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5\n) -> pd.DataFrame:\n # Loop over increasing prefixes of the embeddings\n for dims in scales:\n # Query vector must be normalized for each new dimensionality\n emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))\n\n # Score\n scores = df.apply(\n functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1\n )\n df[\"scores\"] = scores\n\n # Re-rank\n df = df.sort_values(by=\"scores\", ascending=False)\n\n # Prune (in our case, remove half of candidates at each step)\n df = df.head(int(prune_ratio * len(df)))\n\n return df\n\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, search_data)\n]\n","for d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:5][\"title\"], \"\\n\")\n","# Search on entire embeddings\nres = client.search(\n collection_name=collection_name,\n data=search_data,\n anns_field=\"embedding\",\n limit=5,\n output_fields=[\"title\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", query)\n print(\"Results:\")\n for row in rows:\n print(row[\"title\"].strip())\n print()\n","queries2 = [\n \"A teenager fakes illness to get off school and have adventures with two friends.\"\n]\n\n\n# Search the database based on input text\ndef embed_search(data):\n embeds = model.encode(data)\n return [x for x in embeds]\n\n\ninstruct_queries = [\"search_query: \" + q.strip() for q in queries2]\nsearch_data2 = embed_search(instruct_queries)\nhead_search2 = [x[:search_dim] for x in search_data2]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=head_search2,\n anns_field=\"head_embedding\",\n limit=256,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","for query, hits in zip(queries, res):\n rows = [x[\"entity\"] for x in hits]\n\n print(\"Query:\", queries2[0])\n for idx, row in enumerate(rows):\n if row[\"title\"].strip() == \"Ferris Bueller's Day Off\":\n print(f\"Row {idx}: Ferris Bueller's Day Off\")\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries2, dfs, search_data2)\n]\n\nfor d in dfs_results:\n print(d[\"query\"], \"\\n\", d[\"results\"][:7][\"title\"].to_string(index=False), \"\\n\")\n","client = MilvusClient(uri=\"./wikiplots-matryoshka-flipped.db\")\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, auto_id=True),\n FieldSchema(name=\"title\", dtype=DataType.VARCHAR, max_length=256),\n FieldSchema(name=\"head_embedding\", dtype=DataType.FLOAT_VECTOR, dim=search_dim),\n FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),\n]\n\nschema = CollectionSchema(fields=fields, enable_dynamic_field=False)\nclient.create_collection(collection_name=collection_name, schema=schema)\n\nindex_params = client.prepare_index_params()\nindex_params.add_index(\n field_name=\"head_embedding\", index_type=\"FLAT\", metric_type=\"COSINE\"\n)\nclient.create_index(collection_name, index_params)\n","for batch in tqdm(ds.batch(batch_size=512)):\n plot_summary = [\"search_document: \" + x.strip() for x in batch[\"PlotSummary\"]]\n\n # Encode and flip embeddings\n embeddings = model.encode(plot_summary, convert_to_tensor=True)\n embeddings = torch.flip(embeddings, dims=[-1])\n head_embeddings = embeddings[:, :search_dim]\n\n data = [\n {\n \"title\": title,\n \"head_embedding\": head.cpu().numpy(),\n \"embedding\": embedding.cpu().numpy(),\n }\n for title, head, embedding in zip(batch[\"Title\"], head_embeddings, embeddings)\n ]\n res = client.insert(collection_name=collection_name, data=data)\n","# Normalize head embeddings\n\nflip_search_data = [\n torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data\n]\nflip_head_search = [x[:search_dim] for x in flip_search_data]\n\n# Perform standard vector search on subset of embeddings\nres = client.search(\n collection_name=collection_name,\n data=flip_head_search,\n anns_field=\"head_embedding\",\n limit=128,\n output_fields=[\"title\", \"head_embedding\", \"embedding\"],\n)\n","dfs = [hits_to_dataframe(hits) for hits in res]\n\ndfs_results = [\n {\"query\": query, \"results\": funnel_search(df, query_emb)}\n for query, df, query_emb in zip(queries, dfs, flip_search_data)\n]\n\nfor d in dfs_results:\n print(\n d[\"query\"],\n \"\\n\",\n d[\"results\"][:7][\"title\"].to_string(index=False, header=False),\n \"\\n\",\n )\n"],"headingContent":"Funnel Search with Matryoshka Embeddings","anchorList":[{"label":"Pesquisa em funil com embeddings Matryoshka","href":"Funnel-Search-with-Matryoshka-Embeddings","type":1,"isActive":false},{"label":"Carregar o modelo de incorporação Matryoshka","href":"Load-Matryoshka-Embedding-Model","type":2,"isActive":false},{"label":"Carregar o conjunto de dados, incorporar itens e construir uma base de dados de vectores","href":"Loading-Dataset-Embedding-Items-and-Building-Vector-Database","type":2,"isActive":false},{"label":"Efetuar a pesquisa em funil","href":"Performing-Funnel-Search","type":2,"isActive":false},{"label":"Comparação da pesquisa em funil com a pesquisa normal","href":"Comparing-Funnel-Search-to-Regular-Search","type":2,"isActive":false},{"label":"Investigando a falha de recordação da pesquisa de funil para Ferris Bueller's Day Off","href":"Investigating-Funnel-Search-Recall-Failure-for-Ferris-Buellers-Day-Off","type":2,"isActive":false},{"label":"A ordem é importante? Embeddings de prefixo vs sufixo.","href":"Does-the-order-matter-Prefix-vs-suffix-embeddings","type":2,"isActive":false},{"label":"Resumo","href":"Summary","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.md b/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.md new file mode 100644 index 000000000..2e350a31e --- /dev/null +++ b/localization/v2.4.x/site/pt/tutorials/funnel_search_with_matryoshka.md @@ -0,0 +1,571 @@ +--- +id: funnel_search_with_matryoshka.md +summary: >- + Neste bloco de notas, examinamos a forma de utilizar as incrustações + Matryoshka com o Milvus para pesquisa semântica. Ilustramos um algoritmo + chamado "pesquisa em funil" que nos permite efetuar uma pesquisa de + semelhanças num pequeno subconjunto das nossas dimensões de incorporação sem + uma queda drástica na recuperação. +title: Pesquisa em funil com embeddings Matryoshka +--- +

      Pesquisa em funil com embeddings Matryoshka

      Ao criar sistemas de pesquisa vetorial eficientes, um dos principais desafios é gerir os custos de armazenamento, mantendo uma latência e uma recuperação aceitáveis. Os modelos modernos de incorporação produzem vectores com centenas ou milhares de dimensões, criando um armazenamento significativo e uma sobrecarga computacional para o vetor bruto e o índice.

      +

      Tradicionalmente, os requisitos de armazenamento são reduzidos através da aplicação de um método de quantização ou de redução da dimensionalidade imediatamente antes da construção do índice. Por exemplo, podemos poupar armazenamento reduzindo a precisão utilizando a Quantização de Produtos (PQ) ou o número de dimensões utilizando a Análise de Componentes Principais (PCA). Estes métodos analisam todo o conjunto de vectores para encontrar um conjunto mais compacto que mantenha as relações semânticas entre os vectores.

      +

      Embora eficazes, estas abordagens padrão reduzem a precisão ou a dimensionalidade apenas uma vez e numa única escala. Mas e se pudéssemos manter várias camadas de pormenor em simultâneo, como uma pirâmide de representações cada vez mais precisas?

      +

      Eis os embeddings Matryoshka. Com o nome das bonecas russas (ver ilustração), estas construções inteligentes incorporam várias escalas de representação num único vetor. Ao contrário dos métodos tradicionais de pós-processamento, os encaixes Matryoshka aprendem esta estrutura multi-escala durante o processo de formação inicial. O resultado é notável: não só a incorporação completa capta a semântica da entrada, como cada prefixo de subconjunto aninhado (primeira metade, primeiro quarto, etc.) fornece uma representação coerente, embora menos pormenorizada.

      +
      +

      Neste caderno, examinamos a forma de utilizar as incrustações Matryoshka com o Milvus para a pesquisa semântica. Ilustramos um algoritmo chamado "pesquisa em funil" que nos permite efetuar pesquisas por semelhança num pequeno subconjunto das nossas dimensões de incorporação sem uma queda drástica na recuperação.

      +
      import functools
      +
      +from datasets import load_dataset
      +import numpy as np
      +import pandas as pd
      +import pymilvus
      +from pymilvus import MilvusClient
      +from pymilvus import FieldSchema, CollectionSchema, DataType
      +from sentence_transformers import SentenceTransformer
      +import torch
      +import torch.nn.functional as F
      +from tqdm import tqdm
      +
      +

      Carregar o modelo de incorporação Matryoshka

      Em vez de utilizar um modelo de incorporação padrão, como sentence-transformers/all-MiniLM-L12-v2utilizamos um modelo da Nomic treinado especialmente para produzir embeddings Matryoshka.

      +
      model = SentenceTransformer(
      +    # Remove 'device='mps' if running on non-Mac device
      +    "nomic-ai/nomic-embed-text-v1.5",
      +    trust_remote_code=True,
      +    device="mps",
      +)
      +
      +
      <All keys matched successfully>
      +
      +

      Carregar o conjunto de dados, incorporar itens e construir uma base de dados de vectores

      O código seguinte é uma modificação do código da página de documentação "Movie Search with Sentence Transformers and Milvus". Primeiro, carregamos o conjunto de dados do HuggingFace. Ele contém cerca de 35 mil entradas, cada uma correspondendo a um filme com um artigo na Wikipédia. Neste exemplo, usaremos os campos Title e PlotSummary.

      +
      ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
      +print(ds)
      +
      +
      Dataset({
      +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
      +    num_rows: 34886
      +})
      +
      +

      Em seguida, ligamo-nos a uma base de dados Milvus Lite, especificamos o esquema de dados e criamos uma coleção com este esquema. Iremos armazenar a incorporação não normalizada e o primeiro sexto da incorporação em campos separados. A razão para isto é que precisamos do primeiro 1/6 da incorporação Matryoshka para efetuar uma pesquisa de semelhança e os restantes 5/6 das incorporações para reordenar e melhorar os resultados da pesquisa.

      +
      embedding_dim = 768
      +search_dim = 128
      +collection_name = "movie_embeddings"
      +
      +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
      +
      +fields = [
      +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
      +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
      +    # First sixth of unnormalized embedding vector
      +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
      +    # Entire unnormalized embedding vector
      +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
      +]
      +
      +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
      +client.create_collection(collection_name=collection_name, schema=schema)
      +
      +

      Atualmente, o Milvus não suporta a pesquisa em subconjuntos de sequências, pelo que dividimos as sequências em duas partes: a cabeça representa o subconjunto inicial do vetor a indexar e pesquisar, e a cauda é o restante. O modelo é treinado para a pesquisa de semelhança de distância de cosseno, por isso normalizamos os embeddings da cabeça. No entanto, para calcular semelhanças para subconjuntos maiores mais tarde, precisamos armazenar a norma da incorporação da cabeça, para que possamos desnormalizá-la antes de juntar à cauda.

      +

      Para efetuar a pesquisa através do primeiro 1/6 da incorporação, teremos de criar um índice de pesquisa vetorial sobre o campo head_embedding. Mais tarde, compararemos os resultados da "pesquisa em funil" com uma pesquisa vetorial normal e, por isso, criaremos também um índice de pesquisa sobre a incorporação completa.

      +

      É importante notar que utilizamos a métrica de distância COSINE em vez da métrica de distância IP, porque, de outro modo, teríamos de registar as normas de incorporação, o que complicaria a implementação (isto fará mais sentido quando o algoritmo de pesquisa em funil for descrito).

      +
      index_params = client.prepare_index_params()
      +index_params.add_index(
      +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
      +)
      +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
      +client.create_index(collection_name, index_params)
      +
      +

      Por fim, codificamos os resumos dos enredos de todos os 35 mil filmes e introduzimos os correspondentes embeddings na base de dados.

      +
      for batch in tqdm(ds.batch(batch_size=512)):
      +    # This particular model requires us to prefix 'search_document:' to stored entities
      +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
      +
      +    # Output of embedding model is unnormalized
      +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
      +    head_embeddings = embeddings[:, :search_dim]
      +
      +    data = [
      +        {
      +            "title": title,
      +            "head_embedding": head.cpu().numpy(),
      +            "embedding": embedding.cpu().numpy(),
      +        }
      +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
      +    ]
      +    res = client.insert(collection_name=collection_name, data=data)
      +
      +
      100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
      +
      +

      Vamos agora implementar uma "pesquisa em funil" utilizando o primeiro 1/6 das dimensões do embedding Matryoshka. Tenho três filmes em mente para recuperar e produzi o meu próprio resumo do enredo para consultar a base de dados. Incorporamos as consultas e, em seguida, efectuamos uma pesquisa vetorial no campo head_embedding, obtendo 128 candidatos a resultados.

      +
      queries = [
      +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
      +    "A teenager fakes illness to get off school and have adventures with two friends.",
      +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
      +]
      +
      +
      +# Search the database based on input text
      +def embed_search(data):
      +    embeds = model.encode(data)
      +    return [x for x in embeds]
      +
      +
      +# This particular model requires us to prefix 'search_query:' to queries
      +instruct_queries = ["search_query: " + q.strip() for q in queries]
      +search_data = embed_search(instruct_queries)
      +
      +# Normalize head embeddings
      +head_search = [x[:search_dim] for x in search_data]
      +
      +# Perform standard vector search on first sixth of embedding dimensions
      +res = client.search(
      +    collection_name=collection_name,
      +    data=head_search,
      +    anns_field="head_embedding",
      +    limit=128,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +

      Nesta altura, fizemos uma pesquisa num espaço vetorial muito mais pequeno e, por isso, é provável que tenhamos reduzido a latência e os requisitos de armazenamento do índice em relação à pesquisa no espaço total. Vamos examinar as 5 principais correspondências para cada consulta:

      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits][:5]
      +
      +    print("Query:", query)
      +    print("Results:")
      +    for row in rows:
      +        print(row["title"].strip())
      +    print()
      +
      +
      Query: An archaeologist searches for ancient artifacts while fighting Nazis.
      +Results:
      +"Pimpernel" Smith
      +Black Hunters
      +The Passage
      +Counterblast
      +Dominion: Prequel to the Exorcist
      +
      +Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Results:
      +How to Deal
      +Shorts
      +Blackbird
      +Valentine
      +Unfriended
      +
      +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
      +Results:
      +Ghostkeeper
      +Our Vines Have Tender Grapes
      +The Ref
      +Impact
      +The House in Marsh Road
      +
      +

      Como podemos ver, a recordação foi afetada como consequência do truncamento dos embeddings durante a pesquisa. A pesquisa em funil resolve isto com um truque inteligente: podemos usar o resto das dimensões de incorporação para classificar e podar a nossa lista de candidatos para recuperar o desempenho da recuperação sem executar quaisquer pesquisas vectoriais adicionais dispendiosas.

      +

      Para facilitar a exposição do algoritmo de pesquisa de funil, convertemos os resultados da pesquisa Milvus para cada consulta num quadro de dados Pandas.

      +
      def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
      +    """
      +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
      +
      +    """
      +    rows = [x["entity"] for x in hits]
      +    rows_dict = [
      +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
      +    ]
      +    return pd.DataFrame.from_records(rows_dict)
      +
      +
      +dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +

      Agora, para efetuar a pesquisa de funil, iteramos sobre os subconjuntos cada vez maiores dos embeddings. Em cada iteração, classificamos novamente os candidatos de acordo com as novas semelhanças e eliminamos uma fração dos candidatos com a classificação mais baixa.

      +

      Para concretizar isto, a partir do passo anterior recuperámos 128 candidatos utilizando 1/6 das dimensões de incorporação e de consulta. O primeiro passo para efetuar a pesquisa em funil consiste em recalcular as semelhanças entre as consultas e os candidatos utilizando o primeiro 1/3 das dimensões. Os últimos 64 candidatos são eliminados. Em seguida, repetimos este processo com os primeiros 2/3 das dimensões e, depois, com todas as dimensões, reduzindo sucessivamente para 32 e 16 candidatos.

      +
      # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
      +def calculate_score(row, query_emb=None, dims=768):
      +    emb = F.normalize(row["embedding"][:dims], dim=-1)
      +    return (emb @ query_emb).item()
      +
      +
      +# You could also add a top-K parameter as a termination condition
      +def funnel_search(
      +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
      +) -> pd.DataFrame:
      +    # Loop over increasing prefixes of the embeddings
      +    for dims in scales:
      +        # Query vector must be normalized for each new dimensionality
      +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
      +
      +        # Score
      +        scores = df.apply(
      +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
      +        )
      +        df["scores"] = scores
      +
      +        # Re-rank
      +        df = df.sort_values(by="scores", ascending=False)
      +
      +        # Prune (in our case, remove half of candidates at each step)
      +        df = df.head(int(prune_ratio * len(df)))
      +
      +    return df
      +
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries, dfs, search_data)
      +]
      +
      +
      for d in dfs_results:
      +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
      +
      +
      An archaeologist searches for ancient artifacts while fighting Nazis. 
      + 0           "Pimpernel" Smith
      +1               Black Hunters
      +29    Raiders of the Lost Ark
      +34             The Master Key
      +51            My Gun Is Quick
      +Name: title, dtype: object 
      +
      +A teenager fakes illness to get off school and have adventures with two friends. 
      + 21               How I Live Now
      +32     On the Edge of Innocence
      +77             Bratz: The Movie
      +4                    Unfriended
      +108                  Simon Says
      +Name: title, dtype: object 
      +
      +A young couple with a kid look after a hotel during winter and the husband goes insane. 
      + 9         The Shining
      +0         Ghostkeeper
      +11     Fast and Loose
      +7      Killing Ground
      +12         Home Alone
      +Name: title, dtype: object 
      +
      +

      Conseguimos recuperar a memória sem efetuar quaisquer pesquisas vectoriais adicionais! Em termos qualitativos, estes resultados parecem ter uma recuperação mais elevada para "Raiders of the Lost Ark" e "The Shining" do que a pesquisa vetorial padrão no tutorial, "Movie Search using Milvus and Sentence Transformers", que utiliza um modelo de incorporação diferente. No entanto, não consegue encontrar "Ferris Bueller's Day Off", ao qual voltaremos mais tarde no caderno. (Ver o artigo Aprendizagem de representações Matryoshka para mais experiências quantitativas e avaliação comparativa).

      +

      Vamos comparar os resultados da nossa pesquisa em funil com uma pesquisa vetorial normal no mesmo conjunto de dados com o mesmo modelo de incorporação. Realizamos uma pesquisa nos embeddings completos.

      +
      # Search on entire embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=search_data,
      +    anns_field="embedding",
      +    limit=5,
      +    output_fields=["title", "embedding"],
      +)
      +
      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits]
      +
      +    print("Query:", query)
      +    print("Results:")
      +    for row in rows:
      +        print(row["title"].strip())
      +    print()
      +
      +
      Query: An archaeologist searches for ancient artifacts while fighting Nazis.
      +Results:
      +"Pimpernel" Smith
      +Black Hunters
      +Raiders of the Lost Ark
      +The Master Key
      +My Gun Is Quick
      +
      +Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Results:
      +A Walk to Remember
      +Ferris Bueller's Day Off
      +How I Live Now
      +On the Edge of Innocence
      +Bratz: The Movie
      +
      +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
      +Results:
      +The Shining
      +Ghostkeeper
      +Fast and Loose
      +Killing Ground
      +Home Alone
      +
      +

      Com exceção dos resultados para "Um adolescente finge estar doente para não ir à escola...", os resultados da pesquisa em funil são quase idênticos aos da pesquisa completa, apesar de a pesquisa em funil ter sido efectuada num espaço de pesquisa de 128 dimensões contra 768 dimensões para a pesquisa regular.

      +

      Investigando a falha de recordação da pesquisa de funil para Ferris Bueller's Day Off

      Por que é que a pesquisa de funil não conseguiu recuperar o filme Ferris Bueller's Day Off? Vamos examinar se ele estava ou não na lista de candidatos original ou se foi filtrado por engano.

      +
      queries2 = [
      +    "A teenager fakes illness to get off school and have adventures with two friends."
      +]
      +
      +
      +# Search the database based on input text
      +def embed_search(data):
      +    embeds = model.encode(data)
      +    return [x for x in embeds]
      +
      +
      +instruct_queries = ["search_query: " + q.strip() for q in queries2]
      +search_data2 = embed_search(instruct_queries)
      +head_search2 = [x[:search_dim] for x in search_data2]
      +
      +# Perform standard vector search on subset of embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=head_search2,
      +    anns_field="head_embedding",
      +    limit=256,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +
      for query, hits in zip(queries, res):
      +    rows = [x["entity"] for x in hits]
      +
      +    print("Query:", queries2[0])
      +    for idx, row in enumerate(rows):
      +        if row["title"].strip() == "Ferris Bueller's Day Off":
      +            print(f"Row {idx}: Ferris Bueller's Day Off")
      +
      +
      Query: A teenager fakes illness to get off school and have adventures with two friends.
      +Row 228: Ferris Bueller's Day Off
      +
      +

      Vemos que o problema é que a lista inicial de candidatos não era suficientemente grande, ou melhor, o resultado desejado não é suficientemente semelhante à consulta no nível mais alto de granularidade. Alterá-la de 128 para 256 resulta numa recuperação bem sucedida. Devemos criar uma regra geral para definir o número de candidatos num conjunto retido para avaliar empiricamente o compromisso entre a recuperação e a latência.

      +
      dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries2, dfs, search_data2)
      +]
      +
      +for d in dfs_results:
      +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
      +
      +
      A teenager fakes illness to get off school and have adventures with two friends. 
      +       A Walk to Remember
      +Ferris Bueller's Day Off
      +          How I Live Now
      +On the Edge of Innocence
      +        Bratz: The Movie
      +              Unfriended
      +              Simon Says 
      +
      +

      A ordem é importante? Embeddings de prefixo vs sufixo.

      O modelo foi treinado para ter um bom desempenho na correspondência de prefixos recursivamente mais pequenos dos embeddings. Será que a ordem das dimensões que utilizamos é importante? Por exemplo, será que também poderíamos pegar em subconjuntos dos embeddings que são sufixos? Nesta experiência, invertemos a ordem das dimensões nos embeddings Matryoshka e efectuamos uma pesquisa de funil.

      +
      client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
      +
      +fields = [
      +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
      +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
      +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
      +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
      +]
      +
      +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
      +client.create_collection(collection_name=collection_name, schema=schema)
      +
      +index_params = client.prepare_index_params()
      +index_params.add_index(
      +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
      +)
      +client.create_index(collection_name, index_params)
      +
      +
      huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
      +To disable this warning, you can either:
      +    - Avoid using `tokenizers` before the fork if possible
      +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
      +
      +
      for batch in tqdm(ds.batch(batch_size=512)):
      +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
      +
      +    # Encode and flip embeddings
      +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
      +    embeddings = torch.flip(embeddings, dims=[-1])
      +    head_embeddings = embeddings[:, :search_dim]
      +
      +    data = [
      +        {
      +            "title": title,
      +            "head_embedding": head.cpu().numpy(),
      +            "embedding": embedding.cpu().numpy(),
      +        }
      +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
      +    ]
      +    res = client.insert(collection_name=collection_name, data=data)
      +
      +
      100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
      +
      +
      # Normalize head embeddings
      +
      +flip_search_data = [
      +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
      +]
      +flip_head_search = [x[:search_dim] for x in flip_search_data]
      +
      +# Perform standard vector search on subset of embeddings
      +res = client.search(
      +    collection_name=collection_name,
      +    data=flip_head_search,
      +    anns_field="head_embedding",
      +    limit=128,
      +    output_fields=["title", "head_embedding", "embedding"],
      +)
      +
      +
      dfs = [hits_to_dataframe(hits) for hits in res]
      +
      +dfs_results = [
      +    {"query": query, "results": funnel_search(df, query_emb)}
      +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
      +]
      +
      +for d in dfs_results:
      +    print(
      +        d["query"],
      +        "\n",
      +        d["results"][:7]["title"].to_string(index=False, header=False),
      +        "\n",
      +    )
      +
      +
      An archaeologist searches for ancient artifacts while fighting Nazis. 
      +       "Pimpernel" Smith
      +          Black Hunters
      +Raiders of the Lost Ark
      +         The Master Key
      +        My Gun Is Quick
      +            The Passage
      +        The Mole People 
      +
      +A teenager fakes illness to get off school and have adventures with two friends. 
      +                       A Walk to Remember
      +                          How I Live Now
      +                              Unfriended
      +Cirque du Freak: The Vampire's Assistant
      +                             Last Summer
      +                                 Contest
      +                                 Day One 
      +
      +A young couple with a kid look after a hotel during winter and the husband goes insane. 
      +         Ghostkeeper
      +     Killing Ground
      +Leopard in the Snow
      +              Stone
      +          Afterglow
      +         Unfaithful
      +     Always a Bride 
      +
      +

      A recuperação é muito mais fraca do que a pesquisa em funil ou a pesquisa regular, como esperado (o modelo de incorporação foi treinado por aprendizagem contrastiva em prefixos das dimensões de incorporação, e não em sufixos).

      +

      Resumo

      Aqui está uma comparação dos nossos resultados de pesquisa entre métodos:

      +
      +
      +
      +Mostrámos como utilizar as incrustações Matryoshka com o Milvus para realizar um algoritmo de pesquisa semântica mais eficiente chamado "pesquisa em funil". Explorámos também a importância dos passos de reordenação e poda do algoritmo, bem como um modo de falha quando a lista inicial de candidatos é demasiado pequena. Finalmente, discutimos como a ordem das dimensões é importante na formação de sub-embeddings - deve ser da mesma forma para a qual o modelo foi treinado. Ou melhor, é apenas porque o modelo foi treinado de uma determinada forma que os prefixos dos embeddings são significativos. Agora já sabe como implementar as incrustações Matryoshka e a pesquisa em funil para reduzir os custos de armazenamento da pesquisa semântica sem sacrificar demasiado o desempenho da recuperação! diff --git a/localization/v2.4.x/site/pt/tutorials/tutorials-overview.md b/localization/v2.4.x/site/pt/tutorials/tutorials-overview.md index 08631c7fb..8ca65236c 100644 --- a/localization/v2.4.x/site/pt/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/pt/tutorials/tutorials-overview.md @@ -28,7 +28,7 @@ title: Visão geral dos tutoriais
      - + @@ -43,5 +43,6 @@ title: Visão geral dos tutoriais +
      Tipo de objetoNome do privilégioDescrição da API relevante no lado do cliente
      RAG multimodal com MilvusRAGpesquisa vetorial, campo dinâmico
      Pesquisa de imagens com MilvusPesquisa semânticapesquisa vetorial, campo dinâmico
      Pesquisa híbrida com MilvusPesquisa híbridapesquisa híbrida, multi-vetor, incorporação densa, incorporação esparsa
      Pesquisa multimodal com vários vectoresPesquisa semânticamulti-vetorial, pesquisa híbrida
      Pesquisa multimodal utilizando múltiplos vectoresPesquisa semânticamulti-vetorial, pesquisa híbrida
      Sistema de resposta a perguntasResposta a perguntaspesquisa vetorial
      Sistema de recomendaçãoSistema de recomendaçãopesquisa vetorial
      Pesquisa de similaridade de vídeoPesquisa semânticapesquisa vetorial
      Utilizar ColPali para recuperação multimodal com MilvusInício rápidopesquisa vetorial
      Visualização de vectoresInício rápidopesquisa vetorial
      Recomendação de filmes com MilvusSistema de recomendaçãopesquisa vetorial
      Pesquisa de funil com Matryoshka EmbeddingsInício rápidopesquisa vetorial
      diff --git a/localization/v2.4.x/site/pt/userGuide/manage-collections.json b/localization/v2.4.x/site/pt/userGuide/manage-collections.json index f12057e63..18a214a1f 100644 --- a/localization/v2.4.x/site/pt/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/pt/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gerir colecções","href":"Manage-Collections","type":1,"isActive":false},{"label":"Antes de começar","href":"Before-you-start","type":2,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Criar coleção","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualizar colecções","href":"View-Collections","type":2,"isActive":false},{"label":"Carregar e libertar a coleção","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Configurar pseudónimos","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Definir propriedades","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonar uma coleção","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"Gerir colecções","href":"Manage-Collections","type":1,"isActive":false},{"label":"Antes de começar","href":"Before-you-start","type":2,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Criar coleção","href":"Create-Collection","type":2,"isActive":false},{"label":"Visualizar colecções","href":"View-Collections","type":2,"isActive":false},{"label":"Carregar e libertar uma coleção","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"Configurar pseudónimos","href":"Set-up-aliases","type":2,"isActive":false},{"label":"Definir propriedades","href":"Set-Properties","type":2,"isActive":false},{"label":"Abandonar uma coleção","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/userGuide/manage-collections.md b/localization/v2.4.x/site/pt/userGuide/manage-collections.md index 195e23410..69b387380 100644 --- a/localization/v2.4.x/site/pt/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/pt/userGuide/manage-collections.md @@ -53,7 +53,7 @@ title: Gerir colecções >

      No Milvus, armazena os seus embeddings vectoriais em colecções. Todos os embeddings vectoriais dentro de uma coleção partilham a mesma dimensionalidade e a mesma métrica de distância para medir a semelhança.

      -

      As colecções Milvus suportam campos dinâmicos (ou seja, campos não pré-definidos no esquema) e incrementação automática de chaves primárias.

      +

      As colecções do Milvus suportam campos dinâmicos (ou seja, campos não pré-definidos no esquema) e incrementação automática de chaves primárias.

      Para acomodar diferentes preferências, Milvus oferece dois métodos para criar uma coleção. Um permite uma configuração rápida, enquanto o outro permite uma personalização detalhada do esquema da coleção e dos parâmetros do índice.

      Adicionalmente, pode visualizar, carregar, libertar e largar uma coleção quando necessário.

      Criar coleção

    -

    Carregar e libertar a coleção

    -

    Reatribuir pseudónimos

    +

    Reatribuir aliases

    Para reatribuir aliases a outras colecções, utilize o método alter_alias() especificando o nome da coleção e o alias.

    diff --git a/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.json index 3c9c3d18e..a180a809b 100644 --- a/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.json +++ b/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.json @@ -1 +1 @@ -{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"","anchorList":[{"label":"Índice de campos escalares","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Tipos de indexação escalar","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexação automática","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexação personalizada","href":"Custom-indexing","type":2,"isActive":false},{"label":"Verificação do resultado","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"Índice de campos escalares","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"Tipos de indexação escalar","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"Indexação automática","href":"Auto-indexing","type":2,"isActive":false},{"label":"Indexação personalizada","href":"Custom-indexing","type":2,"isActive":false},{"label":"Verificação do resultado","href":"Verifying-the-result","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.md index 08db460a4..d62910f99 100644 --- a/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.md +++ b/localization/v2.4.x/site/pt/userGuide/manage-indexes/index-scalar-fields.md @@ -4,7 +4,7 @@ order: 2 summary: >- Este guia irá orientá-lo na criação e configuração de índices escalares para campos como inteiros, cadeias de caracteres, etc. -title: Campos escalares de índice +title: Índice de campos escalares ---

    Índice de campos escalares

    No Milvus, um índice escalar é usado para acelerar a metafiltragem por um valor de campo específico não-vetorial, semelhante a um índice de base de dados tradicional. Este guia irá guiá-lo na criação e configuração de índices escalares para campos como inteiros, strings, etc.

    +

    No Milvus, um índice escalar é usado para acelerar a metafiltragem por um valor de campo específico não vetorial, semelhante a um índice de base de dados tradicional. Este guia irá guiá-lo na criação e configuração de índices escalares para campos como inteiros, strings, etc.

    Tipos de indexação escalar

    Este guia explica-lhe como criar e gerir partições numa coleção.

    -

    Visão geral

    É possível adicionar mais partições à coleção. Uma coleção pode ter até 1.024 partições.

    +

    Pode adicionar mais partições à coleção. Uma coleção pode ter até 1.024 partições.

    Para criar partições, use create_partition().

    @@ -652,7 +652,7 @@ res = await client."partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionA" ) @@ -663,7 +663,7 @@ res = client.get_load_status( # "state": "<LoadState: Loaded>" # } -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionB" ) @@ -820,7 +820,7 @@ res = await client."_default", "partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", ) diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.json b/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.json index 6c128c07a..12b01c280 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.json +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.json @@ -1 +1 @@ -{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"10.102.7.3\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"","anchorList":[{"label":"Pesquisa híbrida","href":"Hybrid-Search","type":1,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Etapa 1: criar várias instâncias de AnnSearchRequest","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"Etapa 2: Configurar uma estratégia de ranqueamento","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"Etapa 3: Executar uma pesquisa híbrida","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false},{"label":"PERGUNTAS FREQUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"127.0.0.1\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"Hybrid Search","anchorList":[{"label":"Pesquisa híbrida","href":"Hybrid-Search","type":1,"isActive":false},{"label":"Preparativos","href":"Preparations","type":2,"isActive":false},{"label":"Etapa 1: criar várias instâncias de AnnSearchRequest","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"Etapa 2: Configurar uma estratégia de ranqueamento","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"Etapa 3: Executar uma pesquisa híbrida","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"Limites","href":"Limits","type":2,"isActive":false},{"label":"PERGUNTAS FREQUENTES","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.md b/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.md index 315c8d47c..30f41dad0 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.md +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/multi-vector-search.md @@ -26,7 +26,7 @@ title: Pesquisa híbrida

    Neste tutorial, você aprenderá como:

    • Criar várias instâncias de AnnSearchRequest para pesquisas de similaridade em diferentes campos vetoriais;

    • -
    • Configurar uma estratégia de classificação para combinar e classificar novamente os resultados de pesquisa de várias instâncias de AnnSearchRequest;

    • +
    • Configurar uma estratégia de classificação para combinar e classificar os resultados de pesquisa de várias instâncias de AnnSearchRequest;

    • Utilizar o método hybrid_search() para executar uma pesquisa híbrida.

    @@ -54,7 +54,7 @@ title: Pesquisa híbrida # Connect to Milvus connections.connect( - host="10.102.7.3", # Replace with your Milvus server IP + host="127.0.0.1", # Replace with your Milvus server IP port="19530" ) @@ -214,7 +214,7 @@ rerank = RRFRanker() d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    Com as instâncias de AnnSearchRequest e a estratégia de reranking definidas, use o método hybrid_search() para executar a pesquisa híbrida.

    +

    Com as instâncias AnnSearchRequest e a estratégia de reranking definidas, use o método hybrid_search() para executar a pesquisa híbrida.

    # Before conducting hybrid search, load the collection into memory.
     collection.load()
     
    @@ -276,7 +276,7 @@ res = collection.hybrid_search(
           
         
    • Em que cenário a pesquisa híbrida é recomendada?

      -

      A pesquisa híbrida é ideal para situações complexas que exigem uma elevada precisão, especialmente quando uma entidade pode ser representada por vários vectores diferentes. Isto aplica-se aos casos em que os mesmos dados, como uma frase, são processados através de diferentes modelos de incorporação ou quando a informação multimodal (como imagens, impressões digitais e impressões de voz de um indivíduo) é convertida em vários formatos vectoriais. Ao atribuir pesos a estes vectores, a sua influência combinada pode enriquecer significativamente a recuperação e melhorar a eficácia dos resultados da pesquisa.

    • +

      A pesquisa híbrida é ideal para situações complexas que exigem uma elevada precisão, especialmente quando uma entidade pode ser representada por vários vectores diferentes. Isto aplica-se a casos em que os mesmos dados, como uma frase, são processados através de diferentes modelos de incorporação ou quando a informação multimodal (como imagens, impressões digitais e impressões de voz de um indivíduo) é convertida em vários formatos vectoriais. Ao atribuir pesos a estes vectores, a sua influência combinada pode enriquecer significativamente a recuperação e melhorar a eficácia dos resultados da pesquisa.

    • Como é que um classificador ponderado normaliza as distâncias entre diferentes campos vectoriais?

      Um classificador ponderado normaliza as distâncias entre campos vectoriais utilizando pesos atribuídos a cada campo. Calcula a importância de cada campo vetorial de acordo com o seu peso, dando prioridade aos que têm pesos mais elevados. É aconselhável utilizar o mesmo tipo de métrica nos pedidos de pesquisa ANN para garantir a consistência. Este método garante que os vectores considerados mais significativos têm uma maior influência na classificação geral.

    • É possível utilizar classificadores alternativos como o Cohere Ranker ou o BGE Ranker?

      diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.json index d7cf4cd69..dbd1a1bb3 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Pesquisa num único vetor","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Preparações","href":"Preparations","type":2,"isActive":false},{"label":"Pesquisa básica","href":"Basic-search","type":2,"isActive":false},{"label":"Pesquisa filtrada","href":"Filtered-search","type":2,"isActive":false},{"label":"Pesquisa de intervalo","href":"Range-search","type":2,"isActive":false},{"label":"Pesquisa de agrupamento","href":"Grouping-search","type":2,"isActive":false},{"label":"Parâmetros de pesquisa","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"Pesquisa de vetor único","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Preparações","href":"Preparations","type":2,"isActive":false},{"label":"Pesquisa básica","href":"Basic-search","type":2,"isActive":false},{"label":"Pesquisa filtrada","href":"Filtered-search","type":2,"isActive":false},{"label":"Pesquisa de intervalo","href":"Range-search","type":2,"isActive":false},{"label":"Pesquisa de agrupamento","href":"Grouping-search","type":2,"isActive":false},{"label":"Parâmetros de pesquisa","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.md index cc8a25515..628ed9752 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/single-vector-search.md @@ -4,9 +4,9 @@ order: 1 summary: >- Este artigo descreve como procurar vectores numa coleção Milvus utilizando um único vetor de consulta. -title: Pesquisa num único vetor +title: Pesquisa de vetor único --- -

      Pesquisa num único vetor

      O trecho de código abaixo reaproveita o código existente para estabelecer uma conexão com o Milvus e configurar rapidamente uma coleção.

      -
      # 1. Set up a Milvus client
      +
      from pymilvus import MilvusClient
      +import random
      +
      +# 1. Set up a Milvus client
       client = MilvusClient(
      -    uri=CLUSTER_ENDPOINT,
      -    token=TOKEN 
      +    uri="http://localhost:19530"
       )
       
       # 2. Create a collection
      @@ -449,7 +451,7 @@ res = await client.Python  Java Node.js
    # Single vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         # Replace with your query vector
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
    @@ -643,7 +645,7 @@ res = await client.Python  Java Node.js
    # Bulk-vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[
             [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
             [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
    @@ -1228,7 +1230,7 @@ searchResp = client.search(searchReq);
        Python  Java Node.js
    # Search with output fields
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1376,7 +1378,7 @@ res = await client.Python  Java Node.js
     
    # Search with filter
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1483,7 +1485,7 @@ res = await client.Python  Java Node.js
     
    # Infix match on color field
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1584,7 +1586,7 @@ search_params = {
     }
     
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=3, # Max. number of search results to return
         search_params=search_params, # Search parameters
    @@ -1840,6 +1842,6 @@ search_parameters = {
     
     

    notas

    -

    [1] Número de unidades de cluster após a indexação. Ao indexar uma coleção, Milvus subdivide os dados vectoriais em várias unidades de agrupamento, cujo número varia com as definições de indexação actuais.

    +

    [1] Número de unidades de cluster após a indexação. Ao indexar uma coleção, o Milvus subdivide os dados vectoriais em várias unidades de agrupamento, cujo número varia com as definições de indexação actuais.

    [2] Número de entidades a devolver numa pesquisa.

    diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.json b/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.json index 97979f19c..f54f27dd9 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.json +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Com Iteradores","href":"With-Iterators","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Preparações","href":"Preparations","type":2,"isActive":false},{"label":"Pesquisa com iterador","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Consultar com um iterador","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n","import io.milvus.client.MilvusServiceClient;\nimport io.milvus.param.ConnectParam;\nimport io.milvus.param.highlevel.collection.CreateSimpleCollectionParam;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectParam connectParam = ConnectParam.newBuilder()\n .withUri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusServiceClient client = new MilvusServiceClient(connectParam);\n\n// 2. Create a collection\nCreateSimpleCollectionParam createCollectionParam = CreateSimpleCollectionParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withDimension(5)\n .build();\n\nclient.createCollection(createCollectionParam);\n","# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(10000):\n current_color = random.choice(colors)\n current_tag = random.randint(1000, 9999)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"tag\": current_tag,\n \"color_tag\": f\"{current_color}_{str(current_tag)}\"\n })\n\nprint(data[0])\n\n# Output\n#\n# {\n# \"id\": 0,\n# \"vector\": [\n# -0.5705990742218152,\n# 0.39844925120642083,\n# -0.8791287928610869,\n# 0.024163154953680932,\n# 0.6837669917169638\n# ],\n# \"color\": \"purple\",\n# \"tag\": 7774,\n# \"color_tag\": \"purple_7774\"\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data,\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 10000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(9990 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.param.R;\nimport io.milvus.param.dml.InsertParam;\nimport io.milvus.response.MutationResultWrapper;\nimport io.milvus.grpc.MutationResult;\n\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<10000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertParam insertParam = InsertParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withRows(data)\n .build();\n\nR insertRes = client.insert(insertParam);\n\nif (insertRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(insertRes.getMessage());\n}\n\nMutationResultWrapper wrapper = new MutationResultWrapper(insertRes.getData());\nSystem.out.println(wrapper.getInsertCount());\n","from pymilvus import Collection,connections\n\n# 4. Search with iterator\nconnections.connect(host=\"127.0.0.1\", port=19530)\ncollection = Collection(\"quick_setup\")\n\nquery_vectors = [[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]]\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\"nprobe\": 10}\n}\n\niterator = collection.search_iterator(\n data=query_vectors,\n anns_field=\"vector\",\n batch_size=10,\n param=search_params,\n output_fields=[\"color_tag\"],\n limit=300\n)\n# search 300 entities totally with 10 entities per page\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n for hit in result:\n results.append(hit.to_dict())\n\nprint(results)\n\n# Output\n#\n# [\n# {\n# \"id\": 1756,\n# \"distance\": 2.0642056465148926,\n# \"entity\": {\n# \"color_tag\": \"black_9109\"\n# }\n# },\n# {\n# \"id\": 6488,\n# \"distance\": 1.9437453746795654,\n# \"entity\": {\n# \"color_tag\": \"purple_8164\"\n# }\n# },\n# {\n# \"id\": 3338,\n# \"distance\": 1.9107104539871216,\n# \"entity\": {\n# \"color_tag\": \"brown_8121\"\n# }\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.param.dml.SearchIteratorParam;\nimport io.milvus.response.QueryResultsWrapper;\nimport io.milvus.orm.iterator.SearchIterator;\n\n// 4. Search with iterators\nSearchIteratorParam iteratorParam = SearchIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withVectorFieldName(\"vector\")\n // Use withFloatVectors() in clusters compatible with Milvus 2.4.x\n .withVectors(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f))\n .withBatchSize(10L)\n .withParams(\"{\\\"metric_type\\\": \\\"COSINE\\\", \\\"params\\\": {\\\"level\\\": 1}}\")\n .build();\n \n\nR searchIteratorRes = client.searchIterator(iteratorParam);\n\nif (searchIteratorRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(searchIteratorRes.getMessage());\n}\n\nSearchIterator searchIterator = searchIteratorRes.getData();\nList results = new ArrayList<>();\n\nwhile (true) {\n List batchResults = searchIterator.next();\n if (batchResults.isEmpty()) {\n searchIterator.close();\n break;\n }\n for (QueryResultsWrapper.RowRecord rowRecord : batchResults) {\n results.add(rowRecord);\n }\n}\n\nSystem.out.println(results.size());\n","# 6. Query with iterator\niterator = collection.query_iterator(\n batch_size=10, # Controls the size of the return each time you call next()\n expr=\"color_tag like \\\"brown_8\\\"\",\n output_fields=[\"color_tag\"]\n)\n\nresults = []\n\nwhile True:\n result = iterator.next()\n if not result:\n iterator.close()\n break\n \n results.extend(result)\n \n# 8. Check the search results\nprint(len(results))\n\nprint(results[:3])\n\n# Output\n#\n# [\n# {\n# \"color_tag\": \"brown_8785\",\n# \"id\": 94\n# },\n# {\n# \"color_tag\": \"brown_8568\",\n# \"id\": 176\n# },\n# {\n# \"color_tag\": \"brown_8721\",\n# \"id\": 289\n# }\n# ]\n","import io.milvus.param.dml.QueryIteratorParam;\nimport io.milvus.orm.iterator.QueryIterator;\n\n// 5. Query with iterators\n\ntry {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(new ArrayList<>()).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n} catch (Exception e) {\n // TODO: handle exception\n e.printStackTrace();\n}\n\nQueryIteratorParam queryIteratorParam = QueryIteratorParam.newBuilder()\n .withCollectionName(\"quick_setup\")\n .withExpr(\"color_tag like \\\"brown_8%\\\"\")\n .withBatchSize(50L)\n .addOutField(\"vector\")\n .addOutField(\"color_tag\")\n .build();\n\nR queryIteratRes = client.queryIterator(queryIteratorParam);\n\nif (queryIteratRes.getStatus() != R.Status.Success.getCode()) {\n System.err.println(queryIteratRes.getMessage());\n}\n\nQueryIterator queryIterator = queryIteratRes.getData();\n\nwhile (true) {\n List batchResults = queryIterator.next();\n if (batchResults.isEmpty()) {\n queryIterator.close();\n break;\n }\n\n String jsonString = \"\";\n List jsonObject = new ArrayList<>();\n try {\n jsonString = Files.readString(Path.of(\"results.json\"));\n jsonObject = JSON.parseArray(jsonString).toJavaList(null);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n for (QueryResultsWrapper.RowRecord queryResult : batchResults) {\n JSONObject row = new JSONObject();\n row.put(\"id\", queryResult.get(\"id\"));\n row.put(\"vector\", queryResult.get(\"vector\"));\n row.put(\"color_tag\", queryResult.get(\"color_tag\"));\n jsonObject.add(row);\n }\n\n try {\n Files.write(Path.of(\"results.json\"), JSON.toJSONString(jsonObject).getBytes(), StandardOpenOption.WRITE);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n"],"headingContent":"With Iterators","anchorList":[{"label":"Com Iteradores","href":"With-Iterators","type":1,"isActive":false},{"label":"Visão geral","href":"Overview","type":2,"isActive":false},{"label":"Preparações","href":"Preparations","type":2,"isActive":false},{"label":"Pesquisa com iterador","href":"Search-with-iterator","type":2,"isActive":false},{"label":"Consultar com um iterador","href":"Query-with-an-iterator","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.md b/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.md index 29cddde03..9ea003af3 100644 --- a/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.md +++ b/localization/v2.4.x/site/pt/userGuide/search-query-get/with-iterators.md @@ -248,7 +248,7 @@ System.out.println(wrapper.getInsertCount()); -
    from pymilvus import Collection
    +
    from pymilvus import Collection,connections
     
     # 4. Search with iterator
     connections.connect(host="127.0.0.1", port=19530)
    @@ -375,7 +375,7 @@ System.out.println(results.size());
         
         
           output_fields
    -      Uma lista de nomes de campo para incluir em cada entidade em retorno.
    O valor padrão é None. Se não for especificado, apenas o campo primário será incluído. + Uma lista de nomes de campos para incluir em cada entidade em retorno.
    O valor padrão é None. Se não for especificado, apenas o campo primário será incluído. limit diff --git a/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.json b/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.json index ecbf09d8d..7b9518610 100644 --- a/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.json +++ b/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.json @@ -1 +1 @@ -{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"使用 Helm 图表升级 Milvus 群集","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"检查 Milvus Helm 图表","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"进行滚动升级","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"使用 Helm 升级 Milvus","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"迁移元数据","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ helm repo update\n$ helm search repo zilliztech/milvus --versions\n","helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","NAME CHART VERSION APP VERSION DESCRIPTION \nzilliztech/milvus 4.1.34 2.4.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.33 2.4.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.32 2.4.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.31 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.30 2.4.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.29 2.4.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.24 2.3.11 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.23 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.22 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.21 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.20 2.3.10 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.18 2.3.10 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.18 2.3.9 Milvus is an open-source vector database built ... \nzilliztech/milvus 4.1.17 2.3.8 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.16 2.3.7 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.15 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.14 2.3.6 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.13 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.12 2.3.5 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.11 2.3.4 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.10 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.9 2.3.3 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.8 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.7 2.3.2 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.6 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.5 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.4 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.3 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.2 2.3.1 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.1 2.3.0 Milvus is an open-source vector database built ...\nzilliztech/milvus 4.1.0 2.3.0 Milvus is an open-source vector database built ...\n","sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'\n","helm repo update\nhelm upgrade my-release zilliztech/milvus --reuse-values --version=4.1.24 # use the helm chart version here\n","NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION \nnew-release default 1 2022-11-21 15:41:25.51539 +0800 CST deployed milvus-3.2.18 2.1.4 \n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 21m\nmy-release-etcd-1 1/1 Running 0 21m\nmy-release-etcd-2 1/1 Running 0 21m\nmy-release-milvus-datacoord-664c58798d-fl75s 1/1 Running 0 21m\nmy-release-milvus-datanode-5f75686c55-xfg2r 1/1 Running 0 21m\nmy-release-milvus-indexcoord-5f98b97589-2l48r 1/1 Running 0 21m\nmy-release-milvus-indexnode-857b4ddf98-vmd75 1/1 Running 0 21m\nmy-release-milvus-proxy-6c548f787f-scspp 1/1 Running 0 21m\nmy-release-milvus-querycoord-c454f44cd-dwmwq 1/1 Running 0 21m\nmy-release-milvus-querynode-76bb4946d-lbrz6 1/1 Running 0 21m\nmy-release-milvus-rootcoord-7764c5b686-62msm 1/1 Running 0 21m\nmy-release-minio-0 1/1 Running 0 21m\nmy-release-minio-1 1/1 Running 0 21m\nmy-release-minio-2 1/1 Running 0 21m\nmy-release-minio-3 1/1 Running 0 21m\nmy-release-pulsar-bookie-0 1/1 Running 0 21m\nmy-release-pulsar-bookie-1 1/1 Running 0 21m\nmy-release-pulsar-bookie-2 1/1 Running 0 21m\nmy-release-pulsar-bookie-init-tjxpj 0/1 Completed 0 21m\nmy-release-pulsar-broker-0 1/1 Running 0 21m\nmy-release-pulsar-proxy-0 1/1 Running 0 21m\nmy-release-pulsar-pulsar-init-c8vvc 0/1 Completed 0 21m\nmy-release-pulsar-recovery-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-0 1/1 Running 0 21m\nmy-release-pulsar-zookeeper-1 1/1 Running 0 20m\nmy-release-pulsar-zookeeper-2 1/1 Running 0 20m\n","$ kubectl get pods my-release-milvus-proxy-6c548f787f-scspp -o=jsonpath='{$.spec.containers[0].image}'\n# milvusdb/milvus:v2.1.4\n","./migrate.sh -i my-release -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true\n","./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4\n./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0\n"],"headingContent":"Upgrade Milvus Cluster with Helm Chart","anchorList":[{"label":"使用 Helm 图表升级 Milvus 群集","href":"Upgrade-Milvus-Cluster-with-Helm-Chart","type":1,"isActive":false},{"label":"检查 Milvus Helm 图表","href":"Check-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"进行滚动升级","href":"Conduct-a-rolling-upgrade","type":2,"isActive":false},{"label":"使用 Helm 升级 Milvus","href":"Upgrade-Milvus-using-Helm","type":2,"isActive":false},{"label":"迁移元数据","href":"Migrate-the-metadata","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.md b/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.md index 28ceb2f1f..257541bb2 100644 --- a/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.md +++ b/localization/v2.4.x/site/zh/adminGuide/upgrade_milvus_cluster-helm.md @@ -123,7 +123,7 @@ zilliztech/milvus 4.1.0 2.3.0 Milvus is an ope o操作符update假 -

    确保 Milvus 实例中的所有部署都处于正常状态后。就可以运行以下命令将 Milvus 实例升级到 2.4.15。

    +

    确保 Milvus 实例中的所有部署都处于正常状态后。可以运行以下命令将 Milvus 实例升级到 2.4.15。

    sh rollingUpdate.sh -n default -i my-release -o update -t 2.4.15 -w 'milvusdb/milvus:v2.4.15'
     
    @@ -235,25 +235,25 @@ my-release-pulsar-zookeeper-2
  • 迁移 Milvus 元数据。
  • 使用新镜像启动 Milvus 组件。
  • -

    2.将 Milvus 从 2.1.x 版升级到 2.4.15 版

    以下命令假定你将 Milvus 从 v2.1.4 升级到 2.4.15。请将它们更改为适合你需要的版本。

    +

    2.将 Milvus 从 2.1.x 版升级到 2.2.0 版

    以下命令假定你将 Milvus 从 v2.1.4 升级到 2.2.0。请将它们更改为适合你需要的版本。

    1. 指定 Milvus 实例名称、源 Milvus 版本和目标 Milvus 版本。

      -
      ./migrate.sh -i my-release -s 2.1.4 -t 2.4.15
      +
      ./migrate.sh -i my-release -s 2.1.4 -t 2.2.0
       
    2. 如果你的 Milvus 没有安装在默认的 K8s 命名空间,请用-n 指定命名空间。

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0
       
    3. 如果 Milvus 安装的是自定义rootpath ,请用-r 指定根路径。

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev
       
    4. 如果你的 Milvus 安装的是自定义image ,请用-w 指定图片标签。

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -w milvusdb/milvus:v2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -w milvusdb/milvus:v2.2.0
       
    5. 如果想在迁移完成后自动移除迁移 pod,请设置-d true

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -w milvusdb/milvus:v2.4.15 -d true
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -w milvusdb/milvus:v2.2.0 -d true
       
    6. 如果迁移失败,请回滚并重新迁移。

      -
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o rollback -w milvusdb/milvus:v2.1.1
      -./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.4.15 -r by-dev -o migrate -w milvusdb/milvus:v2.4.15
      +
      ./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o rollback -w milvusdb/milvus:v2.1.4
      +./migrate.sh -i my-release -n milvus -s 2.1.4 -t 2.2.0 -r by-dev -o migrate -w milvusdb/milvus:v2.2.0
       
    diff --git a/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.json b/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.json index 1086cfc06..c26ab5ee3 100644 --- a/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.json +++ b/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.json @@ -1,73 +1 @@ -{ - "codeList": [ - "$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n", - "$ helm repo add milvus https://zilliztech.github.io/milvus-helm/\n", - "helm repo add zilliztech https://zilliztech.github.io/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n", - "$ helm repo update\n", - "$ helm install my-release milvus/milvus\n", - "$ kubectl get pods\n", - "NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n", - "$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n", - "$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n", - "$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n", - "$ helm template my-release milvus/milvus > milvus_manifest.yaml\n", - "$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n", - "$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n", - "$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n", - "$ kubectl apply -f milvus_manifest.yaml\n", - "$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n", - "$ helm uninstall my-release\n" - ], - "headingContent": "", - "anchorList": [ - { - "label": "使用 Helm 在 Kubernetes 中运行 Milvus", - "href": "Run-Milvus-in-Kubernetes-with-Helm", - "type": 1, - "isActive": false - }, - { "label": "概述", "href": "Overview", "type": 2, "isActive": false }, - { - "label": "先决条件", - "href": "Prerequisites", - "type": 2, - "isActive": false - }, - { - "label": "安装Milvus舵手图", - "href": "Install-Milvus-Helm-Chart", - "type": 2, - "isActive": false - }, - { - "label": "在线安装", - "href": "Online-install", - "type": 2, - "isActive": false - }, - { - "label": "离线安装", - "href": "Offline-install", - "type": 2, - "isActive": false - }, - { - "label": "升级运行中的 Milvus 集群", - "href": "Upgrade-running-Milvus-cluster", - "type": 2, - "isActive": false - }, - { - "label": "卸载 Milvus", - "href": "Uninstall-Milvus", - "type": 2, - "isActive": false - }, - { - "label": "下一步行动", - "href": "Whats-next", - "type": 2, - "isActive": false - } - ] -} +{"codeList":["$ kubectl get sc\n\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBIINDINGMODE ALLOWVOLUMEEXPANSION AGE\nstandard (default) k8s.io/minikube-hostpath Delete Immediate false \n","$ helm repo add milvus https://github.com/zilliztech/milvus-helm\n","helm repo add zilliztech https://github.com/zilliztech/milvus-helm\nhelm repo update\n# upgrade existing helm release\nhelm upgrade my-release zilliztech/milvus\n","$ helm repo update\n","$ helm install my-release milvus/milvus\n","$ kubectl get pods\n","NAME READY STATUS RESTARTS AGE\nmy-release-etcd-0 1/1 Running 0 3m23s\nmy-release-etcd-1 1/1 Running 0 3m23s\nmy-release-etcd-2 1/1 Running 0 3m23s\nmy-release-milvus-datanode-68cb87dcbd-4khpm 1/1 Running 0 3m23s\nmy-release-milvus-indexnode-5c5f7b5bd9-l8hjg 1/1 Running 0 3m24s\nmy-release-milvus-mixcoord-7fb9488465-dmbbj 1/1 Running 0 3m23s\nmy-release-milvus-proxy-6bd7f5587-ds2xv 1/1 Running 0 3m24s\nmy-release-milvus-querynode-5cd8fff495-k6gtg 1/1 Running 0 3m24s\nmy-release-minio-0 1/1 Running 0 3m23s\nmy-release-minio-1 1/1 Running 0 3m23s\nmy-release-minio-2 1/1 Running 0 3m23s\nmy-release-minio-3 1/1 Running 0 3m23s\nmy-release-pulsar-autorecovery-86f5dbdf77-lchpc 1/1 Running 0 3m24s\nmy-release-pulsar-bookkeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-bookkeeper-1 1/1 Running 0 98s\nmy-release-pulsar-broker-556ff89d4c-2m29m 1/1 Running 0 3m23s\nmy-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-0 1/1 Running 0 3m23s\nmy-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s\n","$ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template\n='{{(index (index .spec.containers 0).ports 0).containerPort}}{{\"\\n\"}}'\n19530\n","$ kubectl port-forward service/my-release-milvus 27017:19530\nForwarding from 127.0.0.1:27017 -> 19530\n","$ kubectl port-forward --address 0.0.0.0 service/my-release-milvus 27017:19530\nForwarding from 0.0.0.0:27017 -> 19530\n","$ helm template my-release milvus/milvus > milvus_manifest.yaml\n","$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt\n$ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py\n","$ pip3 install -r requirements.txt\n$ python3 save_image.py --manifest milvus_manifest.yaml\n","$ for image in $(find . -type f -name \"*.tar.gz\") ; do gunzip -c $image | docker load; done\n","$ kubectl apply -f milvus_manifest.yaml\n","$ helm repo update\n$ helm upgrade my-release zilliztech/milvus\n","$ helm uninstall my-release\n"],"headingContent":"Run Milvus in Kubernetes with Helm","anchorList":[{"label":"使用 Helm 在 Kubernetes 中运行 Milvus","href":"Run-Milvus-in-Kubernetes-with-Helm","type":1,"isActive":false},{"label":"概述","href":"Overview","type":2,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"安装 Milvus Helm 图表","href":"Install-Milvus-Helm-Chart","type":2,"isActive":false},{"label":"在线安装","href":"Online-install","type":2,"isActive":false},{"label":"离线安装","href":"Offline-install","type":2,"isActive":false},{"label":"升级运行中的 Milvus 群集","href":"Upgrade-running-Milvus-cluster","type":2,"isActive":false},{"label":"卸载 Milvus","href":"Uninstall-Milvus","type":2,"isActive":false},{"label":"下一步","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.md b/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.md index 0e5a3031b..1ed271553 100644 --- a/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.md +++ b/localization/v2.4.x/site/zh/getstarted/run-milvus-k8s/install_cluster-helm.md @@ -3,9 +3,8 @@ id: install_cluster-helm.md label: Helm related_key: Kubernetes summary: 了解如何在 Kubernetes 上安装 Milvus 集群。 -title: 使用 Helm 安装 Milvus 集群 +title: 使用 Helm 安装 Milvus 群集 --- -

    使用 Helm 在 Kubernetes 中运行 Milvus

    本页说明如何使用Milvus Helm 图表在 Kubernetes 中启动Milvus 实例。

    +

    本页说明如何使用Milvus Helm 图表在 Kubernetes 中启动 Milvus 实例。

    概述

    Helm 使用一种称为图表的打包格式。图表是描述一组相关 Kubernetes 资源的文件集合。Milvus 提供了一组图表,可帮助您部署 Milvus 依赖项和组件。

    +

    Helm 使用一种称为图表的打包格式。图表是描述一组相关 Kubernetes 资源的文件 Collections。Milvus 提供了一组图表,可帮助您部署 Milvus 依赖项和组件。

    前提条件

    -
  • 安装前检查硬件和软件要求

  • -
  • 安装 Milvus 之前,建议使用Milvus 大小工具,根据数据大小估算硬件要求。这有助于确保 Milvus 安装的最佳性能和资源分配。

  • +
  • 安装 Milvus 之前,建议使用Milvus 大小工具,根据数据大小估算硬件需求。这有助于确保 Milvus 安装的最佳性能和资源分配。

  • -

    如果您在拉动图像时遇到任何问题,请通过community@zilliz.com联系我们,并提供有关问题的详细信息,我们将为您提供必要的支持。

    +

    如果您在绘制图像时遇到任何问题,请通过community@zilliz.com联系我们,并提供有关问题的详细信息,我们将为您提供必要的支持。

    -

    安装 Milvus 舵手图

    在安装 Milvus Helm 图表之前,您需要添加 Milvus Helm 资源库。

    -
    $ helm repo add milvus https://zilliztech.github.io/milvus-helm/
    +
    $ helm repo add milvus https://github.com/zilliztech/milvus-helm
     
    -

    https://milvus-io.github.io/milvus-helm/ 上的 Milvus Helm Charts 软件源已经归档,你可以从https://zilliztech.github.io/milvus-helm/ 上获取更多更新,如下所示:

    -
    helm repo add zilliztech https://zilliztech.github.io/milvus-helm
    +

    位于https://github.com/milvus-io/milvus-helm 的 Milvus Helm Charts 软件仓库已经存档,您可以从https://github.com/zilliztech/milvus-helm 获取进一步更新,具体如下:

    +
    helm repo add zilliztech https://github.com/zilliztech/milvus-helm
     helm repo update
     # upgrade existing helm release
     helm upgrade my-release zilliztech/milvus
    @@ -115,20 +113,20 @@ helm upgrade my-release zilliztech/milvus
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    1.部署 Milvus 集群

    安装好 Helm 图表后,就可以在 Kubernetes 上启动 Milvus。本节将指导你完成启动 Milvus 的步骤。

    +

    1.部署 Milvus 集群

    安装好 Helm 图表后,就可以在 Kubernetes 上启动 Milvus 了。本节将指导你完成启动 Milvus 的步骤。

    $ helm install my-release milvus/milvus
     

    在上述命令中,my-release 是版本名称,milvus/milvus 是本地安装的图表版本库。要使用其他名称,请将my-release 替换为您认为合适的名称。

    -

    上述命令使用默认配置部署 Milvus 群集及其组件和依赖项。要自定义这些设置,我们建议你使用Milvus 大小工具,根据实际数据大小调整配置,然后下载相应的 YAML 文件。要了解有关配置参数的更多信息,请参阅Milvus 系统配置清单

    +

    上述命令使用默认配置部署 Milvus 群集及其组件和依赖项。要自定义这些设置,我们建议你使用Milvus 大小调整工具,根据实际数据大小调整配置,然后下载相应的 YAML 文件。要了解有关配置参数的更多信息,请参阅Milvus 系统配置检查表

    • 版本名称只能包含字母、数字和破折号。版本名称中不允许使用点。
    • -
    • 使用 Helm 安装 Milvus 时,默认命令行安装群集版本的 Milvus。独立安装 Milvus 时需要进一步设置。
    • -
    • 根据Kubernetes 过时的 API 迁移指南,PodDisruptionBudget 的policy/v1beta1API 版本自 v1.25 起不再提供服务。建议您迁移清单和 API 客户端,改用policy/v1API 版本。
      对于仍在 Kubernetes v1.25 及更高版本上使用 PodDisruptionBudget 的policy/v1beta1API 版本的用户,作为一种变通方法,您可以运行以下命令来安装 Milvus:
      helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
    • -
    • 更多信息,请参阅Milvus Helm ChartHelm
    • +
    • 在使用 Helm 安装 Milvus 时,默认命令行会安装群集版本的 Milvus。独立安装 Milvus 时需要进一步设置。
    • +
    • 根据Kubernetes 过时的 API 迁移指南,从 v1.25 起,PodDisruptionBudget 的policy/v1beta1API 版本不再提供服务。建议迁移清单和 API 客户端,改用policy/v1API 版本。
      对于仍在 Kubernetes v1.25 及更高版本上使用 PodDisruptionBudget 的policy/v1beta1API 版本的用户,作为一种变通方法,您可以运行以下命令来安装 Milvus:
      helm install my-release milvus/milvus --set pulsar.bookkeeper.pdb.usePolicy=false,pulsar.broker.pdb.usePolicy=false,pulsar.proxy.pdb.usePolicy=false,pulsar.zookeeper.pdb.usePolicy=false
    • +
    • 更多信息请参见Milvus Helm ChartHelm
    -

    2.检查 Milvus 群集状态

    运行以下命令检查 Milvus 集群中所有 pod 的状态。

    +

    2.检查 Milvus 集群状态

    运行以下命令检查 Milvus 集群中所有 pod 的状态。

    $ kubectl get pods
     

    一旦所有 pod 都在运行,上述命令的输出应与下图类似:

    @@ -153,7 +151,7 @@ my-release-pulsar-proxy-6fbd75db75-nhg4v 1/1 Running 0 3m23s my-release-pulsar-zookeeper-0 1/1 Running 0 3m23s my-release-pulsar-zookeeper-metadata-98zbr 0/1 Completed 0 3m24s
    -

    3.将本地端口转发到 Milvus

    运行以下命令获取 Milvus 集群的服务端口。

    +

    3.将本地端口转发给 Milvus

    运行以下命令获取 Milvus 集群的服务端口。

    $ kubectl get pod my-release-milvus-proxy-6bd7f5587-ds2xv --template
     ='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
     19530
    @@ -186,18 +184,18 @@ my-release-pulsar-zookeeper-metadata-98zbr       0/1   Completed  0        3m24s
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    如果您处于网络受限的环境,请按照本节的步骤启动 Milvus 群集。

    +

    如果处于网络受限的环境,请按照本节的步骤启动 Milvus 群集。

    1.获取 Milvus 清单

    运行以下命令获取 Milvus 清单。

    $ helm template my-release milvus/milvus > milvus_manifest.yaml
     
    -

    上述命令将渲染 Milvus 群集的图表模板,并将输出保存到名为milvus_manifest.yaml 的清单文件中。使用该清单,你可以在单独的 pod 中安装 Milvus 群集及其组件和依赖项。

    +

    上述命令会渲染 Milvus 群集的图表模板,并将输出保存到名为milvus_manifest.yaml 的清单文件中。使用此清单,你可以在单独的 pod 中安装 Milvus 群集及其组件和依赖项。

      -
    • 要以独立模式安装 Milvus 实例(所有 Milvus 组件都包含在单个 pod 中),则应运行helm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml ,为独立模式下的 Milvus 实例渲染图表模板。
    • +
    • 要在独立模式下安装 Milvus 实例(所有 Milvus 组件都包含在一个 pod 中),应改成运行helm template my-release --set cluster.enabled=false --set etcd.replicaCount=1 --set minio.mode=standalone --set pulsar.enabled=false milvus/milvus > milvus_manifest.yaml ,为独立模式下的 Milvus 实例渲染图表模板。
    • 要更改 Milvus 配置,请下载 value.yaml模板,将所需设置放入其中,然后使用helm template -f values.yaml my-release milvus/milvus > milvus_manifest.yaml 渲染相应的清单。
    -

    2.下载图像拉取脚本

    图像提取脚本是用 Python 开发的。您应在requirement.txt 文件中下载该脚本及其依赖项。

    +

    2.下载图像提取脚本

    图像提取脚本是用 Python 开发的。您应在requirement.txt 文件中下载脚本及其依赖项。

    $ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/requirements.txt
     $ wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/offline/save_image.py
     
    @@ -211,7 +209,7 @@ $ python3 save_image.py --manifest milvus_manifest.yaml

    5.部署 Milvus

    $ kubectl apply -f milvus_manifest.yaml
     
    -

    到目前为止,您可以按照在线安装的步骤23检查群集状态,并将本地端口转发给 Milvus。

    +

    到此为止,你可以按照在线安装的步骤23检查群集状态,并将本地端口转发给 Milvus。

    升级运行中的 Milvus 群集

    Knowledge TableWhyHow AI 开发,是一个开源软件包,旨在促进从非结构化文档中提取和探索结构化数据。它为用户提供了一个类似电子表格的界面,并能通过自然语言查询界面创建表格和图形等知识表征。该软件包包括可定制的提取规则、格式选项和通过出处进行的数据追踪,使其适用于各种应用。它支持无缝集成到 RAG 工作流中,既满足了需要用户友好界面的企业用户的需求,也满足了需要灵活后端来高效处理文档的开发人员的需求。

    +

    默认情况下,Knowledge Table 使用 Milvus 数据库来存储和检索提取的数据。这样,用户就可以利用 Milvus 的强大功能轻松搜索、过滤和分析数据。在本教程中,我们将介绍如何开始使用 Knowledge Table 和 Milvus。

    +

    前提条件

      +
    • 装载机
    • +
    • Docker Compose
    • +
    +

    克隆项目

    $ git clone https://github.com/whyhow-ai/knowledge-table.git
    +
    +

    设置环境

    你可以在项目根目录下找到.env.example 文件。将该文件复制到.env ,并填写所需的环境变量。

    +

    对于 Milvus,应设置MILVUS_DB_URIMILVUS_DB_TOKEN 环境变量。以下是一些提示:

    +
    +
      +
    • MILVUS_DB_URI 设置为本地文件,如./milvus.db ,是最方便的方法,因为它会自动利用Milvus Lite将所有数据存储在此文件中。
    • +
    • 如果你有大规模数据,比如超过一百万个向量,你可以在Docker 或 Kubernetes 上设置性能更强的 Milvus 服务器。在此设置中,请使用服务器地址和端口作为 uri,例如http://localhost:19530 。如果在 Milvus 上启用了身份验证功能,请使用"<your_username>:<your_password>"作为令牌,否则不要设置令牌。
    • +
    • 如果要使用 Milvus 的全托管云服务Zilliz Cloud,请调整MILVUS_DB_URIMILVUS_DB_TOKEN ,它们与 Zilliz Cloud 中的公共端点和 Api 密钥相对应。
    • +
    +
    +

    除 Milvus 外,您还应设置其他环境,如OPENAI_API_KEY 。您可以从相关网站获取这些信息。

    +

    启动应用程序

    $ docker-compose up -d --build
    +
    +

    停止应用程序

    $ docker-compose down
    +
    +

    访问项目

    前台可从http://localhost:3000 访问,后台可从http://localhost:8000 访问。

    +

    + + + + +

    +

    您可以玩转用户界面,并尝试使用自己的文档。

    +

    如需进一步了解演示用法,请参阅官方知识表文档

    diff --git a/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.json b/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.json new file mode 100644 index 000000000..2ba692143 --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.json @@ -0,0 +1 @@ +{"codeList":["$ pip install mem0ai pymilvus\n","import os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"\n","# Define Config\nfrom mem0 import Memory\n\nconfig = {\n \"vector_store\": {\n \"provider\": \"milvus\",\n \"config\": {\n \"collection_name\": \"quickstart_mem0_with_milvus\",\n \"embedding_model_dims\": \"1536\",\n \"url\": \"./milvus.db\", # Use local vector database for demo purpose\n },\n },\n \"version\": \"v1.1\",\n}\n\nm = Memory.from_config(config)\n","# Add a memory to user: Working on improving tennis skills\nres = m.add(\n messages=\"I am working on improving my tennis skills.\",\n user_id=\"alice\",\n metadata={\"category\": \"hobbies\"},\n)\n\nres\n","# Get memory_id\nmemory_id = res[\"results\"][0][\"id\"]\n\n# Update this memory with new information: Likes to play tennis on weekends\nm.update(memory_id=memory_id, data=\"Likes to play tennis on weekends\")\n","# Get all memory for the user Alice\nm.get_all(user_id=\"alice\")\n","m.history(memory_id=memory_id)\n","new_mem = m.add(\n \"I have a linear algebra midterm exam on November 20\",\n user_id=\"alice\",\n metadata={\"category\": \"task\"},\n)\n","m.get_all(user_id=\"alice\")\n","m.search(query=\"What are Alice's hobbies\", user_id=\"alice\")\n","m.delete(memory_id=memory_id)\n\nm.get_all(\"alice\")\n"],"headingContent":"Getting Started with Mem0 and Milvus","anchorList":[{"label":"开始使用 Mem0 和 Milvus","href":"Getting-Started-with-Mem0-and-Milvus","type":1,"isActive":false},{"label":"准备工作","href":"Preparation","type":2,"isActive":false},{"label":"使用 Mem0 和 Milvus 管理用户记忆库","href":"Managing-User-Memories-with-Mem0-and-Milvus","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.md b/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.md new file mode 100644 index 000000000..c7613dad8 --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/quickstart_mem0_with_milvus.md @@ -0,0 +1,214 @@ +--- +id: quickstart_mem0_with_milvus.md +summary: >- + 在本教程中,我们将介绍基本的 Mem0 内存管理操作--添加、检索、更新、搜索、删除和跟踪内存历史记录--使用 + Milvus,这是一个高性能、开源的向量数据库,可支持高效存储和检索。本实践介绍将指导您完成基础内存操作,帮助您利用 Mem0 和 Milvus + 构建个性化的人工智能交互。 +title: 开始使用 Mem0 和 Milvus +--- +

    开始使用 Mem0 和 Milvus

    +Open In Colab + + +GitHub Repository +

    +

    Mem0是人工智能应用的智能记忆层,旨在通过保留用户偏好和随时间不断调整来提供个性化和高效的交互。作为聊天机器人和人工智能驱动工具的理想选择,Mem0 可创建无缝、上下文感知的体验。

    +

    在本教程中,我们将介绍基本的 Mem0 内存管理操作--使用Milvus 添加、检索、更新、搜索、删除和跟踪内存历史记录--Milvus 是一个高性能、开源的向量数据库,为高效存储和检索提供了动力。本实践介绍将指导您完成基础内存操作,帮助您利用 Mem0 和 Milvus 构建个性化的人工智能交互。

    +

    准备工作

    下载所需程序库

    $ pip install mem0ai pymilvus
    +
    +
    +

    如果您使用的是 Google Colab,要启用刚刚安装的依赖项,可能需要重启运行时(点击屏幕顶部的 "运行时 "菜单,从下拉菜单中选择 "重启会话")。

    +
    +

    用 Milvus 配置 Mem0

    在本例中,我们将使用 OpenAI 作为 LLM。您应将api 密钥 OPENAI_API_KEY 设置为环境变量。

    +
    import os
    +
    +os.environ["OPENAI_API_KEY"] = "sk-***********"
    +
    +

    现在,我们可以将 Mem0 配置为使用 Milvus 作为向量存储库

    +
    # Define Config
    +from mem0 import Memory
    +
    +config = {
    +    "vector_store": {
    +        "provider": "milvus",
    +        "config": {
    +            "collection_name": "quickstart_mem0_with_milvus",
    +            "embedding_model_dims": "1536",
    +            "url": "./milvus.db",  # Use local vector database for demo purpose
    +        },
    +    },
    +    "version": "v1.1",
    +}
    +
    +m = Memory.from_config(config)
    +
    +
    +
    +
      +
    • 如果你只需要一个本地向量数据库,用于小规模数据或原型设计,那么将 uri 设置为本地文件,例如./milvus.db ,是最方便的方法,因为它会自动利用Milvus Lite将所有数据存储在此文件中。
    • +
    • 如果你有大规模数据,比如超过一百万个向量,你可以在Docker 或 Kubernetes 上设置性能更强的 Milvus 服务器。在此设置中,请使用服务器地址和端口作为 uri,例如http://localhost:19530 。如果在 Milvus 上启用了身份验证功能,请使用"<your_username>:<your_password>"作为令牌,否则不要设置令牌。
    • +
    • 如果您使用Zilliz Cloud(Milvus 的全托管云服务),请调整uritoken ,它们与 Zilliz Cloud 中的公共端点和 API 密钥相对应。
    • +
    +
    +
    +

    使用 Mem0 和 Milvus 管理用户记忆库

    添加记忆库

    add 函数将非结构化文本作为内存存储在 Milvus 中,并将其与特定用户和可选元数据关联。

    +

    在这里,我们将爱丽丝的记忆 "努力提高我的网球技术 "连同相关元数据一起添加到 Milvus 中。

    +
    # Add a memory to user: Working on improving tennis skills
    +res = m.add(
    +    messages="I am working on improving my tennis skills.",
    +    user_id="alice",
    +    metadata={"category": "hobbies"},
    +)
    +
    +res
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Working on improving tennis skills',
    +   'event': 'ADD'}],
    + 'relations': []}
    +
    +

    更新记忆

    我们可以使用add 函数的返回值检索内存 ID,这样就可以通过update 用新信息更新内存。

    +
    # Get memory_id
    +memory_id = res["results"][0]["id"]
    +
    +# Update this memory with new information: Likes to play tennis on weekends
    +m.update(memory_id=memory_id, data="Likes to play tennis on weekends")
    +
    +
    {'message': 'Memory updated successfully!'}
    +
    +

    获取用户的所有内存

    我们可以使用get_all 函数查看所有插入的内存,或通过 Milvus 中的user_id 进行筛选。

    +

    请注意,我们可以看到该记忆已从 "努力提高网球技能 "更改为 "喜欢在周末打网球"。

    +
    # Get all memory for the user Alice
    +m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'}]}
    +
    +

    查看记忆更新历史

    我们还可以通过history 函数指定我们感兴趣的内存_id,查看内存更新历史。

    +
    m.history(memory_id=memory_id)
    +
    +
    [{'id': '71ed3cec-5d9a-4fa6-a009-59802450c0b9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': None,
    +  'new_memory': 'Working on improving tennis skills',
    +  'event': 'ADD',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': None},
    + {'id': 'db2b003c-ffb7-42e4-bd8a-b9cf56a02bb9',
    +  'memory_id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +  'old_memory': 'Working on improving tennis skills',
    +  'new_memory': 'Likes to play tennis on weekends',
    +  'event': 'UPDATE',
    +  'created_at': '2024-11-01T19:33:44.116920-07:00',
    +  'updated_at': '2024-11-01T19:33:47.619857-07:00'}]
    +
    +

    搜索内存

    我们可以使用search 函数查找与用户最相关的内存。

    +

    让我们从为 Alice 添加另一个内存开始。

    +
    new_mem = m.add(
    +    "I have a linear algebra midterm exam on November 20",
    +    user_id="alice",
    +    metadata={"category": "task"},
    +)
    +
    +

    现在,我们调用get_all ,指定 user_id,以验证我们确实有 2 个用户 Alice 的内存条目。

    +
    m.get_all(user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    现在我们可以通过提供queryuser_id 来执行search 。请注意,我们默认使用L2 指标进行相似性搜索,因此score 越小表示相似性越高。

    +
    m.search(query="What are Alice's hobbies", user_id="alice")
    +
    +
    {'results': [{'id': '77162018-663b-4dfa-88b1-4f029d6136ab',
    +   'memory': 'Likes to play tennis on weekends',
    +   'hash': '4c3bc9f87b78418f19df6407bc86e006',
    +   'metadata': None,
    +   'score': 1.2807445526123047,
    +   'created_at': '2024-11-01T19:33:44.116920-07:00',
    +   'updated_at': '2024-11-01T19:33:47.619857-07:00',
    +   'user_id': 'alice'},
    +  {'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'score': 1.728922724723816,
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    +

    删除内存

    我们还可以通过提供相应的memory_iddelete 内存。

    +

    我们将删除内存 "喜欢在周末打网球",因为它的memory_id 已被检索,并调用get_all 验证删除是否成功。

    +
    m.delete(memory_id=memory_id)
    +
    +m.get_all("alice")
    +
    +
    {'results': [{'id': 'aa8eaa38-74d6-4b58-8207-b881d6d93d02',
    +   'memory': 'Has a linear algebra midterm exam on November 20',
    +   'hash': '575182f46965111ca0a8279c44920ea2',
    +   'metadata': {'category': 'task'},
    +   'created_at': '2024-11-01T19:33:57.271657-07:00',
    +   'updated_at': None,
    +   'user_id': 'alice'}]}
    +
    diff --git a/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.json b/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.json new file mode 100644 index 000000000..d72be426f --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/arc53/DocsGPT.git\n$ cd DocsGPT\n","$ echo \"\\nlangchain-milvus==0.1.6\" >> ./application/requirements.txt\n"," backend:\n build: ./application\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n"," worker:\n build: ./application\n command: celery -A application.app.celery worker -l INFO -B\n environment:\n - VECTOR_STORE=milvus\n - MILVUS_URI=...\n - MILVUS_TOKEN=...\n","$ docker-compose down\n"],"headingContent":"Use Milvus in DocsGPT","anchorList":[{"label":"在 DocsGPT 中使用 Milvus","href":"Use-Milvus-in-DocsGPT","type":1,"isActive":false},{"label":"安装要求","href":"Requirements","type":2,"isActive":false},{"label":"克隆版本库","href":"Clone-the-repository","type":2,"isActive":false},{"label":"添加依赖关系","href":"Add-dependency","type":2,"isActive":false},{"label":"设置环境变量","href":"Set-environment-variables","type":2,"isActive":false},{"label":"启动服务","href":"Start-the-services","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.md b/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.md new file mode 100644 index 000000000..1664494e4 --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/use_milvus_in_docsgpt.md @@ -0,0 +1,140 @@ +--- +id: use_milvus_in_docsgpt.md +summary: 在本教程中,我们将向您展示如何使用 Milvus 作为 DocsGPT 的后台向量数据库。 +title: 在 DocsGPT 中使用 Milvus +--- +

    在 DocsGPT 中使用 Milvus

    DocsGPT是一种先进的开源解决方案,通过集成强大的 GPT 模型,简化了项目文档中信息的查找。它能让开发人员轻松获得有关项目问题的准确答案,消除耗时的手动搜索。

    +

    在本教程中,我们将向你展示如何使用 Milvus 作为 DocsGPT 的后台向量数据库。

    +
    +

    本教程主要参考DocsGPT官方安装指南。如果你发现本教程有过时的部分,可以优先参考官方指南,并向我们提出问题。

    +
    +

    安装要求

    确保已安装Docker

    +

    克隆版本库

    克隆版本库并导航到它:

    +
    $ git clone https://github.com/arc53/DocsGPT.git
    +$ cd DocsGPT
    +
    +

    添加依赖关系

    application 文件夹下的requirements.txt 文件中添加langchain-milvus 依赖关系:

    +
    $ echo "\nlangchain-milvus==0.1.6" >> ./application/requirements.txt
    +
    +

    设置环境变量

    VECTOR_STORE=milvus,MILVUS_URI=...,MILVUS_TOKEN=... 添加到docker-compose.yaml 文件中backendworker 服务的环境变量中,就像这样:

    +
      backend:
    +    build: ./application
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +
      worker:
    +    build: ./application
    +    command: celery -A application.app.celery worker -l INFO -B
    +    environment:
    +      - VECTOR_STORE=milvus
    +      - MILVUS_URI=...
    +      - MILVUS_TOKEN=...
    +
    +

    对于MILVUS_URIMILVUS_TOKEN ,您既可以使用完全托管的Zilliz Cloud(Recommended) 服务,也可以手动启动 Milvus 服务。

    +
      +
    • 对于完全托管的 Zilliz 云服务:我们推荐使用 Zilliz Cloud 服务。您可以在Zilliz Cloud 上注册一个免费试用账户。之后,您将获得MILVUS_URIMILVUS_TOKEN ,它们与公共端点和 API 密钥相对应。

    • +
    • 用于手动启动 Milvus 服务:如果要设置 Milvus 服务,可以按照Milvus 官方文档设置 Milvus 服务器,然后从服务器获取MILVUS_URIMILVUS_TOKENMILVUS_URIMILVUS_TOKEN 的格式应分别为http://<your_server_ip>:19530<your_username>:<your_password>

    • +
    +

    启动服务

    运行:./setup.sh

    +

    然后导航至 http://localhost:5173/。

    +

    您可以在用户界面上进行操作,并提出有关文件的问题。

    +

    + + alt text + alt文本

    +

    如果要停止服务,运行:

    +
    $ docker-compose down
    +
    +

    有关详细信息和更高级的设置,请参阅DocsGPT官方文档。

    diff --git a/localization/v2.4.x/site/zh/integrations/use_milvus_in_private_gpt.md b/localization/v2.4.x/site/zh/integrations/use_milvus_in_private_gpt.md index 672d69d2a..9dc970d08 100644 --- a/localization/v2.4.x/site/zh/integrations/use_milvus_in_private_gpt.md +++ b/localization/v2.4.x/site/zh/integrations/use_milvus_in_private_gpt.md @@ -18,7 +18,7 @@ title: 在 PrivateGPT 中使用 Milvus d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    PrivateGPT是一个可投入生产的人工智能项目,它能让用户在没有互联网连接的情况下,使用大型语言模型对其文档提出问题,同时确保 100% 的隐私。PrivateGPT 提供的应用程序接口分为高级和低级区块。它还提供了一个 Gradio UI 客户端以及批量模型下载脚本和摄取脚本等实用工具。从概念上讲,PrivateGPT 封装了 RAG 管道并公开了其基元,可随时使用并提供 API 和 RAG 管道的完整实现。

    +

    PrivateGPT是一个可投入生产的人工智能项目,它能让用户在没有互联网连接的情况下,使用大型语言模型对其文档提出问题,同时确保 100% 的隐私。PrivateGPT 提供的应用程序接口分为高级和低级区块。它还提供了一个 Gradio UI 客户端以及批量模型下载脚本和摄取脚本等实用工具。从概念上讲,PrivateGPT 封装了一个 RAG 管道并公开了其基元,可随时使用并提供 API 和 RAG 管道的完整实现。

    在本教程中,我们将向您展示如何使用 Milvus 作为 PrivateGPT 的后端向量数据库。

    本教程主要参考PrivateGPT官方安装指南。如果您发现本教程有过时的部分,可以优先参考官方指南,并向我们提出问题。

    @@ -38,7 +38,7 @@ title: 在 PrivateGPT 中使用 Milvus d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    1.克隆 PrivateGPT 仓库

    克隆版本库并导航至版本库:

    +

    1.克隆 PrivateGPT 仓库

    克隆版本库并导航到它:

    $ git clone https://github.com/zylon-ai/private-gpt
     $ cd private-gpt
     
    @@ -65,13 +65,15 @@ $ cd private-gpt d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    PrivateGPT 允许自定义设置。我们需要指定一些模块设置。在本教程中,我们将使用以下模块:

    +

    PrivateGPT 允许自定义设置某些模块,例如 LLM、Embeddings、向量存储、用户界面。

    +

    在本教程中,我们将使用以下模块:

    • LLM: Ollama
    • -
    • Embeddings:嵌入:Ollama
    • +
    • Embeddings:Ollama
    • 向量存储:Milvus
    • 用户界面Gradio
    +

    运行以下命令,使用诗歌来安装所需的模块依赖项:

    $ poetry install --extras "llms-ollama embeddings-ollama vector-stores-milvus ui"
     

    启动 Ollama 服务

    访问ollama.ai,按照说明在机器上安装 Ollama。

    安装完成后,确保关闭 Ollama 桌面应用程序。

    -

    现在,启动 Ollama 服务(它将启动本地推理服务器,为 LLM 和 Embeddings 服务):

    +

    现在,启动 Ollama 服务(它将启动本地推理服务器,同时为 LLM 和 Embeddings 服务):

    $ ollama serve
     
    -

    安装要使用的模型,默认settings-ollama.yaml 配置为用户 llama3.1 8b LLM(约 4GB)和 nomic-embed-text Embeddings(约 275MB)

    +

    安装要使用的模型,默认settings-ollama.yaml 配置为用户llama3.1 8b LLM (~4GB) 和nomic-embed-text Embeddings (~275MB)

    默认情况下,PrivateGPT 会根据需要自动提取模型。可以通过修改ollama.autopull_models 属性来改变这种行为。

    无论如何,如果您想手动提取模型,请运行以下命令:

    $ ollama pull llama3.1
    @@ -131,8 +133,8 @@ $ ollama pull nomic-embed-text
     字段 选项说明
     
     
    -uri默认设置为 "local_data/private_gpt/milvus/milvus_local.db",作为本地文件;你也可以在 docker 或 k8s 上设置性能更高的 Milvus 服务器,例如 http://localhost:19530,作为你的 uri;要使用 Zilliz Cloud,请将 uri 和 token 调整为 Zilliz Cloud 中的 Endpoint 和 Api key。
    -令牌与 docker 或 k8s 上的 Milvus 服务器配对,或与 Zilliz Cloud 的 Api 密钥配对。
    +uri默认设置为 "local_data/private_gpt/milvus/milvus_local.db",作为本地文件;你也可以在 docker 或 k8s 上设置性能更高的 Milvus 服务器,例如 http://localhost:19530,作为你的 uri;要使用Zilliz Cloud,请将 uri 和 token 调整为 Zilliz Cloud 中的公共端点和 API 密钥。
    +令牌与 docker 或 k8s 上的 Milvus 服务器配对,或与 Zilliz Cloud 的 API 密钥配对。
     集合名称Collections 的名称,默认设置为 "milvus_db"。
     覆盖覆盖 Collection 中已存在的数据,默认设置为 "true"。
     
    @@ -152,7 +154,7 @@ $ ollama pull nomic-embed-text
               d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
             >
           
    -    

    完成所有设置后,即可通过 gradio UI 运行 PrivateGPT。

    +

    完成所有设置后,即可通过 Gradio UI 运行 PrivateGPT。

    PGPT_PROFILES=ollama make run
     

    用户界面的网址是http://0.0.0.0:8001

    @@ -162,4 +164,5 @@ $ ollama pull nomic-embed-text

    -

    您可以在用户界面上进行操作,并询问有关文档的问题。

    +

    您可以玩转用户界面,并就您的文档提出问题。

    +

    更多详情,请参阅PrivateGPT官方文档。

    diff --git a/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.json b/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.json new file mode 100644 index 000000000..e0f34a07c --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.json @@ -0,0 +1 @@ +{"codeList":["$ git clone https://github.com/sambanova/ai-starter-kit.git\n$ d ai-starter-kit/enterprise_knowledge_retriever\n","...\nvectorstore = self.vectordb.create_vector_store(\n ..., db_type='milvus'\n)\n...\nvectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)\n","python3 -m venv enterprise_knowledge_env\nsource enterprise_knowledge_env/bin/activate\npip install -r requirements.txt\n","$ streamlit run streamlit/app.py --browser.gatherUsageStats false \n"],"headingContent":"Use Milvus with SambaNova","anchorList":[{"label":"将 Milvus 与 SambaNova 结合使用","href":"Use-Milvus-with-SambaNova","type":1,"isActive":false},{"label":"前提条件","href":"Prerequisites","type":2,"isActive":false},{"label":"克隆版本库","href":"Clone-the-repository","type":2,"isActive":false},{"label":"更改向量存储类型","href":"Change-the-vector-store-type","type":2,"isActive":false},{"label":"安装依赖项","href":"Install-dependencies","type":2,"isActive":false},{"label":"启动应用程序","href":"Start-the-application","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.md b/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.md new file mode 100644 index 000000000..edfe95b70 --- /dev/null +++ b/localization/v2.4.x/site/zh/integrations/use_milvus_with_sambanova.md @@ -0,0 +1,133 @@ +--- +id: use_milvus_with_sambanova.md +summary: >- + 本教程利用 SambaNova 人工智能入门套件中的 Milvus 集成,构建了一个类似于 + RAG(检索-增强生成)的企业知识检索系统,用于基于企业私有文档的检索和回答。 +title: 将 Milvus 与 SambaNova 结合使用 +--- +

    将 Milvus 与 SambaNova 结合使用

    SambaNova是一个创新的人工智能技术平台,可加速部署先进的人工智能和深度学习功能。该平台专为企业使用而设计,使企业能够利用生成式人工智能来提高性能和效率。通过提供 SambaNova 套件和 DataScale 等尖端解决方案,该平台使企业能够从数据中提取有价值的见解,推动操作改进,并促进人工智能领域的新机遇。

    +

    SambaNova AI 入门套件是开源资源的 Collections,旨在帮助开发人员和企业利用 SambaNova 部署 AI 驱动的应用程序。这些工具包提供了实用的示例和指南,有助于实施各种人工智能用例,使用户更容易利用 SambaNova 的先进技术。

    +

    本教程利用 SambaNova AI 入门套件中的 Milvus 集成,构建一个类似于 RAG(Retrieval-Augmented Generation)的企业知识检索系统,用于基于企业私有文档的检索和回答。

    +
    +

    本教程主要参考SambaNova AI Starter Kits官方指南。如果您发现本教程有过时的部分,可以优先参考官方指南,并向我们提出问题。

    +
    +

    前提条件

    我们建议使用 Python >= 3.10 和 < 3.12。

    +

    访问SambaNova 云获取 SambaNova API 密钥。

    +

    克隆版本库

    $ git clone https://github.com/sambanova/ai-starter-kit.git
    +$ d ai-starter-kit/enterprise_knowledge_retriever
    +
    +

    更改向量存储类型

    通过在create_vector_store()src/document_retrieval.py 中的load_vdb() 函数中设置db_type='milvus' 来更改向量存储。

    +
    ...
    +vectorstore = self.vectordb.create_vector_store(
    +    ..., db_type='milvus'
    +)
    +...
    +vectorstore = self.vectordb.load_vdb(..., db_type='milvus', ...)
    +
    +

    安装依赖项

    运行以下命令安装所需的依赖项:

    +
    python3 -m venv enterprise_knowledge_env
    +source enterprise_knowledge_env/bin/activate
    +pip install -r requirements.txt
    +
    +

    启动应用程序

    使用以下命令启动应用程序:

    +
    $ streamlit run streamlit/app.py --browser.gatherUsageStats false 
    +
    +

    之后,您将在浏览器中看到用户界面:http://localhost:8501/

    +

    + + + + +

    +

    在用户界面中设置 SambaNova API 密钥后,您就可以使用用户界面并就文档提问。

    +

    更多详情,请参阅SambaNova AI 入门套件的企业知识检索官方文档。

    diff --git a/localization/v2.4.x/site/zh/menuStructure/zh.json b/localization/v2.4.x/site/zh/menuStructure/zh.json index d4685a43f..655c38696 100644 --- a/localization/v2.4.x/site/zh/menuStructure/zh.json +++ b/localization/v2.4.x/site/zh/menuStructure/zh.json @@ -304,12 +304,6 @@ "order": 9, "children": [] }, - { - "label": "用户和角色", - "id": "users_and_roles.md", - "order": 10, - "children": [] - }, { "label": "内存复制", "id": "replica.md", @@ -1057,6 +1051,12 @@ "order": 0, "children": [] }, + { + "label": "用户、权限和角色", + "id": "users_and_roles.md", + "order": 10, + "children": [] + }, { "label": "启用 RBAC", "id": "rbac.md", @@ -1420,6 +1420,18 @@ "order": 7, "children": [] }, + { + "label": "文件GPT", + "id": "use_milvus_in_docsgpt.md", + "order": 9, + "children": [] + }, + { + "label": "桑巴诺瓦", + "id": "use_milvus_with_sambanova.md", + "order": 10, + "children": [] + }, { "label": "PrivateGPT", "id": "use_milvus_in_private_gpt.md", @@ -1444,6 +1456,12 @@ "id": "integrate_with_camel.md", "order": 1, "children": [] + }, + { + "label": "Mem0", + "id": "quickstart_mem0_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1463,6 +1481,12 @@ "id": "integrate_with_vanna.md", "order": 1, "children": [] + }, + { + "label": "知识表", + "id": "knowledge_table_with_milvus.md", + "order": 2, + "children": [] } ] }, @@ -1633,6 +1657,12 @@ "order": 9, "children": [] }, + { + "label": "利用 Matryoshka Embeddings 进行漏斗搜索", + "id": "funnel_search_with_matryoshka.md", + "order": 10, + "children": [] + }, { "label": "探索更多", "id": "explore-more", diff --git a/localization/v2.4.x/site/zh/reference/disk_index.md b/localization/v2.4.x/site/zh/reference/disk_index.md index 3f6252b96..8545720e6 100644 --- a/localization/v2.4.x/site/zh/reference/disk_index.md +++ b/localization/v2.4.x/site/zh/reference/disk_index.md @@ -68,7 +68,7 @@ title: 盘上索引

    要使用 DiskANN,请确保

    • 数据中只使用至少 1 维的浮点矢量。
    • -
    • 仅使用欧氏距离 (L2)、内积 (IP) 或 COSINE 来测量向量间的距离。
    • +
    • 仅使用欧氏距离 (L2)、内积 (IP) 或 COSINE 来测量向量之间的距离。

    索引和搜索设置

    Knowhere 是 Milvus 的核心向量执行引擎,它集成了多个向量相似性搜索库,包括FaissHnswlibAnnoy。Knowhere 还设计用于支持异构计算。它可以控制在哪个硬件(CPU 或 GPU)上执行索引构建和搜索请求。这就是Knowhere名称的由来--知道在哪里执行操作。未来的版本将支持更多类型的硬件,包括 DPU 和 TPU。

    +

    Knowhere 是 Milvus 的核心向量执行引擎,它集成了多个向量相似性搜索库,包括FaissHnswlibAnnoy。Knowhere 的设计还支持异构计算。它可以控制在哪个硬件(CPU 或 GPU)上执行索引构建和搜索请求。这就是Knowhere名字的由来--知道在哪里执行操作符。未来的版本将支持更多类型的硬件,包括 DPU 和 TPU。

    Milvus架构中的Knowhere

    下图显示了 Knowhere 在 Milvus 架构中的位置。

    +

    下图说明了 Knowhere 在 Milvus 架构中的位置。

    Knowhere Knowhere

    -

    最底层是系统硬件。第三方索引库位于硬件之上。然后,Knowhere 通过 CGO 与上层的索引节点和查询节点进行交互,CGO 允许 Go 包调用 C 代码。

    +

    最底层是系统硬件。上面是第三方索引库。在最上层,Knowhere通过CGO与索引节点和查询节点交互,CGO允许Go包调用C代码。

    Knowhere的优势

    以下是 Knowhere 与 Faiss 相比的优势。

    +

    以下是Knowhere与Faiss相比的优势。

    支持比特视图

    Milvus 引入了比特集机制来实现 "软删除"。软删除的向量仍然存在于数据库中,但在向量相似性搜索或查询时不会被计算。

    -

    比特集中的每个比特都对应一个索引向量。如果一个向量在比特集中被标记为 "1",则表示该向量已被软删除,在向量搜索过程中将不会涉及。比特集参数适用于 Knowhere 中所有公开的 Faiss 索引查询 API,包括 CPU 和 GPU 索引。

    +

    比特集中的每个比特都对应一个索引向量。如果某个向量在比特集中被标记为 "1",则表示该向量已被软删除,在向量搜索过程中不会涉及。比特集参数适用于 Knowhere 中所有公开的 Faiss 索引查询 API,包括 CPU 和 GPU 索引。

    有关比特集机制的更多信息,请查看比特集

    支持二进制向量索引的多种相似性度量方法

    Knowhere支持HammingJaccardTanimotoSuperstructureSubstructure。Jaccard和Tanimoto可用于测量两个样本集之间的相似性,而Superstructure和Substructure可用于测量化学结构的相似性。

    支持 AVX512 指令集

    除了Faiss已经支持的AArch64SSE4.2AVX2指令集外,Knowhere还支持AVX512指令集,与AVX2指令集相比,AVX512指令集可将索引构建和查询性能提高20%至30%

    -

    自动选择SIMD指令

    Knowhere支持在任何CPU处理器(包括内部平台和云平台)上自动调用合适的SIMD指令(如SIMD SSE、AVX、AVX2和AVX512),因此用户无需在编译时手动指定SIMD标志(如"-msse4")。

    +

    自动选择SIMD指令

    Knowhere支持在任何CPU处理器(本地部署和云平台)上自动调用合适的SIMD指令(如SIMD SSE、AVX、AVX2和AVX512),因此用户无需在编译时手动指定SIMD标志(如"-msse4")。

    Knowhere 是通过重构 Faiss 的代码库而构建的。依赖于 SIMD 加速的常用函数(如相似性计算)被分解出来。然后为每个函数实现四个版本(即 SSE、AVX、AVX2 和 AVX512),并将每个版本放入单独的源文件中。然后,使用相应的 SIMD 标志对源文件进行单独编译。因此,在运行时,Knowhere 可以根据当前的 CPU 标志自动选择最合适的 SIMD 指令,然后使用挂钩功能链接正确的函数指针。

    -

    其他性能优化

    阅读《Milvus: A Purpose-Built Vector Data Management System》,了解有关 Knowhere 性能优化的更多信息。

    +

    其他性能优化措施

    阅读《Milvus: A Purpose-Built Vector Data Management System》,了解有关 Knowhere 性能优化的更多信息。

    Knowhere 代码结构

    Milvus 中的计算主要涉及向量和标量操作。Knowhere 只处理向量索引的操作。

    -

    索引是一种独立于原始向量数据的数据结构。一般来说,建立索引需要四个步骤:创建索引、训练数据、插入数据和建立索引。在一些人工智能应用中,数据集训练与向量搜索是分离的。先对数据集的数据进行训练,然后插入 Milvus 等向量数据库进行相似性搜索。例如,开放数据集 sift1M 和 sift1B 区分了用于训练的数据和用于测试的数据。

    +

    Milvus 中的计算主要涉及向量和标量操作。Knowhere 只处理向量索引的操作符。

    +

    索引是一种独立于原始向量数据的数据结构。一般来说,建立索引需要四个步骤:创建索引、训练数据、插入数据和建立索引。在一些人工智能应用中,数据集训练与向量搜索是分离的。先对数据集的数据进行训练,然后插入到 Milvus 等向量数据库中进行相似性搜索。例如,开放数据集 sift1M 和 sift1B 区分了用于训练的数据和用于测试的数据。

    然而,在 Knowhere 中,用于训练的数据和用于搜索的数据是相同的。Knowhere 会对一个数据中的所有数据进行训练,然后插入所有训练过的数据并为它们建立索引。

    DataObj基类

    DataObj 是 Knowhere 中所有数据结构的基类。 是 中唯一的虚拟方法。Index 类继承自 ,其字段名为 "size_"。Index 类还有两个虚拟方法-- 和 。从 派生的 类是所有向量索引的虚拟基类。 提供的方法包括 , , , 和 。Size() DataObj DataObj Serialize() Load() Index VecIndex VecIndex Train() Query() GetStatistics() ClearStatistics()

    @@ -116,19 +115,19 @@ title: Knowhere IDMAP

    从技术上讲,IDMAP 不是索引,而是用于暴力搜索。向量插入数据库时,既不需要数据训练,也不需要建立索引。搜索将直接在插入的向量数据上进行。

    不过,为了保持代码的一致性,IDMAP 也继承自VecIndex 类及其所有虚拟接口。IDMAP 的用法与其他索引相同。

    -

    IVF 索引

    +

    IVF 索引

    IVF IVF

    -

    IVF(倒置文件)索引是最常用的索引。IVF 类派生自VecIndexFaissBaseIndex ,并进一步扩展到IVFSQIVFPQGPUIVF 派生自GPUIndexIVF 。然后GPUIVF 进一步扩展到GPUIVFSQGPUIVFPQ

    +

    IVF(倒置文件)索引是最常用的索引。IVF 类衍生自VecIndexFaissBaseIndex ,并进一步扩展到IVFSQIVFPQGPUIVF 衍生自GPUIndexIVF 。然后,GPUIVF 进一步扩展到GPUIVFSQGPUIVFPQ

    IVFSQHybrid 是一个自主开发的混合索引。粗量化器在 GPU 上执行,而桶中的搜索则在 CPU 上进行。 的召回率与 相同,但性能更好。IVFSQHybrid GPUIVFSQ

    -

    二进制索引的基类结构相对更简单。BinaryIDMAPBinaryIVF 源自FaissBaseBinaryIndexVecIndex

    -

    第三方索引

    +

    二进制索引的基类结构相对简单。BinaryIDMAPBinaryIVFFaissBaseBinaryIndexVecIndex 派生而来。

    +

    第三方索引

    - third-party indexes - 第三方索引

    -

    目前,除了 Faiss 之外,只支持两种第三方索引:基于树的索引Annoy 和基于图的索引HNSW 。这两种常用的第三方索引均源自VecIndex

    -

    向Knowhere添加索引

    如果想在Knowhere中添加新的索引,首先可以参考现有的索引:

      -
    • 要添加基于量化的索引,请参考IVF_FLAT

    • -
    • 要添加基于图形的索引,请参考HNSW

    • +
    • 要添加基于量化的指数,请参考IVF_FLAT

    • +
    • 要添加基于图的索引,请参考HNSW

    • 要添加基于树的索引,请参阅Annoy

    参考现有索引后,可以按照以下步骤向Knowhere添加新索引。

    @@ -174,7 +173,7 @@ title: Knowhere

    在了解了 Knowhere 如何在 Milvus 中运行之后,你可能还想

    diff --git a/localization/v2.4.x/site/zh/reference/schema.json b/localization/v2.4.x/site/zh/reference/schema.json index 890aabd57..942f64b37 100644 --- a/localization/v2.4.x/site/zh/reference/schema.json +++ b/localization/v2.4.x/site/zh/reference/schema.json @@ -1 +1 @@ -{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"管理模式","href":"Manage-Schema","type":1,"isActive":false},{"label":"字段模式","href":"Field-schema","type":2,"isActive":false},{"label":"Collections 模式","href":"Collection-schema","type":2,"isActive":false},{"label":"下一步","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import FieldSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# The following creates a field and use it as the partition key\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n","from pymilvus import FieldSchema\n\nfields = [\n FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True),\n # configure default value `25` for field `age`\n FieldSchema(name=\"age\", dtype=DataType.INT64, default_value=25, description=\"age\"),\n embedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n]\n","from pymilvus import FieldSchema, CollectionSchema\nid_field = FieldSchema(name=\"id\", dtype=DataType.INT64, is_primary=True, description=\"primary id\")\nage_field = FieldSchema(name=\"age\", dtype=DataType.INT64, description=\"age\")\nembedding_field = FieldSchema(name=\"embedding\", dtype=DataType.FLOAT_VECTOR, dim=128, description=\"vector\")\n\n# Enable partition key on a field if you need to implement multi-tenancy based on the partition-key field\nposition_field = FieldSchema(name=\"position\", dtype=DataType.VARCHAR, max_length=256, is_partition_key=True)\n\n# Set enable_dynamic_field to True if you need to use dynamic fields. \nschema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description=\"desc of a collection\")\n","from pymilvus import Collection,connections\nconn = connections.connect(host=\"127.0.0.1\", port=19530)\ncollection_name1 = \"tutorial_1\"\ncollection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)\n","import pandas as pd\ndf = pd.DataFrame({\n \"id\": [i for i in range(nb)],\n \"age\": [random.randint(20, 40) for i in range(nb)],\n \"embedding\": [[random.random() for _ in range(dim)] for _ in range(nb)],\n \"position\": \"test_pos\"\n})\n\ncollection, ins_res = Collection.construct_from_dataframe(\n 'my_collection',\n df,\n primary_field='id',\n auto_id=False\n )\n"],"headingContent":"Manage Schema","anchorList":[{"label":"管理模式","href":"Manage-Schema","type":1,"isActive":false},{"label":"字段模式","href":"Field-schema","type":2,"isActive":false},{"label":"Collections 模式","href":"Collection-schema","type":2,"isActive":false},{"label":"下一步","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/reference/schema.md b/localization/v2.4.x/site/zh/reference/schema.md index 7a42c0f90..1d02e1664 100644 --- a/localization/v2.4.x/site/zh/reference/schema.md +++ b/localization/v2.4.x/site/zh/reference/schema.md @@ -39,7 +39,10 @@ title: 管理模式

    字段模式属性

    - + + + + @@ -130,7 +133,7 @@ fields = [
  • BINARY_VECTOR:将二进制数据存储为 0 和 1 的序列,用于图像处理和信息检索中的紧凑特征表示。
  • FLOAT_VECTOR:存储 32 位浮点数,常用于科学计算和机器学习中的实数表示。
  • FLOAT16_VECTOR:存储 16 位半精度浮点数,用于深度学习和 GPU 计算,以提高内存和带宽效率。
  • -
  • BFLOAT16_VECTOR:存储精度降低但指数范围与 Float32 相同的 16 位浮点数,常用于深度学习,可在不明显影响精度的情况下降低内存和计算要求。
  • +
  • BFLOAT16_VECTOR:存储精度降低但指数范围与 Float32 相同的 16 位浮点数,在深度学习中很受欢迎,可在不明显影响精度的情况下降低内存和计算要求。
  • SPARSE_FLOAT_VECTOR:存储非零元素及其相应索引的列表,用于表示稀疏向量。更多信息,请参阅稀疏向量
  • Milvus 支持在一个 Collections 中使用多个向量场。更多信息,请参阅混合搜索

    @@ -154,17 +157,20 @@ fields = [

    集合模式属性

    属性说明 备注
    属性说明说明
    - + + + + - + - + @@ -193,7 +199,8 @@ position_field = FieldSchema(name="position" schema = CollectionSchema(fields=[id_field, age_field, embedding_field], auto_id=False, enable_dynamic_field=True, description="desc of a collection")

    使用指定的 Schema 创建 Collections:

    -
    from pymilvus import Collection
    +
    from pymilvus import Collection,connections
    +conn = connections.connect(host="127.0.0.1", port=19530)
     collection_name1 = "tutorial_1"
     collection1 = Collection(name=collection_name1, schema=schema, using='default', shards_num=2)
     
    diff --git a/localization/v2.4.x/site/zh/reference/users_and_roles.json b/localization/v2.4.x/site/zh/reference/users_and_roles.json index 6fc89ff8d..8d9fc5d68 100644 --- a/localization/v2.4.x/site/zh/reference/users_and_roles.json +++ b/localization/v2.4.x/site/zh/reference/users_and_roles.json @@ -1 +1 @@ -{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"","anchorList":[{"label":"用户和角色","href":"Users-and-Roles","type":1,"isActive":false},{"label":"关键概念","href":"Key-concepts","type":2,"isActive":false},{"label":"举例说明:授予权限","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"默认用户和角色","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"对象类型和权限列表","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"下一步","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["milvusClient.grant_privilege(\n role_name=\"CUSTOM_ROLE_NAME\",\n object_type=\"Collection\", # Valid value: Global, Collection or User.\n privilege=\"CreateIndex\", # See the table below for valid privilege names and relevant API descriptions.\n object_name=\"YOUR_COLLECTION_NAME\" # The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n)\n","GrantPrivilegeReq grantPrivilegeReq = GrantPrivilegeReq.builder()\n .roleName(\"roleName\")\n .objectName(\"CollectionName\") // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n .objectType(\"Collection\") // Valid value: Global, Collection or User.\n .privilege(\"CreateIndex\") // See the table below for valid privilege names and relevant API descriptions.\n .build();\nclient.grantPrivilege(grantPrivilegeReq);\n","milvusClient.grantPrivilege({\n roleName: 'roleName',\n object: 'Collection', // Valid value: Global, Collection or User.\n objectName: 'CollectionName', // The name of the collection to grant access to. Use \"*\" to grant access to all collections.\n privilegeName: 'CreateIndex' // See the table below for valid privilege names and relevant API descriptions.\n })\n"],"headingContent":"Users, Privileges, and Roles","anchorList":[{"label":"用户、权限和角色","href":"Users-Privileges-and-Roles","type":1,"isActive":false},{"label":"关键概念","href":"Key-concepts","type":2,"isActive":false},{"label":"举例说明:授予权限","href":"Example-Granting-privileges","type":2,"isActive":false},{"label":"默认用户和角色","href":"Default-users-and-roles","type":2,"isActive":false},{"label":"对象类型和权限列表","href":"List-of-object-types-and-privileges","type":2,"isActive":false},{"label":"下一步","href":"Whats-next","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/reference/users_and_roles.md b/localization/v2.4.x/site/zh/reference/users_and_roles.md index f1ffc8b79..7a08d2ee9 100644 --- a/localization/v2.4.x/site/zh/reference/users_and_roles.md +++ b/localization/v2.4.x/site/zh/reference/users_and_roles.md @@ -2,9 +2,9 @@ id: users_and_roles.md related_key: 'users, roles' summary: 了解基于角色的访问控制(RBAC)中用户、角色、对象和权限的定义。 -title: 用户和角色 +title: 用户、权限和角色 --- -

    用户和角色

    本主题概述 Milvus 中基于角色的访问控制(RBAC),详细说明用户、角色、对象和权限之间的定义和关系。

    +

    本主题概述了 Milvus 中基于角色的访问控制(RBAC),详细介绍了用户、角色、对象和权限之间的定义和关系。

    下图说明了对象、权限、角色和用户之间的关系。

    @@ -40,21 +40,21 @@ title: 用户和角色 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    要管理 Milvus 资源的访问控制,必须了解 RBAC 的关键组成部分:对象类型、对象名称、用户、角色和权限。

    +

    要管理对 Milvus 资源的访问控制,必须了解 RBAC 的关键组成部分:对象类型、对象名称、用户、角色和权限。

      -
    • 对象类型:分配权限的对象类别。对象类型可以是

      +
    • 对象类型:分配权限的对象类别。对象类型可以是

        -
      • Global:全系统对象,允许用户执行影响所有集合、用户或全系统设置的操作。
      • -
      • Collection:特定集合对象:允许用户在特定集合内执行创建索引、加载数据、插入或删除数据以及查询数据等操作。
      • +
      • Global:全系统对象,允许用户执行影响所有 Collections、用户或全系统设置的操作。
      • +
      • Collection:特定于 Collections 的对象,允许用户执行创建索引、加载数据、插入或删除数据以及查询特定 Collections 中的数据等操作。
      • User:与用户管理相关的对象,允许用户管理数据库用户的凭证和角色,如更新用户凭证或查看用户详细信息。
    • 对象名称:要控制访问的对象的具体名称。例如

      • 如果对象类型为Global ,则必须将对象名称设置为通配符 (*),表示指定类型的所有对象。
      • -
      • 如果对象类型是Collection ,对象名称就是一个集合的名称。
      • +
      • 如果对象类型是Collection ,对象名称就是一个 Collection 的名称。
      • 如果对象类型为User ,对象名称就是数据库用户的名称。
    • -
    • 用户:与 Milvus 交互的个人或应用程序,由用户名和相应密码组成。

    • +
    • 用户:与 Milvus 交互的人或应用程序,由用户名和相应的密码组成。

    • 权限:定义可执行的操作和可访问的资源。权限不直接授予用户,而是分配给角色。

    • 角色:定义用户对某些对象所拥有的一系列权限。角色一旦与用户绑定,用户就会继承授予该角色的所有权限。

    @@ -73,7 +73,7 @@ title: 用户和角色 d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    下面的代码片段展示了如何在特定集合上向角色授予CreateIndex 权限:

    +

    下面的代码片段展示了如何在特定 Collections 上向角色授予CreateIndex 权限:

    milvusClient.grant_privilege(
    @@ -150,29 +150,29 @@ client.grantPrivilege(grantPrivilegeReq);
     
    - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -202,8 +202,8 @@ client.grantPrivilege(grantPrivilegeReq);
    属性说明 备注
    属性说明说明
    field要创建的集合中的字段要创建的 Collection 中的字段 必填
    descriptionCollections 的描述Collection 的描述 数据类型:
    可选
    对象类型权限名称客户端相关 API 说明
    收藏创建索引创建索引
    集合下拉索引下拉索引
    集合索引详情DescribeIndex/GetIndexState/GetIndexBuildProgress
    采集加载载入集合/获取载入进度/获取载入状态
    收集获取加载进度获取加载进度
    集合获取加载状态获取加载状态
    采集释放释放集合
    收藏插入插入
    收藏删除删除
    收藏插入插入
    收藏搜索搜索
    收藏冲洗冲洗/获取冲洗状态
    收藏获取冲洗状态获取冲洗状态
    集合查询查询
    采集获取统计信息获取收藏统计信息
    采集压缩压缩
    采集导入批量输入/导入
    收集负载平衡负载平衡
    集合创建分区创建分区
    数据集删除分区删除分区
    收藏显示分区显示分区
    集合具有分区有分区
    全局全局该表中的所有 API 操作权限
    Collections创建索引创建索引
    Collections下拉索引下拉索引
    Collections索引详情DescribeIndex/GetIndexState/GetIndexBuildProgress
    Collections加载载入集合/获取载入进度/获取载入状态
    Collections获取加载进度获取加载进度
    Collections获取加载状态获取加载状态
    Collections释放释放集合
    Collection插入插入
    Collections删除删除
    Collections插入插入
    Collections搜索搜索
    Collections冲洗冲洗/获取冲洗状态
    Collections获取冲洗状态获取冲洗状态
    Collections查询查询
    Collections获取统计信息获取收藏统计信息
    Collections压缩压缩
    Collections导入批量输入/导入
    Collections负载平衡负载平衡
    Collections创建分区创建分区
    Collections删除分区删除分区
    Collections显示分区显示分区
    Collections具有分区有分区
    全局全局该表中的所有 API 操作符权限
    全局创建数据集创建集合
    全局删除收藏下拉菜单
    全局描述收藏集描述集合
  • 对象和权限名称区分大小写。
  • -
  • 要向某类对象(如集合、全局、用户)授予所有权限,请在权限名称中使用 "*"。
  • -
  • 全局对象的权限名称 "*"不包括所有权限,因为所有权限包括所有权限,包括任何集合和用户对象。
  • +
  • 要向某类对象(如 Collections、Global、User)授予所有权限,请使用 "*"作为权限名称。
  • +
  • 全局对象的权限名称 "*"不包括 All 权限,因为 All 权限包括所有权限,包括任何 Collections 和用户对象。
  • 下一步

    在构建高效的向量搜索系统时,一个关键的挑战是管理存储成本,同时保持可接受的延迟和召回率。现代 Embeddings 模型输出的向量有成百上千个维度,这给原始向量和索引带来了巨大的存储和计算开销。

    +

    传统方法是在建立索引前应用量化或降维方法来降低存储需求。例如,我们可以使用乘积量化(PQ)降低精度,或使用主成分分析(PCA)降低维数,从而节省存储空间。这些方法会对整个向量集进行分析,以找到一个能保持向量间语义关系的更紧凑的向量集。

    +

    这些标准方法虽然有效,但只能在单一尺度上降低一次精度或维度。但是,如果我们能同时保持多层细节,就像一个精确度越来越高的表征金字塔呢?

    +

    这就是 Matryoshka Embeddings。这些巧妙的构造以俄罗斯嵌套娃娃命名(见插图),将多级表示嵌入到单个向量中。与传统的后处理方法不同,Matryoshka 嵌入在初始训练过程中就能学习这种多尺度结构。结果非常显著:不仅完整的 Embeddings 能够捕捉输入语义,而且每个嵌套的子集前缀(前半部分、前四分之一等)都提供了一个连贯的、即使不那么详细的表示。

    +
    +

    在本笔记本中,我们将研究如何将 Matryoshka 嵌入与 Milvus 一起用于语义搜索。我们展示了一种名为 "漏斗搜索 "的算法,它允许我们在嵌入维度的一小部分子集上执行相似性搜索,而不会导致召回率急剧下降。

    +
    import functools
    +
    +from datasets import load_dataset
    +import numpy as np
    +import pandas as pd
    +import pymilvus
    +from pymilvus import MilvusClient
    +from pymilvus import FieldSchema, CollectionSchema, DataType
    +from sentence_transformers import SentenceTransformer
    +import torch
    +import torch.nn.functional as F
    +from tqdm import tqdm
    +
    +

    加载 Matryoshka 嵌入模型

    我们不使用标准的嵌入模型,如 sentence-transformers/all-MiniLM-L12-v2等标准嵌入模型,我们使用了Nomic专门为生成 Matryoshka 嵌入而训练的模型

    +
    model = SentenceTransformer(
    +    # Remove 'device='mps' if running on non-Mac device
    +    "nomic-ai/nomic-embed-text-v1.5",
    +    trust_remote_code=True,
    +    device="mps",
    +)
    +
    +
    <All keys matched successfully>
    +
    +

    加载数据集、嵌入项目和构建向量数据库

    以下代码是对文档页面"使用句子变形器和 Milvus 进行电影搜索 "中的代码的修改首先,我们从 HuggingFace 加载数据集。它包含约 35k 个条目,每个条目对应一部有维基百科文章的电影。我们将在本例中使用TitlePlotSummary 字段。

    +
    ds = load_dataset("vishnupriyavr/wiki-movie-plots-with-summaries", split="train")
    +print(ds)
    +
    +
    Dataset({
    +    features: ['Release Year', 'Title', 'Origin/Ethnicity', 'Director', 'Cast', 'Genre', 'Wiki Page', 'Plot', 'PlotSummary'],
    +    num_rows: 34886
    +})
    +
    +

    接下来,我们连接到 Milvus Lite 数据库,指定数据 Schema,并用此 Schema 创建一个 Collections。我们将在不同字段中存储非规范化嵌入和嵌入的前六分之一。这样做的原因是,我们需要前 1/6 的 Matryoshka 嵌入来执行相似性搜索,而其余 5/6 的嵌入则用于重新排序和改进搜索结果。

    +
    embedding_dim = 768
    +search_dim = 128
    +collection_name = "movie_embeddings"
    +
    +client = MilvusClient(uri="./wiki-movie-plots-matryoshka.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    # First sixth of unnormalized embedding vector
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    # Entire unnormalized embedding vector
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +

    Milvus 目前不支持对嵌入式子集进行搜索,因此我们将嵌入式分成两部分:头部代表要索引和搜索的向量的初始子集,尾部是剩余部分。该模型是为余弦距离相似性搜索而训练的,因此我们对头部嵌入进行了归一化处理。不过,为了以后计算更大子集的相似性,我们需要存储头部嵌入的规范,因此可以在连接到尾部之前对其进行非规范化处理。

    +

    为了通过前 1/6 的嵌入执行搜索,我们需要在head_embedding 字段上创建一个向量搜索索引。稍后,我们将比较 "漏斗搜索 "和常规向量搜索的结果,因此也要在全嵌入上建立一个搜索索引。

    +

    重要的是,我们使用的是COSINE 而不是IP 距离度量,因为否则我们就需要跟踪嵌入规范,这将使实现过程变得复杂(一旦介绍了漏斗搜索算法,这一点将更有意义)。

    +
    index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +index_params.add_index(field_name="embedding", index_type="FLAT", metric_type="COSINE")
    +client.create_index(collection_name, index_params)
    +
    +

    最后,我们对所有 35k 部电影的情节摘要进行编码,并将相应的 Embeddings 输入数据库。

    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    # This particular model requires us to prefix 'search_document:' to stored entities
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Output of embedding model is unnormalized
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:57<00:00,  5.18s/it]
    +
    +

    现在,让我们使用 Matryoshka 嵌入维数的前 1/6 来执行 "漏斗搜索"。我有三部要检索的电影,并制作了自己的情节摘要用于查询数据库。我们嵌入查询,然后在head_embedding 字段上执行向量搜索,检索出 128 个结果候选。

    +
    queries = [
    +    "An archaeologist searches for ancient artifacts while fighting Nazis.",
    +    "A teenager fakes illness to get off school and have adventures with two friends.",
    +    "A young couple with a kid look after a hotel during winter and the husband goes insane.",
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +# This particular model requires us to prefix 'search_query:' to queries
    +instruct_queries = ["search_query: " + q.strip() for q in queries]
    +search_data = embed_search(instruct_queries)
    +
    +# Normalize head embeddings
    +head_search = [x[:search_dim] for x in search_data]
    +
    +# Perform standard vector search on first sixth of embedding dimensions
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +

    此时,我们已经在更小的向量空间上执行了搜索,因此相对于在完整空间上的搜索,可能会降低延迟并减少对索引的存储要求。让我们来看看每个查询的前 5 个匹配结果:

    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits][:5]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +The Passage
    +Counterblast
    +Dominion: Prequel to the Exorcist
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +How to Deal
    +Shorts
    +Blackbird
    +Valentine
    +Unfriended
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +Ghostkeeper
    +Our Vines Have Tender Grapes
    +The Ref
    +Impact
    +The House in Marsh Road
    +
    +

    我们可以看到,由于在搜索过程中截断了 Embeddings,因此召回率受到了影响。漏斗搜索通过一个巧妙的技巧解决了这一问题:我们可以利用剩余的嵌入维度对候选列表进行重新排序和修剪,从而恢复检索性能,而无需运行任何额外的昂贵向量搜索。

    +

    为了便于阐述漏斗搜索算法,我们将每个查询的 Milvus 搜索命中率转换为 Pandas 数据帧。

    +
    def hits_to_dataframe(hits: pymilvus.client.abstract.Hits) -> pd.DataFrame:
    +    """
    +    Convert a Milvus search result to a Pandas dataframe. This function is specific to our data schema.
    +
    +    """
    +    rows = [x["entity"] for x in hits]
    +    rows_dict = [
    +        {"title": x["title"], "embedding": torch.tensor(x["embedding"])} for x in rows
    +    ]
    +    return pd.DataFrame.from_records(rows_dict)
    +
    +
    +dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +

    现在,为了执行漏斗搜索,我们对嵌入的越来越大的子集进行迭代。在每次迭代中,我们都会根据新的相似度对候选项进行重新排序,并删除部分排序最低的候选项。

    +

    具体来说,在上一步中,我们使用 1/6 的嵌入维度和查询维度检索到 128 个候选项。执行漏斗搜索的第一步是使用前 1/3 维度重新计算查询和候选项之间的相似度。我们会剪切掉最下面的 64 个候选项。然后,我们使用前 2/3 个维度重复这一过程,然后使用所有维度,依次剪切到 32 个和 16 个候选维度

    +
    # An optimized implementation would vectorize the calculation of similarity scores across rows (using a matrix)
    +def calculate_score(row, query_emb=None, dims=768):
    +    emb = F.normalize(row["embedding"][:dims], dim=-1)
    +    return (emb @ query_emb).item()
    +
    +
    +# You could also add a top-K parameter as a termination condition
    +def funnel_search(
    +    df: pd.DataFrame, query_emb, scales=[256, 512, 768], prune_ratio=0.5
    +) -> pd.DataFrame:
    +    # Loop over increasing prefixes of the embeddings
    +    for dims in scales:
    +        # Query vector must be normalized for each new dimensionality
    +        emb = torch.tensor(query_emb[:dims] / np.linalg.norm(query_emb[:dims]))
    +
    +        # Score
    +        scores = df.apply(
    +            functools.partial(calculate_score, query_emb=emb, dims=dims), axis=1
    +        )
    +        df["scores"] = scores
    +
    +        # Re-rank
    +        df = df.sort_values(by="scores", ascending=False)
    +
    +        # Prune (in our case, remove half of candidates at each step)
    +        df = df.head(int(prune_ratio * len(df)))
    +
    +    return df
    +
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, search_data)
    +]
    +
    +
    for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:5]["title"], "\n")
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    + 0           "Pimpernel" Smith
    +1               Black Hunters
    +29    Raiders of the Lost Ark
    +34             The Master Key
    +51            My Gun Is Quick
    +Name: title, dtype: object 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    + 21               How I Live Now
    +32     On the Edge of Innocence
    +77             Bratz: The Movie
    +4                    Unfriended
    +108                  Simon Says
    +Name: title, dtype: object 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    + 9         The Shining
    +0         Ghostkeeper
    +11     Fast and Loose
    +7      Killing Ground
    +12         Home Alone
    +Name: title, dtype: object 
    +
    +

    我们已经能够在不执行任何额外向量搜索的情况下恢复召回率!从质量上看,这些结果对 "夺宝奇兵 "和 "闪灵 "召回率似乎高于教程 "使用 Milvus 和 Sentence Transformers 进行电影搜索"中的标准向量搜索,后者使用了不同的嵌入模型。然而,它却无法找到我们将在本手册稍后讨论的 "Ferris Bueller's Day Off"(《Ferris Bueller's Day Off》)。(有关更多定量实验和基准测试,请参阅论文Matryoshka Representation Learning)。

    +

    让我们来比较一下我们的漏斗搜索和标准向量搜索在相同嵌入模型的相同数据集上的结果。我们对全嵌入进行搜索。

    +
    # Search on entire embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=search_data,
    +    anns_field="embedding",
    +    limit=5,
    +    output_fields=["title", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", query)
    +    print("Results:")
    +    for row in rows:
    +        print(row["title"].strip())
    +    print()
    +
    +
    Query: An archaeologist searches for ancient artifacts while fighting Nazis.
    +Results:
    +"Pimpernel" Smith
    +Black Hunters
    +Raiders of the Lost Ark
    +The Master Key
    +My Gun Is Quick
    +
    +Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Results:
    +A Walk to Remember
    +Ferris Bueller's Day Off
    +How I Live Now
    +On the Edge of Innocence
    +Bratz: The Movie
    +
    +Query: A young couple with a kid look after a hotel during winter and the husband goes insane.
    +Results:
    +The Shining
    +Ghostkeeper
    +Fast and Loose
    +Killing Ground
    +Home Alone
    +
    +

    除了 "一名青少年为逃学而装病...... "的搜索结果外,漏斗搜索的结果与完全搜索的结果几乎完全相同,尽管漏斗搜索是在 128 维的搜索空间上进行的,而普通搜索是在 768 维的搜索空间上进行的。

    +

    调查《费里斯-布勒的一天》漏斗搜索召回失败的原因

    为什么漏斗搜索没有成功检索到《费里斯-布勒的一天》?让我们来看看它是否在原始候选列表中,还是被错误地过滤掉了。

    +
    queries2 = [
    +    "A teenager fakes illness to get off school and have adventures with two friends."
    +]
    +
    +
    +# Search the database based on input text
    +def embed_search(data):
    +    embeds = model.encode(data)
    +    return [x for x in embeds]
    +
    +
    +instruct_queries = ["search_query: " + q.strip() for q in queries2]
    +search_data2 = embed_search(instruct_queries)
    +head_search2 = [x[:search_dim] for x in search_data2]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=head_search2,
    +    anns_field="head_embedding",
    +    limit=256,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    for query, hits in zip(queries, res):
    +    rows = [x["entity"] for x in hits]
    +
    +    print("Query:", queries2[0])
    +    for idx, row in enumerate(rows):
    +        if row["title"].strip() == "Ferris Bueller's Day Off":
    +            print(f"Row {idx}: Ferris Bueller's Day Off")
    +
    +
    Query: A teenager fakes illness to get off school and have adventures with two friends.
    +Row 228: Ferris Bueller's Day Off
    +
    +

    我们发现,问题在于初始候选列表不够大,或者说,在最高粒度级别上,所需的点击与查询不够相似。把它从128 改为256 ,结果检索成功。我们应该形成一条经验法则,即通过经验评估召回率和延迟之间的权衡,来设定保留集上的候选项数量。

    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries2, dfs, search_data2)
    +]
    +
    +for d in dfs_results:
    +    print(d["query"], "\n", d["results"][:7]["title"].to_string(index=False), "\n")
    +
    +
    A teenager fakes illness to get off school and have adventures with two friends. 
    +       A Walk to Remember
    +Ferris Bueller's Day Off
    +          How I Live Now
    +On the Edge of Innocence
    +        Bratz: The Movie
    +              Unfriended
    +              Simon Says 
    +
    +

    顺序重要吗?前缀与后缀嵌入。

    经过训练,该模型能够很好地匹配递归较小的前缀嵌入。我们使用的维度顺序是否重要?例如,我们是否也可以提取后缀嵌入的子集?在本实验中,我们颠倒了 Matryoshka 嵌入中维度的顺序,并进行漏斗搜索。

    +
    client = MilvusClient(uri="./wikiplots-matryoshka-flipped.db")
    +
    +fields = [
    +    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    +    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
    +    FieldSchema(name="head_embedding", dtype=DataType.FLOAT_VECTOR, dim=search_dim),
    +    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=embedding_dim),
    +]
    +
    +schema = CollectionSchema(fields=fields, enable_dynamic_field=False)
    +client.create_collection(collection_name=collection_name, schema=schema)
    +
    +index_params = client.prepare_index_params()
    +index_params.add_index(
    +    field_name="head_embedding", index_type="FLAT", metric_type="COSINE"
    +)
    +client.create_index(collection_name, index_params)
    +
    +
    huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
    +To disable this warning, you can either:
    +    - Avoid using `tokenizers` before the fork if possible
    +    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
    +
    +
    for batch in tqdm(ds.batch(batch_size=512)):
    +    plot_summary = ["search_document: " + x.strip() for x in batch["PlotSummary"]]
    +
    +    # Encode and flip embeddings
    +    embeddings = model.encode(plot_summary, convert_to_tensor=True)
    +    embeddings = torch.flip(embeddings, dims=[-1])
    +    head_embeddings = embeddings[:, :search_dim]
    +
    +    data = [
    +        {
    +            "title": title,
    +            "head_embedding": head.cpu().numpy(),
    +            "embedding": embedding.cpu().numpy(),
    +        }
    +        for title, head, embedding in zip(batch["Title"], head_embeddings, embeddings)
    +    ]
    +    res = client.insert(collection_name=collection_name, data=data)
    +
    +
    100%|██████████| 69/69 [05:50<00:00,  5.08s/it]
    +
    +
    # Normalize head embeddings
    +
    +flip_search_data = [
    +    torch.flip(torch.tensor(x), dims=[-1]).cpu().numpy() for x in search_data
    +]
    +flip_head_search = [x[:search_dim] for x in flip_search_data]
    +
    +# Perform standard vector search on subset of embeddings
    +res = client.search(
    +    collection_name=collection_name,
    +    data=flip_head_search,
    +    anns_field="head_embedding",
    +    limit=128,
    +    output_fields=["title", "head_embedding", "embedding"],
    +)
    +
    +
    dfs = [hits_to_dataframe(hits) for hits in res]
    +
    +dfs_results = [
    +    {"query": query, "results": funnel_search(df, query_emb)}
    +    for query, df, query_emb in zip(queries, dfs, flip_search_data)
    +]
    +
    +for d in dfs_results:
    +    print(
    +        d["query"],
    +        "\n",
    +        d["results"][:7]["title"].to_string(index=False, header=False),
    +        "\n",
    +    )
    +
    +
    An archaeologist searches for ancient artifacts while fighting Nazis. 
    +       "Pimpernel" Smith
    +          Black Hunters
    +Raiders of the Lost Ark
    +         The Master Key
    +        My Gun Is Quick
    +            The Passage
    +        The Mole People 
    +
    +A teenager fakes illness to get off school and have adventures with two friends. 
    +                       A Walk to Remember
    +                          How I Live Now
    +                              Unfriended
    +Cirque du Freak: The Vampire's Assistant
    +                             Last Summer
    +                                 Contest
    +                                 Day One 
    +
    +A young couple with a kid look after a hotel during winter and the husband goes insane. 
    +         Ghostkeeper
    +     Killing Ground
    +Leopard in the Snow
    +              Stone
    +          Afterglow
    +         Unfaithful
    +     Always a Bride 
    +
    +

    正如预期的那样,召回率比漏斗搜索或常规搜索要差得多(嵌入模型是通过对嵌入维度的前缀而非后缀进行对比学习来训练的)。

    +

    总结

    以下是各种方法的搜索结果对比:

    +
    +
    +
    +我们展示了如何使用 Matryoshka 嵌入和 Milvus 来执行一种更高效的语义搜索算法,即 "漏斗搜索"。我们还探讨了该算法的 Rerankers 和剪枝步骤的重要性,以及当初始候选列表太小时的失败模式。最后,我们讨论了在形成子嵌入时,维度的顺序是如何重要的--它必须与模型训练时的顺序一致。或者说,只有因为模型是以某种方式训练的,嵌入的前缀才有意义。现在你知道如何实现 Matryoshka 嵌入和漏斗搜索,以降低语义搜索的存储成本,同时又不会牺牲太多检索性能了吧! diff --git a/localization/v2.4.x/site/zh/tutorials/tutorials-overview.md b/localization/v2.4.x/site/zh/tutorials/tutorials-overview.md index 980910524..13e6c6ab4 100644 --- a/localization/v2.4.x/site/zh/tutorials/tutorials-overview.md +++ b/localization/v2.4.x/site/zh/tutorials/tutorials-overview.md @@ -28,7 +28,7 @@ title: 教程概览 使用 Milvus 的多模式 RAGRAG向量搜索,动态字段 使用 Milvus 的图像搜索语义搜索向量搜索,动态字段 使用 Milvus 进行混合搜索混合搜索混合搜索、多向量、密集嵌入、稀疏嵌入 -使用多向量的多模态搜索语义搜索多向量、混合搜索 +使用多向量的多模式搜索语义搜索多向量、混合搜索 问题解答系统问题解答向量搜索 推荐系统推荐系统向量搜索 视频相似性搜索语义搜索向量搜索 @@ -43,5 +43,6 @@ title: 教程概览 使用 ColPali 与 Milvus 一起进行多模式检索快速启动向量搜索 向量可视化快速启动向量搜索 使用 Milvus 进行电影推荐推荐系统向量搜索 +利用 Matryoshka Embeddings 进行漏斗搜索快速启动向量搜索 diff --git a/localization/v2.4.x/site/zh/userGuide/manage-collections.json b/localization/v2.4.x/site/zh/userGuide/manage-collections.json index 992f8fbfc..6b8f97a35 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-collections.json +++ b/localization/v2.4.x/site/zh/userGuide/manage-collections.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"] # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"管理收藏集","href":"Manage-Collections","type":1,"isActive":false},{"label":"开始之前","href":"Before-you-start","type":2,"isActive":false},{"label":"概述","href":"Overview","type":2,"isActive":false},{"label":"创建 Collections","href":"Create-Collection","type":2,"isActive":false},{"label":"查看集合","href":"View-Collections","type":2,"isActive":false},{"label":"加载和释放 Collections","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"设置别名","href":"Set-up-aliases","type":2,"isActive":false},{"label":"设置属性","href":"Set-Properties","type":2,"isActive":false},{"label":"放弃收藏","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection in quick setup mode\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n\n// Thread.sleep(5000);\n\nGetLoadStateReq quickSetupLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nBoolean res = client.getLoadState(quickSetupLoadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nlet res = await client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ export MILVUS_URI=\"localhost:19530\"\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\",\n \"dimension\": 5\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3. Create a collection in customized setup mode\n\n# 3.1. Create schema\nschema = MilvusClient.create_schema(\n auto_id=False,\n enable_dynamic_field=True,\n)\n\n# 3.2. Add fields to schema\nschema.add_field(field_name=\"my_id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"my_vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\n","import io.milvus.v2.common.DataType;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\n// 3. Create a collection in customized setup mode\n\n// 3.1 Create schema\nCreateCollectionReq.CollectionSchema schema = client.createSchema();\n\n// 3.2 Add fields to schema\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_id\")\n .dataType(DataType.Int64)\n .isPrimaryKey(true)\n .autoID(false)\n .build());\n\nschema.addField(AddFieldReq.builder()\n .fieldName(\"my_vector\")\n .dataType(DataType.FloatVector)\n .dimension(5)\n .build());\n","// 3. Create a collection in customized setup mode\n// 3.1 Define fields\nconst fields = [\n {\n name: \"my_id\",\n data_type: DataType.Int64,\n is_primary_key: true,\n auto_id: false\n },\n {\n name: \"my_vector\",\n data_type: DataType.FloatVector,\n dim: 5\n },\n]\n","export fields='[{ \\\n \"fieldName\": \"my_id\", \\\n \"dataType\": \"Int64\", \\\n \"isPrimary\": true \\\n}, \\\n{ \\\n \"fieldName\": \"my_vector\", \\\n \"dataType\": \"FloatVector\", \\\n \"elementTypeParams\": { \\\n \"dim\": 5 \\\n } \\\n}]'\n","# 3.3. Prepare index parameters\nindex_params = client.prepare_index_params()\n\n# 3.4. Add indexes\nindex_params.add_index(\n field_name=\"my_id\",\n index_type=\"STL_SORT\"\n)\n\nindex_params.add_index(\n field_name=\"my_vector\", \n index_type=\"IVF_FLAT\",\n metric_type=\"IP\",\n params={ \"nlist\": 128 }\n)\n","import io.milvus.v2.common.IndexParam;\n\n// 3.3 Prepare index parameters\nIndexParam indexParamForIdField = IndexParam.builder()\n .fieldName(\"my_id\")\n .indexType(IndexParam.IndexType.STL_SORT)\n .build();\n\nIndexParam indexParamForVectorField = IndexParam.builder()\n .fieldName(\"my_vector\")\n .indexType(IndexParam.IndexType.IVF_FLAT)\n .metricType(IndexParam.MetricType.L2)\n .extraParams(Map.of(\"nlist\", 1024))\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForIdField);\nindexParams.add(indexParamForVectorField);\n","// 3.2 Prepare index parameters\nconst index_params = [{\n field_name: \"my_id\",\n index_type: \"STL_SORT\"\n},{\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n}]\n","export indexParams='[{ \\\n \"fieldName\": \"my_id\", \\\n \"indexName\": \"my_id\", \\\n \"params\": { \\\n \"index_type\": \"SLT_SORT\" \\\n } \\\n}, { \\\n \"fieldName\": \"my_vector\", \\\n \"metricType\": \"COSINE\", \\\n \"indexName\": \"my_vector\", \\\n \"params\": { \\\n \"index_type\": \"IVF_FLAT\", \\\n \"nlist\": 1024 \\\n } \\\n}]'\n","# 3.5. Create a collection with the index loaded simultaneously\nclient.create_collection(\n collection_name=\"customized_setup_1\",\n schema=schema,\n index_params=index_params\n)\n\ntime.sleep(5)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\n\n// 3.4 Create a collection with schema and index parameters\nCreateCollectionReq customizedSetupReq1 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .collectionSchema(schema)\n .indexParams(indexParams)\n .build();\n\nclient.createCollection(customizedSetupReq1);\n\n// Thread.sleep(5000);\n\n// 3.5 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq1 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq1);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 3.3 Create a collection with fields and index parameters\nres = await client.createCollection({\n collection_name: \"customized_setup_1\",\n fields: fields,\n index_params: index_params,\n})\n\nconsole.log(res.error_code) \n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n },\n \"indexParams\": [\n {\n \"fieldName\": \"my_vector\",\n \"metricType\": \"COSINE\",\n \"indexName\": \"my_vector\",\n \"params\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n },\n {\n \"fieldName\": \"my_id\",\n \"indexName\": \"my_id\",\n \"params\": {\n \"index_type\": \"STL_SORT\"\n } \n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 3.6. Create a collection and index it separately\nclient.create_collection(\n collection_name=\"customized_setup_2\",\n schema=schema,\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","// 3.6 Create a collection and index it separately\nCreateCollectionReq customizedSetupReq2 = CreateCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .collectionSchema(schema)\n .build();\n\nclient.createCollection(customizedSetupReq2);\n","// 3.4 Create a collection and index it seperately\nres = await client.createCollection({\n collection_name: \"customized_setup_2\",\n fields: fields,\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"schema\": {\n \"autoId\": false,\n \"enabledDynamicField\": false,\n \"fields\": [\n {\n \"fieldName\": \"my_id\",\n \"dataType\": \"Int64\",\n \"isPrimary\": true\n },\n {\n \"fieldName\": \"my_vector\",\n \"dataType\": \"FloatVector\",\n \"elementTypeParams\": {\n \"dim\": \"5\"\n }\n }\n ]\n \n }\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 3.6 Create index\nclient.create_index(\n collection_name=\"customized_setup_2\",\n index_params=index_params\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","CreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"customized_setup_2\")\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n\n// Thread.sleep(1000);\n\n// 3.7 Get load state of the collection\nGetLoadStateReq customSetupLoadStateReq2 = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(customSetupLoadStateReq2);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 3.5 Create index\nres = await client.createIndex({\n collection_name: \"customized_setup_2\",\n field_name: \"my_vector\",\n index_type: \"IVF_FLAT\",\n metric_type: \"IP\",\n params: { nlist: 1024}\n})\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n//\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/indexes/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"indexParams\": [\n {\n \"metricType\": \"L2\",\n \"fieldName\": \"my_vector\",\n \"indexName\": \"my_vector\",\n \"indexConfig\": {\n \"index_type\": \"IVF_FLAT\",\n \"nlist\": \"1024\"\n }\n }\n ]\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoaded\"\n# }\n# }\n","# 5. View Collections\nres = client.describe_collection(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"collection_name\": \"customized_setup_2\",\n# \"auto_id\": false,\n# \"num_shards\": 1,\n# \"description\": \"\",\n# \"fields\": [\n# {\n# \"field_id\": 100,\n# \"name\": \"my_id\",\n# \"description\": \"\",\n# \"type\": 5,\n# \"params\": {},\n# \"element_type\": 0,\n# \"is_primary\": true\n# },\n# {\n# \"field_id\": 101,\n# \"name\": \"my_vector\",\n# \"description\": \"\",\n# \"type\": 101,\n# \"params\": {\n# \"dim\": 5\n# },\n# \"element_type\": 0\n# }\n# ],\n# \"aliases\": [],\n# \"collection_id\": 448143479230158446,\n# \"consistency_level\": 2,\n# \"properties\": {},\n# \"num_partitions\": 1,\n# \"enable_dynamic_field\": true\n# }\n\n","import io.milvus.v2.service.collection.request.DescribeCollectionReq;\nimport io.milvus.v2.service.collection.response.DescribeCollectionResp;\n\n// 4. View collections\nDescribeCollectionReq describeCollectionReq = DescribeCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nDescribeCollectionResp describeCollectionRes = client.describeCollection(describeCollectionReq);\n\nSystem.out.println(JSONObject.toJSON(describeCollectionRes));\n\n// Output:\n// {\n// \"createTime\": 449005822816026627,\n// \"collectionSchema\": {\"fieldSchemaList\": [\n// {\n// \"autoID\": false,\n// \"dataType\": \"Int64\",\n// \"name\": \"my_id\",\n// \"description\": \"\",\n// \"isPrimaryKey\": true,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// },\n// {\n// \"autoID\": false,\n// \"dataType\": \"FloatVector\",\n// \"name\": \"my_vector\",\n// \"description\": \"\",\n// \"isPrimaryKey\": false,\n// \"dimension\": 5,\n// \"maxLength\": 65535,\n// \"isPartitionKey\": false\n// }\n// ]},\n// \"vectorFieldName\": [\"my_vector\"],\n// \"autoID\": false,\n// \"fieldNames\": [\n// \"my_id\",\n// \"my_vector\"\n// ],\n// \"description\": \"\",\n// \"numOfPartitions\": 1,\n// \"primaryFieldName\": \"my_id\",\n// \"enableDynamicField\": true,\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 5. View Collections\nres = await client.describeCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// virtual_channel_names: [ 'by-dev-rootcoord-dml_13_449007919953017716v0' ],\n// physical_channel_names: [ 'by-dev-rootcoord-dml_13' ],\n// aliases: [],\n// start_positions: [],\n// properties: [],\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// schema: {\n// fields: [ [Object], [Object] ],\n// properties: [],\n// name: 'customized_setup_2',\n// description: '',\n// autoID: false,\n// enable_dynamic_field: false\n// },\n// collectionID: '449007919953017716',\n// created_timestamp: '449024569603784707',\n// created_utc_timestamp: '1712892797866',\n// shards_num: 1,\n// consistency_level: 'Bounded',\n// collection_name: 'customized_setup_2',\n// db_name: 'default',\n// num_partitions: '1'\n// }\n// \n","curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\",\n \"collectionName\": \"test_collection\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliases\": [],\n# \"autoId\": false,\n# \"collectionID\": 448707763883002014,\n# \"collectionName\": \"test_collection\",\n# \"consistencyLevel\": \"Bounded\",\n# \"description\": \"\",\n# \"enableDynamicField\": true,\n# \"fields\": [\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 100,\n# \"name\": \"id\",\n# \"partitionKey\": false,\n# \"primaryKey\": true,\n# \"type\": \"Int64\"\n# },\n# {\n# \"autoId\": false,\n# \"description\": \"\",\n# \"id\": 101,\n# \"name\": \"vector\",\n# \"params\": [\n# {\n# \"key\": \"dim\",\n# \"value\": \"5\"\n# }\n# ],\n# \"partitionKey\": false,\n# \"primaryKey\": false,\n# \"type\": \"FloatVector\"\n# }\n# ],\n# \"indexes\": [\n# {\n# \"fieldName\": \"vector\",\n# \"indexName\": \"vector\",\n# \"metricType\": \"COSINE\"\n# }\n# ],\n# \"load\": \"LoadStateLoaded\",\n# \"partitionsNum\": 1,\n# \"properties\": [],\n# \"shardsNum\": 1\n# }\n# }\n","# 6. List all collection names\nres = client.list_collections()\n\nprint(res)\n\n# Output\n#\n# [\n# \"customized_setup_2\",\n# \"quick_setup\",\n# \"customized_setup_1\"\n# ]\n","import io.milvus.v2.service.collection.response.ListCollectionsResp;\n\n// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_2\",\n// \"quick_setup\",\n// \"customized_setup_1\"\n// ]\n","// 5. List all collection names\nListCollectionsResp listCollectionsRes = client.listCollections();\n\nSystem.out.println(listCollectionsRes.getCollectionNames());\n\n// Output:\n// [\n// \"customized_setup_1\",\n// \"quick_setup\",\n// \"customized_setup_2\"\n// ]\n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"dbName\": \"default\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"quick_setup\",\n# \"customized_setup_1\",\n# \"customized_setup_2\"\n# ]\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n replica_number=1 # Number of replicas to create on query nodes. Max value is 1 for Milvus Standalone, and no greater than `queryNode.replicas` for Milvus Cluster.\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.LoadCollectionReq;\n\n// 6. Load the collection\nLoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.loadCollection(loadCollectionReq);\n\n// Thread.sleep(5000);\n\n// 7. Get load state of the collection\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// true\n","// 7. Load the collection\nres = await client.loadCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/load\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadProgress\": 100,\n# \"loadState\": \"LoadStateLoaded\"\n# }\n# }\n","# 7. Load the collection\nclient.load_collection(\n collection_name=\"customized_setup_2\",\n load_fields=[\"my_id\", \"my_vector\"], # Load only the specified fields\n skip_load_dynamic_field=True # Skip loading the dynamic field\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Release the collection\nclient.release_collection(\n collection_name=\"customized_setup_2\"\n)\n\nres = client.get_load_state(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","import io.milvus.v2.service.collection.request.ReleaseCollectionReq;\n\n// 8. Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// Thread.sleep(1000);\n\nres = client.getLoadState(loadStateReq);\n\nSystem.out.println(res);\n\n// Output:\n// false\n","// 8. Release the collection\nres = await client.releaseCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.getLoadState({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/release\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {},\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/get_load_state\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"loadState\": \"LoadStateNotLoad\"\n# }\n# }\n","# 9.1. Create aliases\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"bob\"\n)\n\nclient.create_alias(\n collection_name=\"customized_setup_2\",\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.CreateAliasReq;\n\n// 9. Manage aliases\n\n// 9.1 Create alias\nCreateAliasReq createAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"bob\")\n .build();\n\nclient.createAlias(createAliasReq);\n\ncreateAliasReq = CreateAliasReq.builder()\n .collectionName(\"customized_setup_2\")\n .alias(\"alice\")\n .build();\n\nclient.createAlias(createAliasReq);\n","// 9. Manage aliases\n// 9.1 Create aliases\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.createAlias({\n collection_name: \"customized_setup_2\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"bob\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/create\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\",\n \"aliasName\": \"alice\"\n}'\n\n# Output\n#\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","# 9.2. List aliases\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\",\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.ListAliasesReq;\nimport io.milvus.v2.service.utility.response.ListAliasResp;\n\n// 9.2 List alises\nListAliasesReq listAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nListAliasResp listAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\n// \"bob\",\n// \"alice\"\n// ]\n","// 9.2 List aliases\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob', 'alice' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\",\n# \"alice\"\n# ]\n# }\n","# 9.3. Describe aliases\nres = client.describe_alias(\n alias=\"bob\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"alias\": \"bob\",\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.DescribeAliasReq;\nimport io.milvus.v2.service.utility.response.DescribeAliasResp;\n\n// 9.3 Describe alias\nDescribeAliasReq describeAliasReq = DescribeAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nDescribeAliasResp describeAliasRes = client.describeAlias(describeAliasReq);\n\nSystem.out.println(JSONObject.toJSON(describeAliasRes));\n\n// Output:\n// {\n// \"alias\": \"bob\",\n// \"collectionName\": \"customized_setup_2\"\n// }\n","// 9.3 Describe aliases\nres = await client.describeAlias({\n collection_name: \"customized_setup_2\",\n alias: \"bob\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// extra_info: {},\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// db_name: 'default',\n// alias: 'bob',\n// collection: 'customized_setup_2'\n// }\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/describe\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {\n# \"aliasName\": \"bob\",\n# \"collectionName\": \"quick_setup\",\n# \"dbName\": \"default\"\n# }\n# }\n","# 9.4 Reassign aliases to other collections\nclient.alter_alias(\n collection_name=\"customized_setup_1\",\n alias=\"alice\"\n)\n\nres = client.list_aliases(\n collection_name=\"customized_setup_1\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"alice\"\n# ],\n# \"collection_name\": \"customized_setup_1\",\n# \"db_name\": \"default\"\n# }\n\nres = client.list_aliases(\n collection_name=\"customized_setup_2\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"aliases\": [\n# \"bob\"\n# ],\n# \"collection_name\": \"customized_setup_2\",\n# \"db_name\": \"default\"\n# }\n","import io.milvus.v2.service.utility.request.AlterAliasReq;\n\n// 9.4 Reassign alias to other collections\nAlterAliasReq alterAliasReq = AlterAliasReq.builder()\n .collectionName(\"customized_setup_1\")\n .alias(\"alice\")\n .build();\n\nclient.alterAlias(alterAliasReq);\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"alice\"]\n\nlistAliasesReq = ListAliasesReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nlistAliasRes = client.listAliases(listAliasesReq);\n\nSystem.out.println(listAliasRes.getAlias());\n\n// Output:\n// [\"bob\"]\n","// 9.4 Reassign aliases to other collections\nres = await client.alterAlias({\n collection_name: \"customized_setup_1\",\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'alice' ]\n// \n\nres = await client.listAliases({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.aliases)\n\n// Output\n// \n// [ 'bob' ]\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/alter\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\",\n \"aliasName\": \"alice\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"alice\"\n# ]\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/list\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": [\n# \"bob\"\n# ]\n# }\n","# 9.5 Drop aliases\nclient.drop_alias(\n alias=\"bob\"\n)\n\nclient.drop_alias(\n alias=\"alice\"\n)\n","import io.milvus.v2.service.utility.request.DropAliasReq;\n\n// 9.5 Drop alias\nDropAliasReq dropAliasReq = DropAliasReq.builder()\n .alias(\"bob\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n\ndropAliasReq = DropAliasReq.builder()\n .alias(\"alice\")\n .build();\n\nclient.dropAlias(dropAliasReq);\n","// 9.5 Drop aliases\nres = await client.dropAlias({\n alias: \"bob\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropAlias({\n alias: \"alice\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"bob\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/aliases/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"aliasName\": \"alice\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Set the TTL for the data in the collection\ncollection.set_properties(\n properties={\n \"collection.ttl.seconds\": 60\n }\n)\n","from pymilvus import Collection, connections\n\n# Connect to Milvus server\nconnections.connect(host=\"localhost\", port=\"19530\") # Change to your Milvus server IP and port\n\n# Get existing collection\ncollection = Collection(\"quick_setup\")\n\n# Before setting memory mapping property, we need to release the collection first.\ncollection.release()\n\n# Set memory mapping property to True or Flase\ncollection.set_properties(\n properties={\n \"mmap.enabled\": True\n }\n)\n","# 10. Drop the collections\nclient.drop_collection(\n collection_name=\"quick_setup\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_1\"\n)\n\nclient.drop_collection(\n collection_name=\"customized_setup_2\"\n)\n","import io.milvus.v2.service.collection.request.DropCollectionReq;\n\n// 10. Drop collections\n\nDropCollectionReq dropQuickSetupParam = DropCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.dropCollection(dropQuickSetupParam);\n\nDropCollectionReq dropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_1\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n\ndropCustomizedSetupParam = DropCollectionReq.builder()\n .collectionName(\"customized_setup_2\")\n .build();\n\nclient.dropCollection(dropCustomizedSetupParam);\n","// 10. Drop the collection\nres = await client.dropCollection({\n collection_name: \"customized_setup_2\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"customized_setup_1\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n\nres = await client.dropCollection({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.error_code)\n\n// Output\n// \n// Success\n// \n","$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"quick_setup\"\n}'\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_1\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n\n\n$ curl -X POST \"http://${MILVUS_URI}/v2/vectordb/collections/drop\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"collectionName\": \"customized_setup_2\"\n}'\n\n\n# {\n# \"code\": 0,\n# \"data\": {}\n# }\n"],"headingContent":"Manage Collections","anchorList":[{"label":"管理收藏集","href":"Manage-Collections","type":1,"isActive":false},{"label":"开始之前","href":"Before-you-start","type":2,"isActive":false},{"label":"概述","href":"Overview","type":2,"isActive":false},{"label":"创建 Collections","href":"Create-Collection","type":2,"isActive":false},{"label":"查看集合","href":"View-Collections","type":2,"isActive":false},{"label":"加载和释放 Collections","href":"Load--Release-Collection","type":2,"isActive":false},{"label":"设置别名","href":"Set-up-aliases","type":2,"isActive":false},{"label":"设置属性","href":"Set-Properties","type":2,"isActive":false},{"label":"放弃收藏","href":"Drop-a-Collection","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/userGuide/manage-collections.md b/localization/v2.4.x/site/zh/userGuide/manage-collections.md index a6c221e10..a496e4eec 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-collections.md +++ b/localization/v2.4.x/site/zh/userGuide/manage-collections.md @@ -222,11 +222,11 @@ $ curl -X POST "http://auto_id

    启用该设置可确保主键自动递增。数据插入时无需手动提供主键。

  • enable_dynamic_field

    -

    启用后,待插入数据中除idvector 以外的所有字段都会被视为动态字段。这些附加字段以键值对的形式保存在一个名为$meta 的特殊字段中。此功能允许在插入数据时包含额外字段。

  • +

    启用后,待插入数据中除idvector 之外的所有字段都会被视为动态字段。这些附加字段以键值对的形式保存在一个名为$meta 的特殊字段中。此功能允许在插入数据时包含额外字段。

    从提供的代码中自动索引和加载的 Collections 可以立即插入数据。

    自定义设置

    与其让 Milvus 为你的 Collections 决定几乎一切,你可以自己决定 Collections 的Schema索引参数

    -

    第一步:设置 Schema

    Schema 定义了 Collections 的结构。在 Schema 中,您可以选择启用或禁用enable_dynamic_field 、添加预定义字段以及为每个字段设置属性。有关概念和可用数据类型的详细解释,请参阅Schema Explained

    +

    第 1 步:设置 Schema

    Schema 定义了 Collections 的结构。在 Schema 中,您可以选择启用或禁用enable_dynamic_field 、添加预定义字段以及为每个字段设置属性。有关概念和可用数据类型的详细解释,请参阅Schema Explained

    要设置模式,请使用 create_schema()创建模式对象,并使用 add_field()为模式添加字段。

    @@ -318,7 +318,7 @@ schema.addField(AddFieldReq.builder() enable_dynamic_field - 如果插入到目标 Collections 的数据包括未在 Collections 模式中定义的字段,则决定 Milvus 是否将未定义字段的值保存在动态字段中。
    设置为 "true"时,Milvus 将创建一个名为$meta的字段,用于保存插入数据中的任何未定义字段及其值。 + 决定如果插入到目标 Collections 的数据包括未在 Collections 模式中定义的字段,Milvus 是否将未定义字段的值保存在动态字段中。
    设置为 "true"时,Milvus 将创建一个名为$meta的字段,用于保存插入数据中的任何未定义字段及其值。 field_name @@ -439,7 +439,7 @@ schema.addField(AddFieldReq.builder()

    要设置索引参数,请使用 createIndex().

    -

    要设置索引参数,您需要定义一个 JSON 对象,该对象应遵循 API 端点参考页面上显示的索引参数格式。 POST /v2/vectordb/collections/createAPI 端点参考页面上显示的索引参数格式定义一个 JSON 对象。

    +

    要设置索引参数,需要定义一个 JSON 对象,该对象应遵循 POST /v2/vectordb/collections/createAPI 端点参考页面上显示的索引参数格式定义一个 JSON 对象。

    @@ -523,7 +523,7 @@ indexParams.add(indexParamForVectorField); metric_type - 用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有当指定字段是向量字段时才可用。更多信息,请参阅Milvus 支持的索引。 + 用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有指定字段为向量字段时才可用。更多信息,请参阅Milvus 支持的索引params @@ -553,7 +553,7 @@ indexParams.add(indexParamForVectorField); extraParams - 额外的索引参数。有关详细信息,请参阅内存索引磁盘索引。 + 额外的索引参数。有关详情,请参阅内存索引磁盘索引。 @@ -575,7 +575,7 @@ indexParams.add(indexParamForVectorField); metric_type - 用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有当指定字段是向量字段时才可用。更多信息,请参阅Milvus 支持的索引。 + 用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有指定字段为向量字段时才可用。更多信息,请参阅Milvus 支持的索引params @@ -866,7 +866,7 @@ $ curl -X POST "http://# } # }
    -

    上面创建的 Collection 不会自动加载。您可以按如下方式为 Collections 创建索引。以单独的方式为 Collection 创建索引不会自动加载 Collection。有关详情,请参阅加载和释放 Collections

    +

    上面创建的 Collection 不会自动加载。您可以按如下方式为 Collections 创建索引。以单独的方式为 Collection 创建索引不会自动加载 Collection。有关详细信息,请参阅加载和释放 Collections

    @@ -971,11 +971,11 @@ $ curl -X POST "http://fields.isPrimary - + - + @@ -983,7 +983,7 @@ $ curl -X POST "http://加载和释放集合。

    +

    上面创建的 Collection 不会自动加载。您可以按以下方法为 Collections 创建索引。以单独方式为集合创建索引不会自动加载集合。有关详细信息,请参阅加载和释放集合

    # 3.6 Create index
    @@ -1142,7 +1142,7 @@ $ curl -X POST "http://metric_type
    -      
    + @@ -1601,7 +1601,7 @@ $ curl -X POST "http://# 7. Load the collection client.load_collection( collection_name="customized_setup_2", - load_fields=["my_id", "my_vector"] # Load only the specified fields + load_fields=["my_id", "my_vector"], # Load only the specified fields skip_load_dynamic_field=True # Skip loading the dynamic field ) @@ -1617,7 +1617,7 @@ res = client.get_load_state( # "state": "<LoadState: Loaded>" # } -

    请注意,只有load_fields 中列出的字段才能用作搜索和查询的筛选条件和输出字段。在列表中应始终包含主键。不加载的字段名将不能用于筛选或输出。

    +

    请注意,只有load_fields 中列出的字段才能用作搜索和查询的筛选条件和输出字段。列表中应始终包含主键。不加载的字段名将不能用于筛选或输出。

    可以使用skip_load_dynamic_field=True 跳过加载动态字段。Milvus 将动态字段视为单个字段,因此动态字段中的所有键将一起被包含或排除。

    释放 Collections

    @@ -1916,7 +1916,7 @@ $ curl -X POST "http://listAliases()方法,并指定 Collections 名称。

    -

    要列出 Collections 的别名,可使用 POST /v2/vectordb/aliases/listAPI 端点。

    +

    要列出某个 Collection 的别名,可使用 POST /v2/vectordb/aliases/listAPI 端点。

    diff --git a/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.json b/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.json index a5a6852ab..ce307e351 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.json +++ b/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.json @@ -1 +1 @@ -{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = client.create_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"","anchorList":[{"label":"标量字段索引","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"标量索引的类型","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"自动索引","href":"Auto-indexing","type":2,"isActive":false},{"label":"自定义索引","href":"Custom-indexing","type":2,"isActive":false},{"label":"验证结果","href":"Verifying-the-result","type":2,"isActive":false},{"label":"限制","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["# Auto indexing\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\nindex_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters\n\nindex_params.add_index(\n field_name=\"scalar_1\", # Name of the scalar field to be indexed\n index_type=\"\", # Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n index_name=\"default_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"default_index\") // Name of the index to be created\n .indexType(\"\") // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"default_index\", // Name of the index to be created\n index_type: \"\" // Type of index to be created. For auto indexing, leave it empty or omit this parameter.\n})\n","index_params = MilvusClient.prepare_index_params() # Prepare an IndexParams object\n\nindex_params.add_index(\n field_name=\"scalar_2\", # Name of the scalar field to be indexed\n index_type=\"INVERTED\", # Type of index to be created\n index_name=\"inverted_index\" # Name of the index to be created\n)\n\nclient.create_index(\n collection_name=\"test_scalar_index\", # Specify the collection name\n index_params=index_params\n)\n","import io.milvus.v2.common.IndexParam;\nimport io.milvus.v2.service.index.request.CreateIndexReq;\n\nIndexParam indexParamForScalarField = IndexParam.builder()\n .fieldName(\"scalar_1\") // Name of the scalar field to be indexed\n .indexName(\"inverted_index\") // Name of the index to be created\n .indexType(\"INVERTED\") // Type of index to be created\n .build();\n\nList indexParams = new ArrayList<>();\nindexParams.add(indexParamForVectorField);\n\nCreateIndexReq createIndexReq = CreateIndexReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .indexParams(indexParams)\n .build();\n\nclient.createIndex(createIndexReq);\n","await client.createIndex({\n collection_name: \"test_scalar_index\", // Specify the collection name\n field_name: \"scalar_1\", // Name of the scalar field to be indexed\n index_name: \"inverted_index\", // Name of the index to be created\n index_type: \"INVERTED\" // Type of index to be created\n})\n","client.list_indexes(\n collection_name=\"test_scalar_index\" # Specify the collection name\n)\n\n# Output:\n# ['default_index','inverted_index']\n","import java.util.List;\nimport io.milvus.v2.service.index.request.ListIndexesReq;\n\nListIndexesReq listIndexesReq = ListIndexesReq.builder()\n .collectionName(\"test_scalar_index\") // Specify the collection name\n .build();\n\nList indexNames = client.listIndexes(listIndexesReq);\n\nSystem.out.println(indexNames);\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ]\n","res = await client.listIndexes({\n collection_name: 'test_scalar_index'\n})\n\nconsole.log(res.indexes)\n\n// Output:\n// [\n// \"default_index\",\n// \"inverted_index\"\n// ] \n"],"headingContent":"Index Scalar Fields","anchorList":[{"label":"标量字段索引","href":"Index-Scalar-Fields","type":1,"isActive":false},{"label":"标量索引的类型","href":"Types-of-scalar-indexing","type":2,"isActive":false},{"label":"自动索引","href":"Auto-indexing","type":2,"isActive":false},{"label":"自定义索引","href":"Custom-indexing","type":2,"isActive":false},{"label":"验证结果","href":"Verifying-the-result","type":2,"isActive":false},{"label":"限制","href":"Limits","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.md b/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.md index 40c0247da..b7114ecd0 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.md +++ b/localization/v2.4.x/site/zh/userGuide/manage-indexes/index-scalar-fields.md @@ -2,7 +2,7 @@ id: index-scalar-fields.md order: 2 summary: 本指南将指导您为整数、字符串等字段创建和配置标量索引。 -title: 索引标量字段 +title: 标量字段索引 ---

    标量字段索引

    -

    要使用自动索引,请省略 add_index()中省略 index_type 参数,这样 Milvus 就能根据标量字段类型推断出索引类型。

    +

    要使用自动索引,请省略 add_index()中省略 index_type 参数,以便 Milvus 根据标量字段类型推断索引类型。

    要使用自动索引,请省略 IndexParam中的 indexType 参数,以便 Milvus 根据标量字段类型推断索引类型。

    @@ -71,7 +71,7 @@ client = MilvusClient( uri="http://localhost:19530" ) -index_params = client.create_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters +index_params = MilvusClient.prepare_index_params() # Prepare an empty IndexParams object, without having to specify any index parameters index_params.add_index( field_name="scalar_1", # Name of the scalar field to be indexed @@ -137,7 +137,7 @@ client.createIndex(createIndexReq);

    下面的示例为标量字段scalar_2 创建了一个反转索引。

    -
    index_params = client.create_index_params() #  Prepare an IndexParams object
    +
    index_params = MilvusClient.prepare_index_params() #  Prepare an IndexParams object
     
     index_params.add_index(
         field_name="scalar_2", # Name of the scalar field to be indexed
    @@ -179,8 +179,8 @@ client.createIndex(createIndexReq);
     

    方法和参数

      -
    • create_index_params()

      -

      创建IndexParams对象。

    • +
    • prepare_index_params()

      +

      准备一个IndexParams对象。

    • add_index()

      IndexParams对象添加索引配置。

        @@ -198,12 +198,12 @@ client.createIndex(createIndexReq);

        要创建的标量索引的名称。每个标量字段支持一个索引。

    • create_index()

      -

      在指定的集合中创建索引。

      +

      在指定的 Collection 中创建索引。

      • collection_name(字符串)

        -

        创建索引的集合名称。

      • +

        创建索引的 Collection 的名称。

      • 索引参数

        -

        包含索引配置的IndexParams对象。

      • +

        包含索引配置的IndexParams对象。

    @@ -213,13 +213,13 @@ client.createIndex(createIndexReq);
  • IndexParam准备一个 IndexParam 对象。
    • fieldName(字符串) 要索引的标量字段的名称。
    • indexName(字符串) 要创建的标量索引的名称。每个标量字段支持一个索引。
    • -
    • indexType(字符串) 要创建的标量索引的类型。对于隐式索引,请将其留空或省略此参数。 对于自定义索引,有效值为
        +
      • indexType(字符串) 要创建的标量索引的类型。对于隐式索引,留空或省略此参数。 对于自定义索引,有效值为
        • 倒排:(推荐)倒排索引由术语字典组成,其中包含按字母顺序排序的所有标记词。有关详情,请参阅标量索引
        • STL_SORT:使用标准模板库排序算法对标量字段进行排序。支持布尔和数值字段(如 INT8、INT16、INT32、INT64、FLOAT、DOUBLE)。
        • Trie用于快速前缀搜索和检索的树形数据结构。支持 VARCHAR 字段。
    • -
    • CreateIndexReq在指定的集合中创建索引。
        +
      • CreateIndexReq在指定的 Collections 中创建索引。
        • collectionName(字符串) 创建索引的集合名称。
        • indexParams(List) 包含索引配置的 IndexParam 对象列表。
      • @@ -229,13 +229,13 @@ client.createIndex(createIndexReq);

        方法和参数

        • 创建索引

          -

          在指定的集合中创建索引。

          +

          在指定的 Collection 中创建索引。

          • collection_name(字符串) 创建索引的集合名称。
          • field_name(字符串) 要创建索引的标量字段的名称。
          • index_name(字符串) 要创建的标量索引的名称。每个标量字段支持一个索引。
          • index_type(字符串) 要创建的标量索引的类型。对于隐式索引,请将其留空或省略此参数。 对于自定义索引,有效值为
              -
            • 倒排:(推荐)倒排索引由包含按字母顺序排列的所有标记词的术语字典组成。有关详情,请参阅标量索引
            • +
            • 倒排:(推荐)倒排索引由包含按字母顺序排序的所有标记词的术语字典组成。有关详情,请参阅标量索引
            • STL_SORT:使用标准模板库排序算法对标量字段进行排序。支持布尔和数值字段(如 INT8、INT16、INT32、INT64、FLOAT、DOUBLE)。
            • Trie用于快速前缀搜索和检索的树形数据结构。支持 VARCHAR 字段。
          • diff --git a/localization/v2.4.x/site/zh/userGuide/manage-partitions.json b/localization/v2.4.x/site/zh/userGuide/manage-partitions.json index 59b4f61ff..25ea73b2c 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-partitions.json +++ b/localization/v2.4.x/site/zh/userGuide/manage-partitions.json @@ -1 +1 @@ -{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_status(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"管理分区","href":"Manage-Partitions","type":1,"isActive":false},{"label":"分区概述","href":"Overview","type":2,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"列出分区","href":"List-Partitions","type":2,"isActive":false},{"label":"创建分区","href":"Create-Partitions","type":2,"isActive":false},{"label":"检查特定分区","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"加载和释放分区","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"丢弃分区","href":"Drop-Partitions","type":2,"isActive":false},{"label":"常见问题","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient, DataType\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n)\n\n","import io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig);\n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .build();\n\nclient.createCollection(quickSetupReq);\n","const address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n}); \n","# 3. List partitions\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\"]\n","import io.milvus.v2.service.partition.request.ListPartitionsReq;\n\n// 3. List all partitions in the collection\nListPartitionsReq listPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nList partitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\"_default\"]\n","// 3. List partitions\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default' ]\n// \n","# 4. Create more partitions\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\", \"partitionB\"]\n","import io.milvus.v2.service.partition.request.CreatePartitionReq;\n\n// 4. Create more partitions\nCreatePartitionReq createPartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\ncreatePartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nclient.createPartition(createPartitionReq);\n\nlistPartitionsReq = ListPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\npartitionNames = client.listPartitions(listPartitionsReq);\n\nSystem.out.println(partitionNames);\n\n// Output:\n// [\n// \"_default\",\n// \"partitionA\",\n// \"partitionB\"\n// ]\n","// 4. Create more partitions\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nres = await client.listPartitions({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.partition_names)\n\n// Output\n// \n// [ '_default', 'partitionA', 'partitionB' ]\n// \n","# 5. Check whether a partition exists\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\nprint(res)\n\n# Output\n#\n# True\n\nres = client.has_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionC\"\n)\nprint(res)\n\n# Output\n#\n# False\n","import io.milvus.v2.service.partition.request.HasPartitionReq;\n\n// 5. Check whether a partition exists\nHasPartitionReq hasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nboolean exists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// true\n\nhasPartitionReq = HasPartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionC\")\n .build();\n\nexists = client.hasPartition(hasPartitionReq);\n\nSystem.out.println(exists);\n\n// Output:\n// false\n","// 5. Check whether a partition exists\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// true\n// \n\nres = await client.hasPartition({\n collection_name: \"quick_setup\",\n partition_name: \"partitionC\"\n})\n\nconsole.log(res.value)\n\n// Output\n// \n// false\n// \n","# Release the collection\nclient.release_collection(collection_name=\"quick_setup\")\n\n# Check the load status\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionB\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.collection.request.ReleaseCollectionReq;\nimport io.milvus.v2.service.partition.request.LoadPartitionsReq;\nimport io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 6. Load a partition independantly\n// 6.1 Release the collection\nReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nclient.releaseCollection(releaseCollectionReq);\n\n// 6.2 Load partitionA\nLoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\nThread.sleep(3000);\n\n// 6.3 Check the load status of the collection and its partitions\nGetLoadStateReq getLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 6. Load a partition indenpendantly\nawait client.releaseCollection({\n collection_name: \"quick_setup\"\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n\nawait client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nawait sleep(3000)\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateLoaded\n//\n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionA\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","LoadPartitionsReq loadPartitionsReq = LoadPartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\", \"partitionB\"))\n .build();\n\nclient.loadPartitions(loadPartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionB\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n","await client.loadPartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionA\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n\nres = await client.getLoadState({\n collection_name: \"quick_setup\",\n partition_name: \"partitionB\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// LoadStateLoaded\n// \n","client.load_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"],\n load_fields=[\"id\", \"vector\"],\n skip_load_dynamic_field=True\n)\n","# 7. Release a partition\nclient.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"partitionA\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\", \n partition_name=\"partitionA\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\n// 7. Release a partition\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"partitionA\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"partitionA\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","// 7. Release a partition\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"partitionA\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res.state)\n\n// Output\n// \n// LoadStateNotLoad\n// \n","client.release_partitions(\n collection_name=\"quick_setup\",\n partition_names=[\"_default\", \"partitionA\", \"partitionB\"]\n)\n\nres = client.get_load_state(\n collection_name=\"quick_setup\",\n)\n\n# Output\n#\n# {\n# \"state\": \"\"\n# }\n","# 8. Drop a partition\nclient.drop_partition(\n collection_name=\"quick_setup\",\n partition_name=\"partitionB\"\n)\n\nres = client.list_partitions(collection_name=\"quick_setup\")\nprint(res)\n\n# Output\n#\n# [\"_default\", \"partitionA\"]\n","import io.milvus.v2.service.partition.request.ReleasePartitionsReq;\n\nReleasePartitionsReq releasePartitionsReq = ReleasePartitionsReq.builder()\n .collectionName(\"quick_setup\")\n .partitionNames(List.of(\"_default\", \"partitionA\", \"partitionB\"))\n .build();\n\nclient.releasePartitions(releasePartitionsReq);\n\ngetLoadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nstate = client.getLoadState(getLoadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// false\n","\nawait client.releasePartitions({\n collection_name: \"quick_setup\",\n partition_names: [\"_default\", \"partitionA\", \"partitionB\"]\n})\n\nres = await client.getLoadState({\n collection_name: \"quick_setup\"\n})\n\nconsole.log(res)\n\n// Output\n// \n// {\n// status: {\n// error_code: 'Success',\n// reason: '',\n// code: 0,\n// retriable: false,\n// detail: ''\n// },\n// state: 'LoadStateNotLoad'\n// }\n// \n"],"headingContent":"Manage Partitions","anchorList":[{"label":"管理分区","href":"Manage-Partitions","type":1,"isActive":false},{"label":"分区概述","href":"Overview","type":2,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"列出分区","href":"List-Partitions","type":2,"isActive":false},{"label":"创建分区","href":"Create-Partitions","type":2,"isActive":false},{"label":"检查特定分区","href":"Check-for-a-Specific-Partition","type":2,"isActive":false},{"label":"加载和释放分区","href":"Load--Release-Partitions","type":2,"isActive":false},{"label":"丢弃分区","href":"Drop-Partitions","type":2,"isActive":false},{"label":"常见问题","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/userGuide/manage-partitions.md b/localization/v2.4.x/site/zh/userGuide/manage-partitions.md index f55861b44..4079433dd 100644 --- a/localization/v2.4.x/site/zh/userGuide/manage-partitions.md +++ b/localization/v2.4.x/site/zh/userGuide/manage-partitions.md @@ -132,7 +132,7 @@ client = new M d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

            一旦集合就绪,就可以列出它的分区。

            +

            一旦集合就绪,就可以列出其分区。

            要列出分区,请使用 list_partitions().

            @@ -178,7 +178,7 @@ res = await client.// [ '_default' ] //
  • -

    上述代码片段的输出包括指定 Collections 内分区的名称。

    +

    上述代码片段的输出包括指定 Collection 内分区的名称。

    注释

    如果在集合中设置了字段作为分区键,Milvus 会随集合创建至少64 个分区。在列出分区时,结果可能与上述代码片段的输出不同。

    @@ -287,7 +287,7 @@ res = await client.

    注释

    如果你在一个 Collection 中设置了一个字段作为分区键,Milvus 会负责管理 Collection 中的分区。因此,在尝试创建分区时可能会遇到提示错误。

    -

    有关详情,请参阅使用分区密钥

    +

    有关详细信息,请参阅使用分区密钥

    检查特定分区

    -

    要加载 Collections 的所有分区,只需调用 . loadCollection().要加载 Collections 的特定分区,可使用 loadPartitions().

    +

    要加载 Collections 的所有分区,只需调用 loadCollection().要加载 Collections 的特定分区,可使用 loadPartitions().

    @@ -652,7 +652,7 @@ res = await client."partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionA" ) @@ -663,7 +663,7 @@ res = client.get_load_status( # "state": "<LoadState: Loaded>" # } -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", partition_name="partitionB" ) @@ -820,7 +820,7 @@ res = await client."_default", "partitionA", "partitionB"] ) -res = client.get_load_status( +res = client.get_load_state( collection_name="quick_setup", ) @@ -845,7 +845,7 @@ res = client.get_load_status( d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" > -

    释放分区后,如果不再需要该分区,可以将其丢弃。

    +

    释放分区后,如果不再需要该分区,就可以将其丢弃。

    要丢弃分区,请使用 drop_partition().

    diff --git a/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.json b/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.json index 5cf977df9..763e51268 100644 --- a/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.json +++ b/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.json @@ -1 +1 @@ -{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"10.102.7.3\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"","anchorList":[{"label":"混合搜索","href":"Hybrid-Search","type":1,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"步骤 1:创建多个 AnnSearchRequest 实例","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"步骤 2:配置重排策略","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"步骤 3:执行混合搜索","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"限制","href":"Limits","type":2,"isActive":false},{"label":"常见问题","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType\nimport random\n\n# Connect to Milvus\nconnections.connect(\n host=\"127.0.0.1\", # Replace with your Milvus server IP\n port=\"19530\"\n)\n\n# Create schema\nfields = [\n FieldSchema(name=\"film_id\", dtype=DataType.INT64, is_primary=True),\n FieldSchema(name=\"filmVector\", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors\n FieldSchema(name=\"posterVector\", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors\n\nschema = CollectionSchema(fields=fields,enable_dynamic_field=False)\n\n# Create collection\ncollection = Collection(name=\"test_collection\", schema=schema)\n\n# Create index for each vector field\nindex_params = {\n \"metric_type\": \"L2\",\n \"index_type\": \"IVF_FLAT\",\n \"params\": {\"nlist\": 128},\n}\n\ncollection.create_index(\"filmVector\", index_params)\ncollection.create_index(\"posterVector\", index_params)\n\n# Generate random entities to insert\nentities = []\n\nfor _ in range(1000):\n # generate random values for each field in the schema\n film_id = random.randint(1, 1000)\n film_vector = [ random.random() for _ in range(5) ]\n poster_vector = [ random.random() for _ in range(5) ]\n\n # create a dictionary for each entity\n entity = {\n \"film_id\": film_id,\n \"filmVector\": film_vector,\n \"posterVector\": poster_vector\n }\n\n # add the entity to the list\n entities.append(entity)\n \ncollection.insert(entities)\n","from pymilvus import AnnSearchRequest\n\n# Create ANN search request 1 for filmVector\nquery_filmVector = [[0.8896863042430693, 0.370613100114602, 0.23779315077113428, 0.38227915951132996, 0.5997064603128835]]\n\nsearch_param_1 = {\n \"data\": query_filmVector, # Query vector\n \"anns_field\": \"filmVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_1 = AnnSearchRequest(**search_param_1)\n\n# Create ANN search request 2 for posterVector\nquery_posterVector = [[0.02550758562349764, 0.006085637357292062, 0.5325251250159071, 0.7676432650114147, 0.5521074424751443]]\nsearch_param_2 = {\n \"data\": query_posterVector, # Query vector\n \"anns_field\": \"posterVector\", # Vector field name\n \"param\": {\n \"metric_type\": \"L2\", # This parameter value must be identical to the one used in the collection schema\n \"params\": {\"nprobe\": 10}\n },\n \"limit\": 2 # Number of search results to return in this AnnSearchRequest\n}\nrequest_2 = AnnSearchRequest(**search_param_2)\n\n# Store these two requests as a list in `reqs`\nreqs = [request_1, request_2]\n","from pymilvus import WeightedRanker\n# Use WeightedRanker to combine results with specified weights\n# Assign weights of 0.8 to text search and 0.2 to image search\nrerank = WeightedRanker(0.8, 0.2) \n","# Alternatively, use RRFRanker for reciprocal rank fusion reranking\nfrom pymilvus import RRFRanker\n\nrerank = RRFRanker()\n","# Before conducting hybrid search, load the collection into memory.\ncollection.load()\n\nres = collection.hybrid_search(\n reqs, # List of AnnSearchRequests created in step 1\n rerank, # Reranking strategy specified in step 2\n limit=2 # Number of final search results to return\n)\n\nprint(res)\n","[\"['id: 844, distance: 0.006047376897186041, entity: {}', 'id: 876, distance: 0.006422005593776703, entity: {}']\"]\n"],"headingContent":"Hybrid Search","anchorList":[{"label":"混合搜索","href":"Hybrid-Search","type":1,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"步骤 1:创建多个 AnnSearchRequest 实例","href":"Step-1-Create-Multiple-AnnSearchRequest-Instances","type":2,"isActive":false},{"label":"步骤 2:配置 Rerankers 策略","href":"Step-2-Configure-a-Reranking-Strategy","type":2,"isActive":false},{"label":"步骤 3:执行混合搜索","href":"Step-3-Perform-a-Hybrid-Search","type":2,"isActive":false},{"label":"限制","href":"Limits","type":2,"isActive":false},{"label":"常见问题","href":"FAQ","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.md b/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.md index a3271432e..844e79650 100644 --- a/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.md +++ b/localization/v2.4.x/site/zh/userGuide/search-query-get/multi-vector-search.md @@ -4,7 +4,6 @@ order: 2 summary: 本指南演示如何在 Milvus 中执行混合搜索,并了解结果的重新排序。 title: 混合搜索 --- -

    混合搜索

    自 Milvus 2.4 版起,我们引入了多向量支持和混合搜索框架,这意味着用户可以在一个集合中引入多个向量场(最多 10 个)。不同列中的这些向量代表数据的不同方面,它们来自不同的嵌入模型或经过不同的处理方法。混合搜索的结果会使用重排策略进行整合,如互易等级融合(RRF)和加权评分。要了解有关重新排名策略的更多信息,请参阅重新排名

    +

    自 Milvus 2.4 版起,我们引入了多向量支持和混合搜索框架,这意味着用户可以在一个 Collections 中引入多个向量场(最多 10 个)。不同列中的这些向量代表数据的不同方面,源自不同的 Embeddings 模型或经过不同的处理方法。混合搜索的结果使用 Rerankers 策略进行整合,如互易等级融合(RRF)和加权评分。要了解有关 Rerankers 策略的更多信息,请参阅Reranking

    这一功能在综合搜索场景中特别有用,例如根据图片、声音、指纹等各种属性识别向量库中最相似的人。

    在本教程中,您将学习如何

    • 创建多个AnnSearchRequest 实例,用于不同向量场的相似性搜索;

    • -
    • 配置重排策略,对多个AnnSearchRequest 实例的搜索结果进行组合和重排;

    • +
    • 配置重排策略,对来自多个AnnSearchRequest 实例的搜索结果进行组合和重排;

    • 使用 hybrid_search()方法执行混合搜索。

    -

    本页的代码片段使用PyMilvus ORM 模块与 Milvus 交互。使用新MilvusClient SDK的代码片段将很快发布。

    +

    本页的代码片段使用PyMilvus ORM 模块与 Milvus 进行交互。使用新的MilvusClient SDK的代码片段即将发布。

    准备工作

    在开始混合搜索之前,请确保您有一个包含多个向量字段的集合。目前,Milvus 为每个集合引入了默认的四个向量字段,通过修改proxy.maxVectorFieldNum配置,最多可以扩展到十个。

    -

    下面是一个例子,说明如何创建一个名为test_collection 的集合,其中包含两个向量字段filmVectorposterVector ,并在其中插入随机实体。

    +

    在开始混合搜索之前,请确保您有一个包含多个向量字段的 Collections。目前,Milvus 引入的每个 Collection 默认有四个向量字段,通过修改proxy.maxVectorFieldNum配置,最多可扩展到十个。

    +

    下面是一个示例,说明如何创建一个名为test_collection 的集合,其中包含两个向量字段filmVectorposterVector ,并在其中插入随机实体。

    from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType
     import random
     
     # Connect to Milvus
     connections.connect(
    -host="10.102.7.3", # Replace with your Milvus server IP
    -port="19530"
    +    host="127.0.0.1", # Replace with your Milvus server IP
    +    port="19530"
     )
     
     # Create schema
     fields = [
    -FieldSchema(name="film_id", dtype=DataType.INT64, is_primary=True),
    -FieldSchema(name="filmVector", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors
    -FieldSchema(name="posterVector", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors
    +    FieldSchema(name="film_id", dtype=DataType.INT64, is_primary=True),
    +    FieldSchema(name="filmVector", dtype=DataType.FLOAT_VECTOR, dim=5), # Vector field for film vectors
    +    FieldSchema(name="posterVector", dtype=DataType.FLOAT_VECTOR, dim=5)] # Vector field for poster vectors
     
     schema = CollectionSchema(fields=fields,enable_dynamic_field=False)
     
    @@ -70,9 +69,9 @@ collection = Collection(name="test_collection&quo
     
     # Create index for each vector field
     index_params = {
    -"metric_type": "L2",
    -"index_type": "IVF_FLAT",
    -"params": {"nlist": 128},
    +    "metric_type": "L2",
    +    "index_type": "IVF_FLAT",
    +    "params": {"nlist": 128},
     }
     
     collection.create_index("filmVector", index_params)
    @@ -82,10 +81,10 @@ collection.create_index("posterVector"for _ in range(1000):
    -# generate random values for each field in the schema
    -film_id = random.randint(1, 1000)
    -film_vector = [ random.random() for _ in range(5) ]
    -poster*vector = [ random.random() for * in range(5) ]
    +    # generate random values for each field in the schema
    +    film_id = random.randint(1, 1000)
    +    film_vector = [ random.random() for _ in range(5) ]
    +    poster_vector = [ random.random() for _ in range(5) ]
     
         # create a dictionary for each entity
         entity = {
    @@ -96,10 +95,9 @@ poster*vector = [ random.random() for * # add the entity to the list
         entities.append(entity)
    -
    +    
     collection.insert(entities)
     
    -

    步骤 1:创建多个 AnnSearchRequest 实例 -

    参数:

    • AnnSearchRequest 对象

      代表 ANN 搜索请求的类。每次混合搜索可包含 1 到 1,024 个ANNSearchRequest 对象。

    • data 列表

      -

      要在单个AnnSearchRequest 中搜索的查询向量。目前,该参数只接受包含单个查询向量的列表,例如[[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]] 。今后,该参数将扩展到接受多个查询向量。

    • +

      要在单个AnnSearchRequest 中搜索的查询向量。目前,该参数只接受包含单个查询向量的列表,例如[[0.5791814851218929, 0.5792985702614121, 0.8480776460143558, 0.16098005945243, 0.2842979317256803]] 。今后,该参数将扩展为接受多个查询向量。

    • anns_field (字符串)

      -

      在单个AnnSearchRequest 中使用的向量字段名称。

    • +

      要在单个AnnSearchRequest 中使用的向量字段名称。

    • param (dict)

      单个AnnSearchRequest 的搜索参数字典。这些搜索参数与单向量搜索参数相同。更多信息,请参阅搜索参数

    • limit (int)

      要包含在单个ANNSearchRequest 中的搜索结果的最大数量。

      -

      该参数只影响单个ANNSearchRequest 中返回的搜索结果数,并不决定hybrid_search 调用的最终返回结果。在混合搜索中,最终结果由来自多个ANNSearchRequest 实例的结果组合和重排决定。

    • +

      该参数只影响单个ANNSearchRequest 中返回的搜索结果数,并不决定hybrid_search 调用的最终返回结果。在混合搜索中,最终结果是通过对多个ANNSearchRequest 实例的结果进行组合和 Rerankers 来决定的。

    -

    步骤 2:配置重排策略

    创建AnnSearchRequest 实例后,配置重新排序策略,对结果进行组合和重新排序。目前有两个选项:WeightedRankerRRFRanker 。有关重新排名策略的更多信息,请参阅重新排名

    +

    创建AnnSearchRequest 实例后,配置 Rerankers 策略,对结果进行组合和重排。目前有两个选项:WeightedRankerRRFRanker 。有关重排策略的更多信息,请参阅Rerankers

    • 使用加权评分

      -

      WeightedRanker 用于以指定权重为每个向量场搜索结果分配重要性。如果您将某些向量字段的优先级高于其他向量字段,WeightedRanker(value1, value2, ..., valueN) 可以在合并搜索结果中反映这一点。

      +

      WeightedRanker 用于以指定权重为每个向量场搜索结果分配重要性。如果您将某些向量场的优先级高于其他向量场,WeightedRanker(value1, value2, ..., valueN) 可以在合并搜索结果中反映出来。

      from pymilvus import WeightedRanker
       # Use WeightedRanker to combine results with specified weights
       # Assign weights of 0.8 to text search and 0.2 to image search
      @@ -199,7 +196,6 @@ rerank = WeightedRanker(0.8, 
    • -

    设置好AnnSearchRequest 实例和重排策略后,使用hybrid_search() 方法执行混合搜索。

    +

    设置好AnnSearchRequest 实例和 Rerankers 策略后,使用hybrid_search() 方法执行混合搜索。

    # Before conducting hybrid search, load the collection into memory.
     collection.load()
     
     res = collection.hybrid_search(
    -reqs, # List of AnnSearchRequests created in step 1
    -rerank, # Reranking strategy specified in step 2
    -limit=2 # Number of final search results to return
    +    reqs, # List of AnnSearchRequests created in step 1
    +    rerank, # Reranking strategy specified in step 2
    +    limit=2 # Number of final search results to return
     )
     
     print(res)
     
    -

    参数:

    • reqs 列表

      -

      搜索请求列表,其中每个请求都是一个ANNSearchRequest 对象。每个请求可以对应一个不同的向量场和一组不同的搜索参数。

    • +

      搜索请求列表,其中每个请求都是一个ANNSearchRequest 对象。每个请求可以对应不同的向量场和不同的搜索参数集。

    • rerank 对象

      -

      用于混合搜索的重排策略。可能的值:WeightedRanker(value1, value2, ..., valueN)RRFRanker()

      -

      有关重排策略的更多信息,请参阅重排

    • +

      用于混合搜索的 Rerankers 排序策略。可能的值:WeightedRanker(value1, value2, ..., valueN)RRFRanker()

      +

      有关重排策略的更多信息,请参阅Rerankers

    • limit (int)

      在混合搜索中返回的最终结果的最大数量。

    @@ -258,8 +253,8 @@ limit=2 # Number of >
      -
    • 通常情况下,每个集合默认最多允许 4 个向量字段。不过,您可以选择调整proxy.maxVectorFieldNum 配置,以扩大集合中向量字段的最大数量,每个集合的最大限制为 10 个向量字段。有关更多信息,请参阅 "代理相关配置"

    • -
    • 集合中的部分索引或加载的向量字段将导致错误。

    • +
    • 通常情况下,每个 Collections 默认最多允许 4 个向量字段。不过,您可以选择调整proxy.maxVectorFieldNum 配置,以扩展集合中向量字段的最大数量,每个集合的最大限制为 10 个向量字段。有关更多信息,请参阅 "代理相关配置"

    • +
    • 集合中部分索引或加载的向量字段将导致错误。

    • 目前,混合搜索中的每个AnnSearchRequest 只能携带一个查询向量。

    常见问题

      -
    • 建议在哪些情况下使用混合搜索?

      -

      混合搜索非常适合需要高精确度的复杂情况,尤其是当一个实体可以由多个不同的向量表示时。这适用于同一数据(如一个句子)通过不同的嵌入模型进行处理的情况,或多模态信息(如个人的图像、指纹和声纹)转换成各种向量格式的情况。通过给这些向量分配权重,它们的综合影响可以极大地丰富搜索结果的召回率并提高搜索结果的有效性。

    • +
    • 在哪些情况下推荐使用混合搜索?

      +

      混合搜索非常适合需要高精确度的复杂情况,尤其是当一个实体可以由多个不同向量表示时。这适用于同一数据(如一个句子)通过不同的 Embeddings 模型进行处理的情况,或多模态信息(如个人的图像、指纹和声纹)转换为不同向量格式的情况。通过给这些向量分配权重,它们的综合影响可以极大地丰富召回率,提高搜索结果的有效性。

    • 加权排序器如何对不同向量场之间的距离进行归一化处理?

      -

      加权排序器使用为每个字段分配的权重对向量字段之间的距离进行归一化处理。它根据每个向量场的权重计算其重要性,优先考虑权重较高的向量场。建议在 ANN 搜索请求中使用相同的度量类型,以确保一致性。这种方法可确保被认为更重要的向量对整体排名产生更大的影响。

    • +

      加权排序器使用为每个向量场分配的权重对向量场之间的距离进行归一化处理。它根据权重计算每个向量场的重要性,优先考虑权重较高的向量场。建议在 ANN 搜索请求中使用相同的度量类型,以确保一致性。这种方法可以确保被认为更重要的向量对整体排名有更大的影响。

    • 是否可以使用 Cohere Ranker 或 BGE Ranker 等其他排名器?

      目前只支持所提供的排名器。正在计划在未来的更新中加入其他排名器。

    • -
    • 是否可以同时执行多个混合搜索操作?

      -

      可以,支持同时执行多个混合搜索操作。

    • +
    • 是否可以同时进行多个混合搜索操作?

      +

      可以,支持同时执行多个混合搜索操作符。

    • 能否在多个 AnnSearchRequest 对象中使用相同的向量字段来执行混合搜索?

      从技术上讲,可以在多个 AnnSearchRequest 对象中使用相同的向量字段进行混合搜索。混合搜索并不需要多个向量字段。

    diff --git a/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.json b/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.json index 536c160fa..d5d6e639f 100644 --- a/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.json +++ b/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.json @@ -1 +1 @@ -{"codeList":["# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=CLUSTER_ENDPOINT,\n token=TOKEN \n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"test_collection\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"单向量搜索","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"搜索概述","href":"Overview","type":2,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"基本搜索","href":"Basic-search","type":2,"isActive":false},{"label":"过滤搜索","href":"Filtered-search","type":2,"isActive":false},{"label":"范围搜索","href":"Range-search","type":2,"isActive":false},{"label":"分组搜索","href":"Grouping-search","type":2,"isActive":false},{"label":"搜索参数","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["from pymilvus import MilvusClient\nimport random\n\n# 1. Set up a Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\"\n)\n\n# 2. Create a collection\nclient.create_collection(\n collection_name=\"quick_setup\",\n dimension=5,\n metric_type=\"IP\"\n)\n\n# 3. Insert randomly generated vectors \ncolors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor i in range(1000):\n current_color = random.choice(colors)\n data.append({\n \"id\": i,\n \"vector\": [ random.uniform(-1, 1) for _ in range(5) ],\n \"color\": current_color,\n \"color_tag\": f\"{current_color}_{str(random.randint(1000, 9999))}\"\n })\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=data\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 1000,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(990 more items hidden)\"\n# ]\n# }\n\n# 6.1 Create partitions \nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"red\"\n)\n\nclient.create_partition(\n collection_name=\"quick_setup\",\n partition_name=\"blue\"\n)\n\n# 6.1 Insert data into partitions\nred_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"red\", \"color_tag\": f\"red_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\nblue_data = [ {\"id\": i, \"vector\": [ random.uniform(-1, 1) for _ in range(5) ], \"color\": \"blue\", \"color_tag\": f\"blue_{str(random.randint(1000, 9999))}\" } for i in range(500) ]\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=red_data,\n partition_name=\"red\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n\nres = client.insert(\n collection_name=\"quick_setup\",\n data=blue_data,\n partition_name=\"blue\"\n)\n\nprint(res)\n\n# Output\n#\n# {\n# \"insert_count\": 500,\n# \"ids\": [\n# 0,\n# 1,\n# 2,\n# 3,\n# 4,\n# 5,\n# 6,\n# 7,\n# 8,\n# 9,\n# \"(490 more items hidden)\"\n# ]\n# }\n","import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\nimport com.alibaba.fastjson.JSONObject;\n\nimport io.milvus.v2.client.ConnectConfig;\nimport io.milvus.v2.client.MilvusClientV2;\nimport io.milvus.v2.service.collection.request.CreateCollectionReq;\nimport io.milvus.v2.service.collection.request.GetLoadStateReq;\nimport io.milvus.v2.service.vector.request.InsertReq;\nimport io.milvus.v2.service.vector.response.InsertResp; \n\nString CLUSTER_ENDPOINT = \"http://localhost:19530\";\n\n// 1. Connect to Milvus server\nConnectConfig connectConfig = ConnectConfig.builder()\n .uri(CLUSTER_ENDPOINT)\n .build();\n\nMilvusClientV2 client = new MilvusClientV2(connectConfig); \n\n// 2. Create a collection in quick setup mode\nCreateCollectionReq quickSetupReq = CreateCollectionReq.builder()\n .collectionName(\"quick_setup\")\n .dimension(5)\n .metricType(\"IP\")\n .build();\n\nclient.createCollection(quickSetupReq);\n\nGetLoadStateReq loadStateReq = GetLoadStateReq.builder()\n .collectionName(\"quick_setup\")\n .build();\n\nboolean state = client.getLoadState(loadStateReq);\n\nSystem.out.println(state);\n\n// Output:\n// true\n\n// 3. Insert randomly generated vectors into the collection\nList colors = Arrays.asList(\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\");\nList data = new ArrayList<>();\n\nfor (int i=0; i<1000; i++) {\n Random rand = new Random();\n String current_color = colors.get(rand.nextInt(colors.size()-1));\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\nInsertReq insertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .build();\n\nInsertResp insertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 1000}\n\n// 6.1. Create a partition\nCreatePartitionReq partitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"red\")\n .build();\n\nclient.createPartition(partitionReq);\n\npartitionReq = CreatePartitionReq.builder()\n .collectionName(\"quick_setup\")\n .partitionName(\"blue\")\n .build();\n\nclient.createPartition(partitionReq);\n\n// 6.2 Insert data into the partition\ndata = new ArrayList<>();\n\nfor (int i=1000; i<1500; i++) {\n Random rand = new Random();\n String current_color = \"red\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n} \n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"red\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n\ndata = new ArrayList<>();\n\nfor (int i=1500; i<2000; i++) {\n Random rand = new Random();\n String current_color = \"blue\";\n JSONObject row = new JSONObject();\n row.put(\"id\", Long.valueOf(i));\n row.put(\"vector\", Arrays.asList(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));\n row.put(\"color\", current_color);\n row.put(\"color_tag\", current_color + \"_\" + String.valueOf(rand.nextInt(8999) + 1000));\n data.add(row);\n}\n\ninsertReq = InsertReq.builder()\n .collectionName(\"quick_setup\")\n .data(data)\n .partitionName(\"blue\")\n .build();\n\ninsertResp = client.insert(insertReq);\n\nSystem.out.println(JSONObject.toJSON(insertResp));\n\n// Output:\n// {\"insertCnt\": 500}\n","const { MilvusClient, DataType, sleep } = require(\"@zilliz/milvus2-sdk-node\")\n\nconst address = \"http://localhost:19530\"\n\n// 1. Set up a Milvus Client\nclient = new MilvusClient({address});\n\n// 2. Create a collection in quick setup mode\nawait client.createCollection({\n collection_name: \"quick_setup\",\n dimension: 5,\n metric_type: \"IP\"\n}); \n\n// 3. Insert randomly generated vectors\nconst colors = [\"green\", \"blue\", \"yellow\", \"red\", \"black\", \"white\", \"purple\", \"pink\", \"orange\", \"brown\", \"grey\"]\ndata = []\n\nfor (let i = 0; i < 1000; i++) {\n current_color = colors[Math.floor(Math.random() * colors.length)]\n data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: current_color,\n color_tag: `${current_color}_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nvar res = await client.insert({\n collection_name: \"quick_setup\",\n data: data\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 1000\n// \n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"red\"\n})\n\nawait client.createPartition({\n collection_name: \"quick_setup\",\n partition_name: \"blue\"\n})\n\n// 6.1 Insert data into partitions\nvar red_data = []\nvar blue_data = []\n\nfor (let i = 1000; i < 1500; i++) {\n red_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"red\",\n color_tag: `red_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nfor (let i = 1500; i < 2000; i++) {\n blue_data.push({\n id: i,\n vector: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],\n color: \"blue\",\n color_tag: `blue_${Math.floor(Math.random() * 8999) + 1000}`\n })\n}\n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: red_data,\n partition_name: \"red\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n\nres = await client.insert({\n collection_name: \"quick_setup\",\n data: blue_data,\n partition_name: \"blue\"\n})\n\nconsole.log(res.insert_cnt)\n\n// Output\n// \n// 500\n// \n","# Single vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n # Replace with your query vector\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\n# Convert the output to a formatted JSON string\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 4. Single vector search\nList> query_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nSearchReq searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(3) // The number of results to return\n .build();\n\nSearchResp searchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 4. Single vector search\nvar query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 3, // The number of results to return\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {}\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {}\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {}\n },\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {}\n },\n {\n \"id\": 2,\n \"distance\": 0.5928734540939331,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [[\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\n \"vector\": [\n 0.87928146,\n 0.05324632,\n 0.6312755,\n 0.28005534,\n 0.9542448\n ],\n \"id\": 455\n }\n }\n]]}\n","[\n { score: 1.7463608980178833, id: '854' },\n { score: 1.744946002960205, id: '425' },\n { score: 1.7258622646331787, id: '718' }\n]\n","# Bulk-vector search\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],\n [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]\n ], # Replace with your query vectors\n limit=2, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}} # Search parameters\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 5. Batch vector search\nquery_vectors = Arrays.asList(\n Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f),\n Arrays.asList(0.19886812562848388f, 0.06023560599112088f, 0.6976963061752597f, 0.2614474506242501f, 0.838729485096104f)\n);\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .topK(2)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 5. Batch vector search\nvar query_vectors = [\n [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592],\n [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104]\n]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: query_vectors,\n limit: 2,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 1,\n \"distance\": 1.3017789125442505,\n \"entity\": {}\n },\n {\n \"id\": 7,\n \"distance\": 1.2419954538345337,\n \"entity\": {}\n }\n ], # Result set 1\n [\n {\n \"id\": 3,\n \"distance\": 2.3358664512634277,\n \"entity\": {}\n },\n {\n \"id\": 8,\n \"distance\": 0.5642921924591064,\n \"entity\": {}\n }\n ] # Result set 2\n]\n","// Two sets of vectors are returned as expected\n\n{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\n \"vector\": [\n 0.9533119,\n 0.02538395,\n 0.76714665,\n 0.35481733,\n 0.9845762\n ],\n \"id\": 740\n }\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\n \"vector\": [\n 0.7411156,\n 0.08687937,\n 0.8254139,\n 0.08370924,\n 0.99095553\n ],\n \"id\": 640\n }\n }\n ],\n [\n {\n \"score\": 1.8654699,\n \"fields\": {\n \"vector\": [\n 0.4671427,\n 0.8378432,\n 0.98844475,\n 0.82763994,\n 0.9729997\n ],\n \"id\": 638\n }\n },\n {\n \"score\": 1.8581753,\n \"fields\": {\n \"vector\": [\n 0.735541,\n 0.60140246,\n 0.86730254,\n 0.93152493,\n 0.98603314\n ],\n \"id\": 855\n }\n }\n ]\n]}\n","[\n [\n { score: 2.3590476512908936, id: '854' },\n { score: 2.2896690368652344, id: '59' }\n [\n { score: 2.664059638977051, id: '59' },\n { score: 2.59483003616333, id: '854' }\n ]\n]\n","# 6.2 Search within a partition\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"red\"]\n)\n\nprint(res)\n","// 6.3 Search within partitions\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"red\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 6.2 Search within partitions\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"red\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 16,\n \"distance\": 0.9200337529182434,\n \"entity\": {}\n },\n {\n \"id\": 14,\n \"distance\": 0.4505271911621094,\n \"entity\": {}\n },\n {\n \"id\": 15,\n \"distance\": 0.19924677908420563,\n \"entity\": {}\n },\n {\n \"id\": 17,\n \"distance\": 0.0075093843042850494,\n \"entity\": {}\n },\n {\n \"id\": 13,\n \"distance\": -0.14609718322753906,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1677284,\n \"fields\": {\n \"vector\": [\n 0.9986977,\n 0.17964739,\n 0.49086612,\n 0.23155272,\n 0.98438674\n ],\n \"id\": 1435\n }\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\n \"vector\": [\n 0.6952647,\n 0.13417172,\n 0.91045254,\n 0.119336545,\n 0.9338931\n ],\n \"id\": 1291\n }\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\n \"vector\": [\n 0.3363194,\n 0.028906643,\n 0.6675426,\n 0.030419827,\n 0.9735209\n ],\n \"id\": 1168\n }\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\n \"vector\": [\n 0.9980543,\n 0.36063594,\n 0.66427994,\n 0.17359233,\n 0.94954175\n ],\n \"id\": 1164\n }\n },\n {\n \"score\": 1.0584627,\n \"fields\": {\n \"vector\": [\n 0.7187005,\n 0.12674773,\n 0.987718,\n 0.3110777,\n 0.86093885\n ],\n \"id\": 1085\n }\n }\n ],\n [\n {\n \"score\": 1.8030131,\n \"fields\": {\n \"vector\": [\n 0.59726167,\n 0.7054632,\n 0.9573117,\n 0.94529945,\n 0.8664103\n ],\n \"id\": 1203\n }\n },\n {\n \"score\": 1.7728865,\n \"fields\": {\n \"vector\": [\n 0.6672442,\n 0.60448086,\n 0.9325822,\n 0.80272985,\n 0.8861626\n ],\n \"id\": 1448\n }\n },\n {\n \"score\": 1.7536311,\n \"fields\": {\n \"vector\": [\n 0.59663296,\n 0.77831805,\n 0.8578314,\n 0.88818026,\n 0.9030075\n ],\n \"id\": 1010\n }\n },\n {\n \"score\": 1.7520742,\n \"fields\": {\n \"vector\": [\n 0.854198,\n 0.72294194,\n 0.9245805,\n 0.86126596,\n 0.7969224\n ],\n \"id\": 1219\n }\n },\n {\n \"score\": 1.7452049,\n \"fields\": {\n \"vector\": [\n 0.96419,\n 0.943535,\n 0.87611496,\n 0.8268136,\n 0.79786557\n ],\n \"id\": 1149\n }\n }\n ]\n]}\n","[\n { score: 3.0258803367614746, id: '1201' },\n { score: 3.004319190979004, id: '1458' },\n { score: 2.880324363708496, id: '1187' },\n { score: 2.8246407508850098, id: '1347' },\n { score: 2.797295093536377, id: '1406' }\n]\n","res = client.search(\n collection_name=\"quick_setup\",\n data=[query_vector],\n limit=5,\n search_params={\"metric_type\": \"IP\", \"params\": {\"level\": 1}},\n partition_names=[\"blue\"]\n)\n\nprint(res)\n","searchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .partitionNames(Arrays.asList(\"blue\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","res = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n partition_names: [\"blue\"],\n limit: 5,\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 20,\n \"distance\": 2.363696813583374,\n \"entity\": {}\n },\n {\n \"id\": 26,\n \"distance\": 1.0665391683578491,\n \"entity\": {}\n },\n {\n \"id\": 23,\n \"distance\": 1.066049575805664,\n \"entity\": {}\n },\n {\n \"id\": 29,\n \"distance\": 0.8353596925735474,\n \"entity\": {}\n },\n {\n \"id\": 28,\n \"distance\": 0.7484277486801147,\n \"entity\": {}\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1628494,\n \"fields\": {\n \"vector\": [\n 0.7442872,\n 0.046407282,\n 0.71031404,\n 0.3544345,\n 0.9819991\n ],\n \"id\": 1992\n }\n },\n {\n \"score\": 1.1470042,\n \"fields\": {\n \"vector\": [\n 0.5505825,\n 0.04367262,\n 0.9985836,\n 0.18922359,\n 0.93255126\n ],\n \"id\": 1977\n }\n },\n {\n \"score\": 1.1450152,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.1439825,\n \"fields\": {\n \"vector\": [\n 0.9253267,\n 0.15890503,\n 0.7999555,\n 0.19126713,\n 0.898583\n ],\n \"id\": 1552\n }\n },\n {\n \"score\": 1.1029172,\n \"fields\": {\n \"vector\": [\n 0.95661926,\n 0.18777144,\n 0.38115507,\n 0.14323527,\n 0.93137646\n ],\n \"id\": 1823\n }\n }\n ],\n [\n {\n \"score\": 1.8005109,\n \"fields\": {\n \"vector\": [\n 0.5953582,\n 0.7794224,\n 0.9388869,\n 0.79825854,\n 0.9197286\n ],\n \"id\": 1888\n }\n },\n {\n \"score\": 1.7714822,\n \"fields\": {\n \"vector\": [\n 0.56805456,\n 0.89422905,\n 0.88187534,\n 0.914824,\n 0.8944365\n ],\n \"id\": 1648\n }\n },\n {\n \"score\": 1.7561421,\n \"fields\": {\n \"vector\": [\n 0.83421993,\n 0.39865613,\n 0.92319834,\n 0.42695504,\n 0.96633124\n ],\n \"id\": 1688\n }\n },\n {\n \"score\": 1.7553532,\n \"fields\": {\n \"vector\": [\n 0.89994013,\n 0.052991092,\n 0.8645576,\n 0.6406729,\n 0.95679337\n ],\n \"id\": 1573\n }\n },\n {\n \"score\": 1.7543385,\n \"fields\": {\n \"vector\": [\n 0.16542226,\n 0.38248396,\n 0.9888778,\n 0.80913955,\n 0.9501492\n ],\n \"id\": 1544\n }\n }\n ]\n]}\n","[\n { score: 2.8421106338500977, id: '1745' },\n { score: 2.838560104370117, id: '1782' },\n { score: 2.8134000301361084, id: '1511' },\n { score: 2.718268871307373, id: '1679' },\n { score: 2.7014894485473633, id: '1597' }\n]\n","# Search with output fields\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"] # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 7. Search with output fields\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color\"))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 7. Search with output fields\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n output_fields: [\"color\"],\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 0,\n \"distance\": 1.4093276262283325,\n \"entity\": {\n \"color\": \"pink_8682\"\n }\n },\n {\n \"id\": 16,\n \"distance\": 1.0159327983856201,\n \"entity\": {\n \"color\": \"yellow_1496\"\n }\n },\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {}\n }\n ]\n]}\n","\n[\n { score: 3.036271572113037, id: '59', color: 'orange' },\n { score: 3.0267879962921143, id: '1745', color: 'blue' },\n { score: 3.0069446563720703, id: '854', color: 'black' },\n { score: 2.984386682510376, id: '718', color: 'black' },\n { score: 2.916019916534424, id: '425', color: 'purple' }\n]\n","# Search with filter\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"red%\"'\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color_tag like \\\"red%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"red%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n },\n {\n \"id\": 6,\n \"distance\": -0.4113418459892273,\n \"entity\": {\n \"color\": \"red_9392\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1677284,\n \"fields\": {\"color_tag\": \"red_9030\"}\n },\n {\n \"score\": 1.1476475,\n \"fields\": {\"color_tag\": \"red_3744\"}\n },\n {\n \"score\": 1.0969629,\n \"fields\": {\"color_tag\": \"red_4168\"}\n },\n {\n \"score\": 1.0741848,\n \"fields\": {\"color_tag\": \"red_9678\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'red_8904' },\n { score: 2.491129159927368, id: '425', color_tag: 'purple_8212' },\n { score: 2.4889798164367676, id: '1458', color_tag: 'red_6891' },\n { score: 2.42964243888855, id: '724', color_tag: 'black_9885' },\n { score: 2.4004223346710205, id: '854', color_tag: 'black_5990' }\n]\n","# Infix match on color field\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=5, # Max. number of search results to return\n search_params={\"metric_type\": \"IP\", \"params\": {}}, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n filter='color like \"%ll%\"' # Filter on color field, infix match on \"ll\"\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 8. Filtered search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .filter(\"color like \\\"%ll%\\\"\")\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 8. Filtered search\n// 8.1 Filter with \"like\" operator and prefix wildcard\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n filters: \"color_tag like \\\"%ll%\\\"\",\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 5,\n \"distance\": 0.7972343564033508,\n \"entity\": {\n \"color\": \"yellow_4222\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"yellow_4222\"}\n }\n ]\n]}\n","[\n { score: 2.5080761909484863, id: '1201', color_tag: 'yellow_4222' }\n]\n","# Conduct a range search\nsearch_params = {\n \"metric_type\": \"IP\",\n \"params\": {\n \"radius\": 0.8, # Radius of the search circle\n \"range_filter\": 1.0 # Range filter to filter out vectors that are not within the search circle\n }\n}\n\nres = client.search(\n collection_name=\"quick_setup\", # Replace with the actual name of your collection\n data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],\n limit=3, # Max. number of search results to return\n search_params=search_params, # Search parameters\n output_fields=[\"color\"], # Output fields to return\n)\n\nresult = json.dumps(res, indent=4)\nprint(result)\n","// 9. Range search\nquery_vectors = Arrays.asList(Arrays.asList(0.3580376395471989f, -0.6023495712049978f, 0.18414012509913835f, -0.26286205330961354f, 0.9029438446296592f));\n\nsearchReq = SearchReq.builder()\n .collectionName(\"quick_setup\")\n .data(query_vectors)\n .outputFields(Arrays.asList(\"color_tag\"))\n .searchParams(Map.of(\"radius\", 0.1, \"range\", 1.0))\n .topK(5)\n .build();\n\nsearchResp = client.search(searchReq);\n\nSystem.out.println(JSONObject.toJSON(searchResp));\n","// 9. Range search\nquery_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]\n\nres = await client.search({\n collection_name: \"quick_setup\",\n data: [query_vector],\n limit: 5,\n params: {\n radius: 0.1,\n range: 1.0\n },\n output_fields: [\"color_tag\"]\n})\n\nconsole.log(res.results)\n","[\n [\n {\n \"id\": 4,\n \"distance\": 0.9902134537696838,\n \"entity\": {\n \"color\": \"red_4794\"\n }\n },\n {\n \"id\": 14,\n \"distance\": 0.9803846478462219,\n \"entity\": {\n \"color\": \"green_2899\"\n }\n },\n {\n \"id\": 1,\n \"distance\": 0.8519943356513977,\n \"entity\": {\n \"color\": \"red_7025\"\n }\n }\n ]\n]\n","{\"searchResults\": [\n [\n {\n \"score\": 1.263043,\n \"fields\": {\"color_tag\": \"green_2052\"}\n },\n {\n \"score\": 1.2377806,\n \"fields\": {\"color_tag\": \"purple_3709\"}\n },\n {\n \"score\": 1.1869997,\n \"fields\": {\"color_tag\": \"red_3026\"}\n },\n {\n \"score\": 1.1748955,\n \"fields\": {\"color_tag\": \"black_1646\"}\n },\n {\n \"score\": 1.1720343,\n \"fields\": {\"color_tag\": \"green_4853\"}\n }\n ]\n]}\n","[\n { score: 2.3387961387634277, id: '718', color_tag: 'black_7154' },\n { score: 2.3352415561676025, id: '1745', color_tag: 'blue_8741' },\n { score: 2.290485382080078, id: '1408', color_tag: 'red_2324' },\n { score: 2.285870313644409, id: '854', color_tag: 'black_5990' },\n { score: 2.2593345642089844, id: '1309', color_tag: 'red_8458' }\n]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Group search results\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=[[0.14529211512077012, 0.9147257273453546, 0.7965055218724449, 0.7009258593102812, 0.5605206522382088]], # Query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of groups to return\n group_by_field=\"doc_id\", # Group results by document ID\n group_size=2, # returned at most 2 passages per document, the default value is 1\n group_strict_size=True, # ensure every group contains exactly 3 passages\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_7\", \"doc_7\", \"doc_3\", \"doc_3\", \"doc_2\", \"doc_2\", \"doc_8\", \"doc_8\"]\n[5, 10, 11, 10, 9, 6, 5, 4, 9, 2]\n","# Connect to Milvus\nclient = MilvusClient(uri='http://localhost:19530') # Milvus server address\n\n# Load data into collection\nclient.load_collection(\"group_search\") # Collection name\n\n# Search without `group_by_field`\nres = client.search(\n collection_name=\"group_search\", # Collection name\n data=query_passage_vector, # Replace with your query vector\n search_params={\n \"metric_type\": \"L2\",\n \"params\": {\"nprobe\": 10},\n }, # Search parameters\n limit=5, # Max. number of search results to return\n # group_by_field=\"doc_id\", # Group results by document ID\n # group_size=2, \n # group_strict_size=True,\n output_fields=[\"doc_id\", \"passage_id\"]\n)\n\n# Retrieve the values in the `doc_id` column\ndoc_ids = [result['entity']['doc_id'] for result in res[0]]\npassage_ids = [result['entity']['passage_id'] for result in res[0]]\n\nprint(doc_ids)\nprint(passage_ids)\n","[\"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\", \"doc_11\"]\n[1, 10, 3, 12, 9]\n","# In normal cases, you do not need to set search parameters manually\n# Except for range searches.\nsearch_parameters = {\n 'metric_type': 'L2',\n 'params': {\n 'nprobe': 10,\n 'level': 1,\n 'radius': 1.0\n 'range_filter': 0.8\n }\n}\n"],"headingContent":"Single-Vector Search","anchorList":[{"label":"单向量搜索","href":"Single-Vector-Search","type":1,"isActive":false},{"label":"搜索概述","href":"Overview","type":2,"isActive":false},{"label":"准备工作","href":"Preparations","type":2,"isActive":false},{"label":"基本搜索","href":"Basic-search","type":2,"isActive":false},{"label":"过滤搜索","href":"Filtered-search","type":2,"isActive":false},{"label":"范围搜索","href":"Range-search","type":2,"isActive":false},{"label":"分组搜索","href":"Grouping-search","type":2,"isActive":false},{"label":"搜索参数","href":"Search-parameters","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.md b/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.md index 98e9191f6..5793c9f58 100644 --- a/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.md +++ b/localization/v2.4.x/site/zh/userGuide/search-query-get/single-vector-search.md @@ -23,7 +23,7 @@ title: 单向量搜索

    根据 Collections 中向量场的数量,Milvus 允许您进行两种类型的搜索:

    • 单向量搜索:如果您的 Collections 只有一个向量场,请使用 search()方法来查找最相似的实体。该方法会将您的查询向量与 Collections 中的现有向量进行比较,并返回最匹配的 ID 以及它们之间的距离。作为选项,它还可以返回结果的向量值和元数据。
    • -
    • 混合搜索:对于有两个或更多向量字段的 Collections,可使用 hybrid_search()方法。该方法会执行多个近似近邻(ANN)搜索请求,并在重新排序后将结果组合起来,返回最相关的匹配结果。
    • +
    • 混合搜索:对于有两个或更多向量字段的 Collections,可使用 hybrid_search()方法。该方法会执行多个近似近邻(ANN)搜索请求,并在重新排序后将结果合并以返回最相关的匹配结果。

    本指南主要介绍如何在 Milvus 中执行单向量搜索。有关混合搜索的详细信息,请参阅混合搜索

    搜索概述

    下面的代码片段对现有代码进行了重新利用,以建立与 Milvus 的连接并快速设置 Collections。

    -
    # 1. Set up a Milvus client
    +
    from pymilvus import MilvusClient
    +import random
    +
    +# 1. Set up a Milvus client
     client = MilvusClient(
    -    uri=CLUSTER_ENDPOINT,
    -    token=TOKEN 
    +    uri="http://localhost:19530"
     )
     
     # 2. Create a collection
    @@ -439,7 +441,7 @@ res = await client.search 请求时,您可以提供一个或多个代表查询嵌入的向量值,以及表示要返回结果数量的limit 值。

    -

    根据您的数据和查询向量,您可能会得到少于limit 的结果。当limit 大于查询可能匹配的向量数时,就会出现这种情况。

    +

    根据您的数据和查询向量,您可能会得到少于limit 的结果。当limit 大于您查询的可能匹配向量数时,就会出现这种情况。

    在 Milvus 中,单向量搜索是最简单的search 操作符,用于查找与给定查询向量最相似的向量。

    要执行单矢量搜索,请指定目标 Collections 名称、查询向量和所需结果数 (limit)。该操作会返回一个结果集,其中包括最相似的向量、它们的 ID 和与查询向量的距离。

    下面是搜索与查询向量最相似的前 5 个实体的示例:

    @@ -447,7 +449,7 @@ res = await client.Python Java Node.js
    # Single vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         # Replace with your query vector
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
    @@ -635,13 +637,13 @@ res = await client.

    输出结果会显示与您的查询向量最接近的前 5 个邻居,包括它们的唯一 ID 和计算出的距离。

    批量向量搜索扩展了单向量搜索的概念,允许在单个请求中搜索多个查询向量。这种类型的搜索非常适合需要为一组查询向量查找相似向量的场景,大大减少了所需的时间和计算资源。

    -

    在批量向量搜索中,您可以在data 字段中包含多个查询向量。系统会并行处理这些向量,为每个查询向量返回一个单独的结果集,每个结果集都包含在 Collections 中找到的最接近的匹配结果。

    +

    在批量向量搜索中,您可以在data 字段中包含多个查询向量。系统会并行处理这些向量,为每个查询向量返回一个单独的结果集,每个结果集包含在 Collections 中找到的最接近的匹配结果。

    下面是一个从两个查询向量中搜索最相似实体的两个不同集合的示例:

    # Bulk-vector search
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[
             [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, 0.2614474506242501, 0.838729485096104],
             [0.3172005263489739, 0.9719044792798428, -0.36981146090600725, -0.4860894583077995, 0.95791889146345]
    @@ -1226,7 +1228,7 @@ searchResp = client.search(searchReq);
        Python  Java Node.js
     
    # Search with output fields
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1374,7 +1376,7 @@ res = await client.Python  Java Node.js
     
    # Search with filter
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1481,7 +1483,7 @@ res = await client.Python  Java Node.js
     
    # Infix match on color field
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=5, # Max. number of search results to return
         search_params={"metric_type": "IP", "params": {}}, # Search parameters
    @@ -1582,7 +1584,7 @@ search_params = {
     }
     
     res = client.search(
    -    collection_name="test_collection", # Replace with the actual name of your collection
    +    collection_name="quick_setup", # Replace with the actual name of your collection
         data=[[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]],
         limit=3, # Max. number of search results to return
         search_params=search_params, # Search parameters
    @@ -1699,7 +1701,7 @@ res = await client.HAMMING
    当前字段是否为主字段。将此设置为 True 时,当前字段就是主字段。当前字段是否为主字段。设置为 True 时,当前字段将为主字段。
    fields.elementTypeParams额外的字段参数。额外字段参数。
    fields.elementTypeParams.dim用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有当指定字段是向量字段时才可用。更多信息,请参阅Milvus 支持的索引用于衡量向量间相似性的算法。可能的值有IPL2COSINEJACCARDHAMMING。只有指定字段为向量字段时才可用。更多信息,请参阅Milvus 支持的索引
    params汉明距离越小,相似度越高。要从结果中排除最接近的向量,请确保:
    range_filter <= distance <radius
    -

    要了解有关距离度量类型的更多信息,请参阅 "相似度量"

    +

    要了解有关距离度量类型的更多信息,请参阅相似度量