單節(jié)點快速入門
本文中含有需要您注意的重要提示信息,忽略該信息可能對您的業(yè)務(wù)造成影響,請務(wù)必仔細閱讀。
本文為您介紹如何購買OpenSearch向量檢索版單節(jié)點實例。
購買實例
進入OpenSearch控制臺,在左上角切換到OpenSearch-向量檢索版:然后在實例列表界面,單擊創(chuàng)建實例:
商品版本選擇向量檢索版,選擇地區(qū),配置“數(shù)據(jù)節(jié)點數(shù)量”、“數(shù)據(jù)節(jié)點規(guī)格”、“單數(shù)據(jù)節(jié)點總存儲空間”,設(shè)置“專有網(wǎng)絡(luò)”和“虛擬交換機”,最后按提示要求設(shè)置用戶名和用戶密碼(用于查詢時校驗權(quán)限,非阿里云賬號密碼),單擊“立即購買”:
說明購買的數(shù)據(jù)節(jié)點的個數(shù)及規(guī)格,需根據(jù)自身業(yè)務(wù)進行規(guī)劃,確定規(guī)格后實際費用可在售賣頁自動生成。
單節(jié)點方案,可不購買查詢節(jié)點(即查詢節(jié)點數(shù)量為0),查詢節(jié)點規(guī)格族不生效。
專有網(wǎng)絡(luò)和虛擬交換的配置一定要和訪問向量檢索版實例的ECS機器保持一致。否則在訪問向量檢索版實例時會報錯{'errors':{'code':'403','message':'Forbidden'}}。
數(shù)據(jù)節(jié)點規(guī)格族SSD盤有50G的免費額度,額外額度按步長50GB收費;云盤型無免費額度,額度按步長50GB收費。
在確認訂單界面,查看服務(wù)協(xié)議,確認無誤后,單擊立即開通:
購買成功后,單擊管理控制臺,即可在實例列表界面查看已購買的向量檢索版實例:
配置實例
新購買的實例,在其詳情頁中,實例狀態(tài)為“待配置”,并且會自動部署一個與購買的數(shù)據(jù)節(jié)點的個數(shù)及規(guī)格一致的空實例,之后需要為該實例配置表信息>數(shù)據(jù)同步>字段配置>索引結(jié)構(gòu),之后等待索引重建完成即可正常搜索。
1. 表基礎(chǔ)信息
表管理單擊“添加表",輸入表名稱,設(shè)置數(shù)據(jù)分片數(shù)和數(shù)據(jù)更新資源數(shù),選擇需要的場景模板,單擊下一步:
配置說明:
表名稱:可自定義。
數(shù)據(jù)分片數(shù):由于是單節(jié)點實例,固定默認值為1,不可變更;當前實例僅支持單分片方案,可通過擴容支持多節(jié)點,詳情可見擴縮容文檔。
數(shù)據(jù)更新資源數(shù):數(shù)據(jù)更新所用資源數(shù),每個索引默認免費提供2個4核8G的更新資源,超出免費額度的資源將產(chǎn)生費用,詳情可參考向量檢索版計費概述
場景模板:向量檢索版內(nèi)置了3種模板可供用戶選擇:通用、向量-圖片搜索、向量-文本語義模板。
2. 數(shù)據(jù)同步
配置數(shù)據(jù)源(目前支持的數(shù)據(jù)源有OSS、MaxCompute數(shù)據(jù)源和API推送數(shù)據(jù)源),這里以MaxCompute數(shù)據(jù)源為例,數(shù)據(jù)源類型選擇MaxCompute,設(shè)置Project、AccesskeyID、AccesskeySecret、Table、分組鍵partition、時間戳,可按需選擇是否開啟“自動索引重建”選擇完成之后可選擇校驗,通過后可單擊下一步:
3. 字段配置
OpenSearch會根據(jù)您選擇的場景模板,預(yù)置相關(guān)字段,并會將全量數(shù)據(jù)來源中的字段(如有),自動導(dǎo)入字段列表中:
設(shè)置字段,必須包含至少兩個字段,主鍵字段和向量字段(向量字段需要設(shè)置為多值float類型):
如果需要帶有命名空間的向量,可以在主鍵和向量字段中間加一個命名空間字段。
字段配置說明:
必選字段:主鍵字段和向量字段,主鍵字段為int或string類型并且需要勾選主鍵按鈕,向量字段為float類型并且需要勾選向量字段按鈕;
向量字段默認為多值的float類型,多值分隔符默認使用系統(tǒng)默認分割符^] 進行切分(其對應(yīng)utf編碼為\x1D),也可以輸入自定義多值分隔符
使用向量檢索,在定義字段時有位置要求,需要按照主鍵字段、命名空間字段(非必要)、向量字段的順序創(chuàng)建。(如上圖所示)
當數(shù)據(jù)中缺少字段或字段為空時,系統(tǒng)將自動補充默認值,數(shù)字類型默認補0,STRING類型默認補空字符串,支持自定義默認值
4. 索引結(jié)構(gòu)
4.1. 向量索引
OpenSearch會對主鍵與向量字段自動構(gòu)建索引,索引名與字段名相同,只需要在控制臺配置向量索引:
高級配置,向量索引需要單獨配置參數(shù),詳情可參考向量索引通用配置
主鍵字段、向量字段必須填寫,命名空間字段非必填,可以為空。
僅支持選擇固定的三個字段,不支持新增。
系統(tǒng)自動填充向量索引的配置參數(shù),如無特殊需求,可直接單擊「下一步」快速完成配置。
命名空間字段:實例引擎版本為vetcor service 1.0.2及以下版本,namespace標簽字段不支持string格式類型;實例引擎版本為vetcor service 1.0.2及以上版本,無此限制。
5. 確認創(chuàng)建
索引配置完成后,單擊「確認創(chuàng)建」;可以看到表狀態(tài)在創(chuàng)建中,如下圖所示。
6. 變更歷史
實例管理-變更歷史,可以看到近3天、7天、30天變更記錄,例如:創(chuàng)建表、新增索引、擴容及全量的所有流程,如下截圖時創(chuàng)建表的過程;全部完成之后引擎搭建完成,可以開始查詢測試:
7. 查詢測試
查詢示例:
{
"vector": [0.0019676427,0.005902928,0.021644069,0.21644068,0.12199384,0.043288138,0.007870571,0.0,0.08460863,0.041320495,0.043288138,0.035417568,0.011805856,0.055093993,0.12592913,0.017708784,0.021644069,0.0019676427,0.0,0.0,0.0019676427,0.078705706,0.1987319,0.041320495,0.039352853,0.0039352854,0.007870571,0.0039352854,0.0039352854,0.017708784,0.035417568,0.06886749,0.0019676427,0.0019676427,0.013773498,0.049191065,0.2125054,0.22824654,0.123961486,0.0039352854,0.0,0.0,0.021644069,0.14560555,0.078705706,0.1987319,0.22824654,0.005902928,0.064932205,0.0019676427,0.0019676427,0.021644069,0.027546996,0.035417568,0.22824654,0.22824654,0.1337997,0.023611711,0.009838213,0.007870571,0.0039352854,0.0039352854,0.017708784,0.20069954,0.033449925,0.005902928,0.019676426,0.035417568,0.015741142,0.029514639,0.13183205,0.123961486,0.029514639,0.0,0.027546996,0.22824654,0.15741141,0.0,0.0039352854,0.043288138,0.18889369,0.072802775,0.055093993,0.17315255,0.08460863,0.0019676427,0.007870571,0.035417568,0.22824654,0.10034977,0.009838213,0.021644069,0.062964566,0.027546996,0.015741142,0.04525578,0.086576276,0.033449925,0.023611711,0.017708784,0.0,0.0,0.03738521,0.072802775,0.16724962,0.035417568,0.031482283,0.20463483,0.043288138,0.011805856,0.0039352854,0.051158708,0.023611711,0.11412327,0.13183205,0.16134669,0.049191065,0.023611711,0.0039352854,0.0039352854,0.049191065,0.035417568,0.015741142,0.0039352854,0.03738521,0.08264099,0.094446845,0.021644069],
"topK": 10,
"includeVector": true
}
vector:具體要查詢的向量
topK:取top K個結(jié)果
是否返回文檔中的向量信息
結(jié)果演示:
詳細的查詢語法可參考下文的語法說明。
語法說明
SDK中使用向量檢索
查詢數(shù)據(jù)(通過SDK進行向量、主鍵查詢)
更新數(shù)據(jù)(通過SDK進行add、delete記錄)
單節(jié)點升級多節(jié)點
如果需要將一個單節(jié)點,升級多節(jié)點,可參考下面操作:
單節(jié)點升級多節(jié)點變更期間實例不可用,具體變更進度可在變更歷史頁中查看相應(yīng)的流程進度:
在“實例列表”界面,實例列表頁中找到對應(yīng)的實例,在右側(cè)“操作”欄中單擊"擴/縮容":
在變配頁中選擇具體需要擴/縮容的查詢節(jié)點數(shù)量、規(guī)格,和勾選“服務(wù)協(xié)議”后單擊立即購買即可。