ããã¯ããªã«ãããããŠæžãããã®ïŒ
åã«å°ãããã¯ãã«ããŒã¿ããŒã¹ã«ã¯ã©ã®ãããªãã®ãããã®ã調ã¹ãŠã¿ãŸããã
ベクトルデータベースってどういうものがある? - CLOVER🍀
ããããããã®äžãããªã«ãéžãã§ããã¯ãã«ããŒã¿ããŒã¹ãšãããã®ãè©ŠããŠã¿ããããªãšæããŸããŠã
Qdrantãè©ŠããŠã¿ãããšã«ããŸããã
Qdrant
Qdrantã®Webãµã€ãã¯ãã¡ãã
GitHubãªããžããªãŒã¯ãã¡ãã
Webãµã€ãã®ãããããŒãžã«ãããšãç¹åŸŽã¯ä»¥äžã®ããã§ãã
- OpenAPI 3ä»æ§ã«æ²¿ã£ãããã¥ã¡ã³ããæäŸããå€ãã®ããã°ã©ãã³ã°èšèªã«å¯Ÿããã¯ã©ã€ã¢ã³ããäœæå¯èœ
- ANN SearchïŒApproximate Nearest Neighbor SearchïŒã®ããã®HNSWã¢ã«ãŽãªãºã ãç¬èªã«ã«ã¹ã¿ã å®è£
- ãã¯ãã«ã«é¢é£ä»ãããããã€ããŒãã®è¿œå ããµããŒããããã€ããŒããä¿åããã ãã§ã¯ãªããã€ããŒãã®å€ã«åºã¥ããŠçµæããã£ã«ã¿ãªã³ã°ããããšãå¯èœ
- æååäžèŽãæ°å€ç¯å²ãå°ççäœçœ®ãªã©ãå«ããæ§ã ãªããŒã¿åãšã¯ãšãªãŒããµããŒã
- åæ£åã§ãæ°Žå¹³ã¹ã±ãŒãªã³ã°ãå¯èœ
- Rustã§å®è£ ãããŠããããªãœãŒã¹ãæå¹æŽ»çšã§ãã
Qdrantã䜿ã£ãæ€çŽ¢ãã©ã®ãããªåéã§äœ¿ããšãããããªã®ãã¯ããã¡ãã®ããŒãžãèŠãã®ãããã§ãããã
Vector Search Solutions - Qdrant
é¡äŒŒç»åæ€çŽ¢ãã»ãã³ãã£ãã¯ããã¹ãæ€çŽ¢ãã¬ã³ã¡ã³ããŒã·ã§ã³ããã£ãããããããããã³ã°ãšã³ãžã³ãç°åžžæ€ç¥ãªã©ã
æããããŠããŸãã
ããã¥ã¡ã³ãã¯ãã¡ãã§ãã
æåã«èªãã®ã¯ãã¡ãã®ããŒãžã§ããããã
ãã£ããèŠãŠã¿ãŸãããã
- Qdrantã¯ããã€ããŒãã®è¿œå ãšä¿åãæ€çŽ¢ã管çã«äŸ¿å©ãªAPIãæäŸãããããã¯ã·ã§ã³ã¬ãã£ãªãã¯ãã«é¡äŒŒæ§æ€çŽ¢ãšã³ãžã³
- ãã¯ãã«ããŒã¿ããŒã¹ã¯ãé«æ¬¡å
ãã¯ãã«ãå¹ççã«ä¿åãã¯ãšãªãŒã§ããããã«èšèšãããããŒã¿ããŒã¹ã®äžçš®
- ãã¯ãã«ããŒã¿ããŒã¹ã§ã¯ããã¯ãã«ã«IDãšãã€ããŒããå ãããã®ãåéãã
- ããã§ããããã¯ãã«ããšã¯ãªããžã§ã¯ããŸãã¯ããŒã¿ãã€ã³ãã®æ°åŠçè¡šçŸãè¡šã
- ãã¯ãã«ããŒã¿ããŒã¹ã§ã¯ãè·é¢ã¡ããªã¯ã¹ã«åºã¥ããŠã®ã¯ãšãªãŒãã¯ãã«ã«æãè¿ããã¯ãã«ãèŠã€ããããšã§ãé«éãªé¡äŒŒæ§æ€çŽ¢ãšã»ãã³ãã£ãã¯æ€çŽ¢ãè¡ããããã«ãªã
- äžè¬çã«äœ¿çšãããè·é¢ã¡ããªã¯ã¹ã¯ããŠãŒã¯ãªããè·é¢ãã³ãµã€ã³é¡äŒŒåºŠããããç©ã®3ã€ã§ãããQdrantã§ã¯ãã¹ãŠãµããŒãããŠãã
- ã³ãµã€ã³é¡äŒŒåºŠ ⊠2ã€ã®ãã®ãã©ãã ã䌌ãŠããã枬å®ããæ¹æ³ïŒè·é¢ã§ã¯ãªãïŒã§ã2ã€ã®ææžãŸãã¯æãäºãã«ã©ãã ã䌌ãŠããããæ¯èŒããããã«ããå©çšããã
- ãããç© âŠ 2ã€ã®ãã®ãã©ãã 䌌ãŠããã枬å®ããæ¹æ³ã§ãæ©æ¢°åŠç¿ãããŒã¿ãµã€ãšã³ã¹ã§æ°å€ãæ±ãæã«ããå©çšãããã2ã»ããã®æ°å€ãã©ãã ãäžèŽããŠãããã瀺ããã®
- ãŠãŒã¯ãªããè·é¢ ⊠å°å³äžã®2ã€ã®å Žæã®è·é¢ã枬å®ããæ¹æ³ã§ã2ã€ã®ããŒã¿ãã€ã³ããã©ã®çšåºŠé¡äŒŒããŠãããããããã¯ç°ãªã£ãŠãããã枬å®ããããšã«ãäž»ã«æ©æ¢°åŠç¿ã§å©çšããã
- äžè¬çã«äœ¿çšãããè·é¢ã¡ããªã¯ã¹ã¯ããŠãŒã¯ãªããè·é¢ãã³ãµã€ã³é¡äŒŒåºŠããããç©ã®3ã€ã§ãããQdrantã§ã¯ãã¹ãŠãµããŒãããŠãã
- Qdrantã®äž»ãªæŠå¿µ
- ã³ã¬ã¯ã·ã§ã³ ⊠æ€çŽ¢ã§ããååä»ãã®ãã€ã³ãïŒãã€ããŒããå«ããã¯ãã«ïŒã®éå
- è·é¢ã¡ããªã¯ã¹ ⊠ãã¯ãã«éã®é¡äŒŒæ§ã枬ãã®ã«äœ¿çšãããã³ã¬ã¯ã·ã§ã³ã®äœææã«æå®ãã
- ãã€ã³ã ⊠Qdrantãæäœããäžå¿çãªãšã³ãã£ãã£ã§ããããã¯ãã«ãšãªãã·ã§ã³ã®idããã³ãã€ããŒãã§æ§æããã
- Points - Qdrant
- id ⊠ãã¯ãã«ã®äžæã®èå¥å
- ãã¯ã㫠⊠ç»åãé³ãããã¥ã¡ã³ãããããªãªã©ã®ããŒã¿ã®é«æ¬¡å è¡šçŸ
- ãã€ããŒã ⊠ãã¯ãã«ã«è¿œå ã§ããJSONãªããžã§ã¯ã
- ã¹ãã¬ãŒãž ⊠Qdrantã®ããŒã¿ã®ä¿åå ã§ãã¡ã¢ãªãšãã£ã¹ã¯ããéžæ
- ã¯ã©ã€ã¢ã³ã ⊠Qdrantãžã®æ¥ç¶ã«äœ¿çšã§ããããã°ã©ãã³ã°èšèª
RDBMSã§ããããŒãã«ãã³ã¬ã¯ã·ã§ã³ã§ãã¬ã³ãŒãããã€ã³ãããšããæãã§ãããããã¯ãšãªãŒã®æŠç¥ã¯ã³ã¬ã¯ã·ã§ã³ã®äœææã«
決ãŸããã®ã¿ããã§ããã
ãã¯ãã«æ€çŽ¢ã®åºæ¬ã¯ããã¡ãã
ããã¯ã次åãŸãèŠãããšæããŸãã
Qdrantã®ã€ã³ã¹ããŒã«æ¹æ³ã¯ãDockerãKubernetesãQdrant CloudããœãŒã¹ã³ãŒãã®ãã«ãã玹ä»ãããŠããŸãã
ãŸããèšèŒã¯ãããŸãããããã«ãæžã¿ã®ãã€ããªãããŠã³ããŒãããŠãè¯ãããã§ãã
Releases · qdrant/qdrant · GitHub
ä»åã¯ããšãããããã«ãæžã¿ã®ãã€ããªãããŠã³ããŒãããŠåãããŠã¿ãããšæããŸãã
ãªãQdrantãïŒ
Qdrantã䜿ãåã«ããã¯ãã«ããŒã¿ããŒã¹ã䜿ã£ãŠã¿ãã«ããããã©ãããŠQdrantãéžãã ã®ããæžããŠãããŸãããã
ãã¯ãã«ããŒã¿ããŒã¹ã«èå³ãæã£ãã®ã¯LLMã®æèã§ããç»å Žãããããšãæçµçã«ã¯RAGãªã©ãè©ŠããŠã¿ããããã§ãã
ãã®æããã€ããªããæ€çŽ¢ãªã©ããã£ãŠã¿ããã®ã§ãæçµçã«ã¯Elasticsearchã®ãããªå
šææ€çŽ¢ãšãã¯ãã«æ€çŽ¢ã®äž¡æ¹ãã§ãã
ããŒã¿ã¹ãã¢ãéžã¶ãããããŸããã
ãšããäžæ¹ã§ããã¯ãã«ããŒã¿ããŒã¹ã«ç¹åããŠããQdrantãéžãã ã®ã¯ä»¥äžã®çç±ã§ãã
- ãã¯ãã«ããŒã¿ããŒã¹ãšããç¥ããªãæŠå¿µãåŠã¶ã®ã§ããã°ããã®åéã«ç¹åãããããã¯ãã®ããã¥ã¡ã³ããªã©ã®æ¹ãæ å ±ãå€ããæ·±ã
- æå ã§åããããã®ã§ãSaaSã§ã¯ãªãã»ã«ããã¹ãã£ã³ã°å¯èœãªãã®ããã
- æçµçã«ã¯Python以å€ããã䜿ãããã®ã§ãçµã¿èŸŒã¿ã¢ãŒãã®ã¿ããµããŒãããŠãããããã¯ãã¯é¿ãããïŒã¯ã©ã€ã¢ã³ãïŒãµãŒããŒåœ¢æ ãå©çšã§ããŠæ¬²ããïŒ
ãã€ããªãããªããŒã¿ã¹ãã¢ããããã¯ãã«ããŒã¿ããŒã¹å°çšã®ãã®ãéžãã§ããã®ã¯ãããã¥ã¡ã³ããªã©ãèŠãããšã«ãã
ãã¯ãã«ããŒã¿ããŒã¹ãã®ãã®ã«å¯Ÿããç解ãæåŸ
ããŠããŸãã
ãã®ãããã®æ¡ä»¶ã§ãã¯ãã«ããŒã¿ããŒã¹ãçºããŠãããããããã ã£ãã®ãQdrantã ã£ããšããããšã§ãã
çŸæç¹ã§ã¯ãŸãã¯ãã¯ãã«ããŒã¿ããŒã¹ã1çš®åŠãã§ã¿ããããããªãšæã£ãŠããã®ã§ãä»ã®ãã¯ãã«ããŒã¿ããŒã¹ã«ç¹åãã
ããŒã¿ã¹ãã¢ãæ±ãäºå®ã¯ãããŸããããå®éã©ããªããã¯Qdrantã觊ã£ãŠã¿ãŠã©ããããèå³ãæã€ãã§ããã
Qdrantã¯åæ£æ§æã«ã§ããããªãšããã«ãèå³ããããŸããããã¡ããŸã§æãåºããã¯ãŸã ããããŸããã
ç°å¢
ä»åã®ç°å¢ã¯ãã¡ããUbuntu Linux 22.04 LTSã§ãã
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy $ uname -srvmpio Linux 5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:33:48 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Qdrantã«ã¢ã¯ã»ã¹ããéã«ãããããPythonã
$ python3 --version Python 3.10.12 $ pip3 --version pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
Qdrantãã€ã³ã¹ããŒã«ãã
ããã§ã¯ãQdrantãã€ã³ã¹ããŒã«ããŸãã
ãã¡ãããææ°ã®ãªãªãŒã¹ãããŠã³ããŒãããŸãã
Releases · qdrant/qdrant · GitHub
$ curl -OL https://github.com/qdrant/qdrant/releases/download/v1.7.3/qdrant-x86_64-unknown-linux-gnu.tar.gz
å±éã
$ tar xvf qdrant-x86_64-unknown-linux-gnu.tar.gz qdrant
ã·ã³ã°ã«ãã€ããªã®ããã§ãã
ããŒãžã§ã³ã
$ ./qdrant --version qdrant 1.7.3
èµ·åã
$ ./qdrant _ _ __ _ __| |_ __ __ _ _ __ | |_ / _` |/ _` | '__/ _` | '_ \| __| | (_| | (_| | | | (_| | | | | |_ \__, |\__,_|_| \__,_|_| |_|\__| |_| Access web UI at http://0.0.0.0:6333/dashboard 2024-01-25T14:41:08.535870Z WARN qdrant::settings: Config file not found: config/config 2024-01-25T14:41:08.535964Z WARN qdrant::settings: Config file not found: config/development 2024-01-25T14:41:08.536773Z INFO storage::content_manager::consensus::persistent: Loading raft state from ./storage/raft_state.json 2024-01-25T14:41:08.614482Z INFO qdrant: Distributed mode disabled 2024-01-25T14:41:08.614537Z INFO qdrant: Telemetry reporting enabled, id: 515698cc-9357-487f-b0d2-c5732767837f 2024-01-25T14:41:08.619827Z INFO qdrant::tonic: Qdrant gRPC listening on 6334 2024-01-25T14:41:08.619867Z INFO qdrant::tonic: TLS disabled for gRPC API 2024-01-25T14:41:08.620446Z WARN qdrant::actix: Static content folder for Web UI './static' does not exist 2024-01-25T14:41:08.621420Z INFO qdrant::actix: TLS disabled for REST API 2024-01-25T14:41:08.621484Z INFO qdrant::actix: Qdrant HTTP listening on 6333 2024-01-25T14:41:08.621500Z INFO actix_server::builder: Starting 1 workers 2024-01-25T14:41:08.621517Z INFO actix_server::server: Actix runtime found; starting in Actix runtime
èµ·åããšãŠãéãã§ãã
Qdrantã䜿çšããããŒãã¯ãã¡ãã«èšèŒããããŸãã
http://localhost:6333ïŒREST APIïŒãhttp://localhost:6333/dashboardïŒWeb UIïŒãhttp://localhost:6334ïŒGRPC APIïŒã®3ã€ã®ããã§ãã
ãªãããã®ãã€ããªã«ã¯Web UIã¯å«ãŸããŠããªãããã§ããDockerã€ã¡ãŒãžã«ã¯å«ãŸããŠããŸããã
Dockerfile
ãèŠãŠã¿ããšãå¥ãªããžããªãŒã«ããããã§ããã
qdrant/Dockerfile at v1.7.3 · qdrant/qdrant · GitHub
https://github.com/qdrant/qdrant/blob/v1.7.3/tools/sync-web-ui.sh
ãã¡ãã§ãã
GitHub - qdrant/qdrant-web-ui: Self-hosted web UI for Qdrant
è¿œå ããŸãããã
ããŠã³ããŒãããŠå±éã
$ curl -LO https://github.com/qdrant/qdrant-web-ui/releases/download/v0.1.20/dist-qdrant.zip $ unzip dist-qdrant.zip
å±éåŸã¯dist
ãã£ã¬ã¯ããªãçŸããŸãããããããã£ã¬ã¯ããªæ§é ã«ãªã£ãŠããŠ
$ tree dist -d dist âââ assets 1 directory
assets
é
äžã«ã¯JavaScriptãCSSãå
¥ã£ãŠããŸãã
dist
çŽäžã¯ãããªæãã§ããã
$ ll dist total 1100 drwxr-xr-x 3 xxxxx xxxxx 4096 Dec 7 16:31 ./ drwxr-x--- 7 xxxxx xxxxx 4096 Jan 28 08:50 ../ drwxr-xr-x 2 xxxxx xxxxx 4096 Dec 7 16:31 assets/ -rw-r--r-- 1 xxxxx xxxxx 15086 Dec 7 16:31 favicon.ico -rw-r--r-- 1 xxxxx xxxxx 1781 Dec 7 16:31 index.html -rw-r--r-- 1 xxxxx xxxxx 8870 Dec 7 16:31 logo192.png -rw-r--r-- 1 xxxxx xxxxx 28384 Dec 7 16:31 logo512.png -rw-r--r-- 1 xxxxx xxxxx 9339 Dec 7 16:31 logo.png -rw-r--r-- 1 xxxxx xxxxx 484 Dec 7 16:31 manifest.json -rw-r--r-- 1 xxxxx xxxxx 239641 Dec 7 16:31 openapi.json -rw-r--r-- 1 xxxxx xxxxx 789035 Dec 7 16:31 qdrant-web-ui.spdx.json -rw-r--r-- 1 xxxxx xxxxx 67 Dec 7 16:31 robots.txt
Qdrantã®ã¹ã¯ãªãããèŠããšããã®dist
ãã£ã¬ã¯ããªã®äžèº«ãstatic
ãšãããã£ã¬ã¯ããªã«å
¥ããã°ããã¿ããã§ãã
$ mkdir static $ mv dist/* static/
Qdrantãèµ·åã
$ ./qdrant
http://[Qdrantãèµ·åããŠãããã¹ã]:6333/dashboard
ã«ã¢ã¯ã»ã¹ãããšãWeb UIãçŸããŸãã
ããã§ãQdrantãµãŒããŒã¯èµ·åã§ããŸããã
Qdrantã®Quickstartãè©Šã
ã§ã¯ãQdrantã䜿ã£ãŠã¿ãŸãããã
ä»åã¯Quickstartã«æ²¿ã£ãŠäœ¿ã£ãŠã¿ãããšæããŸãã
Quickstartã§äœ¿ãããŠããã®ã¯PythonãTypeScriptãRustãJavaã§ãããä»åã¯Pythonã䜿ããŸãã
ã€ã³ã¹ããŒã«æ¹æ³ã¯æžãããŠããªãã®ã§ãPythonã®Qdrantã¯ã©ã€ã¢ã³ãã®GitHubãªããžããªã確èª
GitHub - qdrant/qdrant-client: Python client for Qdrant vector search engine
Qdrantã®OpenAPIå®çŸ©ã«åŸã£ãŠREST APIãåŒã³åºãã¯ã©ã€ã¢ã³ãã®ããã§ãã
ã€ã³ã¹ããŒã«ã
$ pip3 install qdrant-client
ããŒãžã§ã³ã
$ pip3 list Package Version ----------------- ---------- annotated-types 0.6.0 anyio 4.2.0 certifi 2023.11.17 exceptiongroup 1.2.0 grpcio 1.60.0 grpcio-tools 1.60.0 h11 0.14.0 h2 4.1.0 hpack 4.0.0 httpcore 1.0.2 httpx 0.26.0 hyperframe 6.0.1 idna 3.6 numpy 1.26.3 pip 22.0.2 portalocker 2.8.2 protobuf 4.25.2 pydantic 2.5.3 pydantic_core 2.14.6 qdrant-client 1.7.1 setuptools 59.6.0 sniffio 1.3.0 typing_extensions 4.9.0 urllib3 2.1.0
Python Qdrant ClientïŒqdrant-clientïŒã¯1.7.1ã§ãã
ã¡ãªã¿ã«ãqdrant-clientã«ã¯QdrantãµãŒããŒãªãã§åäœããããŒã«ã«ã¢ãŒããšããæ©èœãããã¿ããã§ãã
Python Qdrant Client / Local mode
Qdrantã¯ã©ã€ã¢ã³ãããQdrantãµãŒããŒãžã®æ¥ç¶ã¯ã以äžã®èšè¿°ã§è¡ãããã§ãã
from qdrant_client import QdrantClient client = QdrantClient(host="localhost", port=6333)
ãŸãã¯ã³ã¬ã¯ã·ã§ã³ãäœæããŠã¿ãŸããã³ã¬ã¯ã·ã§ã³ã¯ãã¯ãã«ããŒã¿ïŒãã€ã³ãïŒãä¿åãããã®ã§ããã
``create_collection.py
from qdrant_client import QdrantClient from qdrant_client.http.models import Distance, VectorParams client = QdrantClient(host="localhost", port=6333) client.create_collection( collection_name="test_collection", vectors_config=VectorParams(size=4, distance=Distance.DOT) )
ã³ã¬ã¯ã·ã§ã³åããã¯ãã«ã®ãµã€ãºïŒæ¬¡å æ°ïŒãšè·é¢ã¡ããªã¯ã¹ãæå®ããŠããŸããè·é¢ã¡ããªã¯ã¹ã¯ãããç©ã§ããã
collections / Create collection
å®è¡ã
$ python3 create_collection.py
Web UIãèŠããšãã³ã¬ã¯ã·ã§ã³ãäœæã§ããããšã確èªã§ããŸãã
ã¡ãªã¿ã«ãåãã³ãŒãã2åå®è¡ãããšãšã©ãŒã«ãªããŸããã
$ python3 create_collection.py Traceback (most recent call last): File "/path/to/create_collection.py", line 6, in <module> client.create_collection( File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/qdrant_client.py", line 1669, in create_collection return self._client.create_collection( File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/qdrant_remote.py", line 2161, in create_collection result: Optional[bool] = self.http.collections_api.create_collection( File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/http/api/collections_api.py", line 1118, in create_collection return self._build_for_create_collection( File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/http/api/collections_api.py", line 96, in _build_for_create_collection return self.api_client.request( File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/http/api_client.py", line 74, in request return self.send(request, type_) File "/path/to/venv/lib/python3.10/site-packages/qdrant_client/http/api_client.py", line 97, in send raise UnexpectedResponse.for_response(response) qdrant_client.http.exceptions.UnexpectedResponse: Unexpected Response: 400 (Bad Request) Raw response content: b'{"status":{"error":"Wrong input: Collection `test_collection` already exists!"},"time":0.00003701}'
ãã¯ãã«ãç»é²ããŸããQuickstartã§äœ¿ã£ãŠããã®ã¯ãupsertãšãããã§ã«ãã€ã³ããååšããŠããã°äžæžããããã®ã§ãã
ãã€ã³ããšããã®ã¯ãQdrantãæäœããäžå¿çãªãšã³ãã£ãã£ã§ããããã¯ãã«ãšãªãã·ã§ã³ã®idããã³ãã€ããŒãã§æ§æãããã
ãšãããã®ã§ããã
ãœãŒã¹ã³ãŒãã¯ãã¡ãã
add_vectors.py
from qdrant_client import QdrantClient from qdrant_client.http.models import PointStruct client = QdrantClient(host="localhost", port=6333) operation_info = client.upsert( collection_name="test_collection", wait=True, points=[ PointStruct(id=1, vector=[0.05, 0.61, 0.76, 0.74], payload={"city": "Berlin"}), PointStruct(id=2, vector=[0.19, 0.81, 0.75, 0.11], payload={"city": "London"}), PointStruct(id=3, vector=[0.36, 0.55, 0.47, 0.94], payload={"city": "Moscow"}), PointStruct(id=4, vector=[0.18, 0.01, 0.85, 0.80], payload={"city": "New York"}), PointStruct(id=5, vector=[0.24, 0.18, 0.22, 0.44], payload={"city": "Beijing"}), PointStruct(id=6, vector=[0.35, 0.08, 0.11, 0.44], payload={"city": "Mumbai"}), ] ) print(operation_info)
è¿œå ãããã¯ãã«ã¯ãã³ã¬ã¯ã·ã§ã³ã«æå®ããããã«4次å ã§ãããæåŸã«å®è¡çµæãåºåããŠããŸãã
wait
ã«ããŠããã®ã§ãå€æŽå
容ãå®éã«é©çšããããŸã§åŸ
ã€ããã«ãªããŸãã
å®è¡ã
$ python3 add_vectors.py operation_id=0 status=<UpdateStatus.COMPLETED: 'completed'>
Web UIã§ã®ç¢ºèªã
次ã¯æ€çŽ¢ããŠã¿ãŸãã
run_query.py
from qdrant_client import QdrantClient client = QdrantClient(host="localhost", port=6333) search_results = client.search( collection_name="test_collection", query_vector=[0.2, 0.1, 0.9, 0.7], limit=3 ) for result in search_results: print(result)
çµæã¯ScoredPoint
ãšããã¯ã©ã¹ã®ãªã¹ããšããŠè¿ã£ãŠããããã§ãã
å®è¡ã
$ python3 run_query.py id=4 version=0 score=1.362 payload={'city': 'New York'} vector=None shard_key=None id=1 version=0 score=1.273 payload={'city': 'Berlin'} vector=None shard_key=None id=3 version=0 score=1.208 payload={'city': 'Moscow'} vector=None shard_key=None
ã³ã¬ã¯ã·ã§ã³ã«æå®ããŠããè·é¢ã¡ããªã¯ã¹ããããç©ãªã®ã§ãæ€çŽ¢æ¡ä»¶ã«æå®ãããã¯ãã«ã«ã䌌ãŠããããã®ã®äžäœ3件ïŒäŒŒãŠãããã®ã®
éé ïŒãååŸã§ããããšããããšã«ãªã£ãŠããããã§ãã
ããã©ã«ãã§ã¯ãã€ããŒãããã³ãã¯ãã«ã¯çµæã«å«ãŸããªãããã§ãïŒãã€ããŒãã¯è¿ã£ãŠããŠããŸããâŠïŒã
æåŸã«ãæ€çŽ¢æã«ãã€ããŒãã«ãã£ã«ã¿ãŒãå ããŠçµæãçµã蟌ã¿ãŸãã
add_filter.py
from qdrant_client import QdrantClient from qdrant_client.http.models import FieldCondition, Filter, MatchValue client = QdrantClient(host="localhost", port=6333) search_results = client.search( collection_name="test_collection", query_vector=[0.2, 0.1, 0.9, 0.7], query_filter=Filter( must=[FieldCondition(key="city", match=MatchValue(value="London"))] ), with_payload=True, limit=3 ) for result in search_results: print(result)
city
ããŒã®å€ã«Longon
ãå«ããã®ã«çµã蟌ãã§ããŸãã
å®è¡ã
$ python3 add_filter.py id=2 version=0 score=0.871 payload={'city': 'London'} vector=None shard_key=None
å®éã«ãã£ã«ã¿ãŒã䜿ãæã¯ããã€ããŒãã«ã€ã³ããã¯ã¹ãäœæããããšãæšå¥šããŠããããã§ãã
To make filtered search fast on real datasets, we highly recommend to create payload indexes!
ãããŸã§ã§ãQuickstartã®å 容ã¯çµããã§ãã
ãããã«
ãŸãã¯Quickstartããªãã£ãã ãã§ãããå°ãé°å²æ°ã¯ããã£ãæ°ãããŸãã
ããããå°ããã€ãã¯ãã«ããŒã¿ããŒã¹ã«æ £ããŠãããã°ããããªãšæããŸãã