[Milvus] Entity
์ด์ ํฌ์คํธ
https://blog.naver.com/sssang97/223844460930
Entity๋ Collection์ ์ํ ๊ฐ ๋ฐ์ดํฐ ํ์ ๋ปํ๋ค. ๊ทธ๋ฅ ๋ฒกํฐ๋ผ๊ณ ๋ ๋ถ๋ฅธ๋ค.
Entity ์ฝ์
insert ๋ช ๋ น์ ์ฌ์ฉํ๋ฉด ์ฝ์ ๊ฒธ ์ญ์ ๋ฅผ ๋์์ batch๋ก ์ฒ๋ฆฌํ ์ ์๋ค.
###
POST http://{{HOST}}:{{PORT}}/v2/vectordb/entities/insert
Content-Type: application/json
{
"dbName": "test_db",
"collectionName": "test_collection",
"data": [
{
"id": 1,
"vector": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]
},
{
"id": 2,
"vector": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
}
]
}
###
์ด๋ฌ๋ฉด ์ฑ๊ณต ์๋ต๊ณผ ํจ๊ป id ๋ชฉ๋ก์ด ๋ฐํ๋๋ค.
๋ด ๊ฒฝ์ฐ์๋ ๋์ ํ๋๋ฅผ ํ์ฑํํด์ ์ธ์ ๋ ์ถ๊ฐ ํ๋๋ฅผ ๋ฐ์ดํฐ์ ์ง์ด๋ฃ์ ์ ์์๋ค.
๊ทธ๋ฆฌ๊ณ , ๋์ผํ ๊ธฐ๋ณธํค๋ก ๊ฐ์ insertํ๋ฉด ๊ธฐ์กด ๊ฐ์ ๋์ฒดํ๋ค. ๊ทธ๋ฌ๋๊น update ๊ธฐ๋ฅ๋ ๊ฒธํ๋ ์
์ด๋ค.

ID๋ก Entity ์กฐํ
ID๋ก ํน์ ์ํฐํฐ๋ฅผ ์กฐํํ๊ณ ์ถ๋ค๋ฉด, get API๋ฅผ ์ธ ์ ์๋ค.
###
POST http://{{HOST}}:{{PORT}}/v2/vectordb/entities/get
Content-Type: application/json
{
"dbName": "test_db",
"collectionName": "test_collection",
"id": [1, 2]
}
###
๊ฐ๋จํ๋ค.
Entity ํํฐ ์กฐํ
milvus๋ ๋ฒกํฐ ๊ฒ์ ์ธ์๋, Elasticsearch์ฒ๋ผ ๋จ์ ํํฐ์ ๋ํด์๋ ๊ฝค ๋ฐ์ด๋ ์ฑ๋ฅ์ ๋ณด์ฌ์ค ์ ์๋ค. ์ธ๋ฑ์ค๋ฅผ ๊ฑด๋ค๋ ๊ฐ์ ํ์์ ๋ง์ด๋ค.
query API๋ฅผ ์ฌ์ฉํ๋ฉด ๋จ์ ํํฐ์ ๊ธฐ๋ฐํ ์กฐํ๋ฅผ ์ํํ ์ ์๋ค.
###
POST http://{{HOST}}:{{PORT}}/v2/vectordb/entities/query
Content-Type: application/json
{
"dbName": "test_db",
"collectionName": "test_collection",
"filter": "color == 'red'"
}
###
filter๋ผ๋ ํ๋ ์์๋ค๊ฐ ์๊ธฐ๋ค๋ง์ ํน์ํ ํํ์์ ์์ฑํด์ ์ง์ด๋ฃ์ผ๋ฉด ๋๋ค.
ํํฐ ๋ฌธ๋ฒ์ ๋ํ ์์ธ๋ ๋ณ๋ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ๋ค.
https://milvus.io/docs/boolean.md
Entity ๋ฒกํฐ ์ ์ฌ๋ ๊ฒ์
๋ฒกํฐ ์ ์ฌ๋ ๊ฒ์์ ํ๊ณ ์ถ๋ค๋ฉด search API๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
###
POST http://{{HOST}}:{{PORT}}/v2/vectordb/entities/search
Content-Type: application/json
{
"dbName": "test_db",
"collectionName": "test_collection",
"data": [
[
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.7
]
]
}
###
๊ธฐ๋ณธ์ ์ธ ์ฌ์ฉ๋ฒ์ ์ด๋ ต์ง ์๋ค. ๊ทธ๋ฅ ๋ฒกํฐ ๊ฐ์ ํ๋ ๋๊ฒจ์ ๋๋ฆฌ๋ฉด ๋๋ค.
๋ฒกํฐ ๊ฒ์๊ณผ ํจ๊ป ํํฐ๋ฅผ ์กฐํฉํ ์๋ ์๋ค.
์ด๊ฒ๋ ์ ์ฑ๋ฅ์ ๋ด๋ ค๋ฉด ์ธ๋ฑ์ค๋ฅผ ๊ตฌ์ฑํด์ผ ํ๋ค.
์ฐธ์กฐ
https://milvus.io/api-reference/restful/v2.5.x/v2/Vector%20(v2)/Search.md
https://milvus.io/docs/insert-update-delete.md