跳到主要内容

智慧化数据检索-C++

场景介绍

智慧化数据检索可用于文件整理,文件搜索等场景,例如:关键词检索、语义检索(文搜文)和跨模态检索(文搜图)。智慧化数据检索通过召回和重排两个阶段实现:

  • 召回是指通过不同的策略或算法从海量数据中快速筛选出候选结果集。这些策略可针对不同的特征、模型或者数据来源,旨在尽可能覆盖各种潜在场景。ArkData提供了向量召回的能力,并支持灵活的条件过滤。
  • 重排是针对召回得到的候选结果集进行二次筛选,通过简单规则或者更复杂的模型(如机器学习或深度学习模型)计算各个结果的相关性分数,并重新排列顺序。

向量检索召回

向量召回是通过将用户查询转化为向量(需使用嵌入模型进行向量化处理)来检索相似向量,从而实现语义相近内容的召回。向量近似的阈值在召回配置中设定。

排序模块

排序模块包括对结果进行分档以及档内排序,使用的算法有RRF和分数融合排序。

对结果进行分档

以召回结果作为输入,基于召回的特征值或者召回分数,实现召回结果的相关性分档。档位共三个,分为高、中、低档位,供业务对最终检索结果相关性进行判断。

对于向量召回,基于配置的一个或多个向量分数阈值对档位进行划分,当文档的向量分数大于等于某档位的阈值时,则划分至该档位。向量分数阈值是由1个或2个范围在[0,1]的数字组成。向量分数阈值有两个值时,分别表示高档位和中档位的阈值,向量分数小于中档位阈值则均为低档位;阈值有一个值时,该值表示高档位阈值,向量分数小于该值则均为低档位,无中档位。

约束限制

  • 当前只支持基于向量数据库的召回。
  • 查询词长度不超过512字符。

接口说明

名称描述
int OH_Retrieval_CreateRetriever (const OH_Retrieval_Config *config, OH_Retrieval_Retriever **retriever)获取检索器。
int OH_Retrieval_DestroyRetriever (OH_Retrieval_Retriever *retriever)销毁通过OH_Retrieval_CreateRetriever获得的检索器。
OH_Retrieval_Config * OH_Retrieval_CreateConfig ()获取检索器配置。
int OH_Retrieval_DestroyConfig (OH_Retrieval_Config *config)销毁通过OH_Retrieval_CreateConfig获得的检索配置。
OH_Retrieval_DbConfig * OH_Retrieval_CreateDbConfig ()创建一个配置项以打开数据库。
int OH_Retrieval_DestroyDbConfig (OH_Retrieval_DbConfig *dbConfig)销毁OH_Retrieval_CreateDbConfig创建的OH_Retrieval_DbConfig
int OH_Retrieval_SetDbConfig (OH_Retrieval_DbConfig *dbConfig, OH_Rdb_ConfigV2*rdbConfig)设置OH_Retrieval_DbConfig中的数据库配置。
int OH_Retrieval_AddConfig (OH_Retrieval_Config *config, Retrieval_Channel_Type channelType, OH_Retrieval_DbConfig *dbConfig)设置OH_Retrieval_Config中的数据库配置。
int OH_Retrieval_Retrieve (const OH_Retrieval_Retriever *retriever, const OH_Retrieval_Query *query, const OH_Retrieval_Condition *condition, void *context, const OH_Retrieval_Callback *callback)执行检索。获得检索器句柄后,输入检索查询词,根据检索条件执行检索,得到检索结果。
OH_Retrieval_Condition * OH_Retrieval_CreateCondition ()创建检索条件,作为检索接口的入参。
int OH_Retrieval_DestroyCondition (OH_Retrieval_Condition *condition)销毁通过OH_Retrieval_CreateCondition获得的检索条件。
int OH_Retrieval_DestroySubCondition (OH_Retrieval_SubCondition *condition)销毁OH_Retrieval_SubCondition对象。
int OH_Retrieval_AddSubCondition (OH_Retrieval_Condition *condition, OH_Retrieval_SubCondition *subCondition)在检索条件中,增加子检索条件。
OH_Retrieval_VectorCondition * OH_Retrieval_CreateVectorCondition ()创建向量检索条件。
int OH_Retrieval_DestroyVectorCondition (OH_Retrieval_VectorCondition *condition)销毁通过OH_Retrieval_CreateVectorCondition获得的检索条件。
int OH_Retrieval_SetVectorRecallLimit (OH_Retrieval_VectorCondition *condition, uint32_t limit)在检索条件中,设置向量检索结果数量上限1000。
int OH_Retrieval_SetSimilarityThreshold (OH_Retrieval_VectorCondition *condition, double threshold)在检索条件中,设置向量检索的相似度阈值。
OH_Retrieval_Query * OH_Retrieval_CreateQuery ()创建检索词,作为检索接口的入参。
int OH_Retrieval_DestroyQuery (OH_Retrieval_Query *query)销毁通过OH_Retrieval_CreateQuery获得的检索词。
int OH_Retrieval_SetOriginalQuestion (OH_Retrieval_Query *query, const char *question)设置OH_Retrieval_Query中的检索词。
int OH_Retrieval_DestroyRecord (OH_Retrieval_Record *record)销毁通过检索接口OH_Retrieval_Retrieve获得的检索结果。
int OH_Retrieval_GetRecordLength (const OH_Retrieval_Record *record, uint32_t *length)获取检索结果OH_Retrieval_Record中的数据库bucket数组长度。
int OH_Retrieval_GetRecordItem (const OH_Retrieval_Record *record, uint32_t index, const OH_Retrieval_RecordItem **item)获取检索结果OH_Retrieval_Record中的数据库bucket数组。
int OH_Retrieval_GetItemSize (const OH_Retrieval_RecordItem *items, const char *fieldName, size_t *size)获取数据库bucket数组OH_Retrieval_RecordItem中指定字段的值的size。size值包含结束符。
int OH_Retrieval_GetItemText (const OH_Retrieval_RecordItem *items, const char *fieldName, char *value, size_t size)获取数据库bucket数组OH_Retrieval_RecordItem中指定字段的值。

开发步骤

  1. 在CMake脚本中链接动态库。

    find_library(aip_retrieval_ndk libnative_aip_retrieval_ndk.z.so)
    target_link_libraries(
    entry
    PUBLIC
    libace_napi.z.so
    ${aip_retrieval_ndk}
    )
  2. 导入头文件。

    #include "dataaugmentation/retrieval/aip_retrieval.h"
    #include "dataaugmentation/retrieval/aip_retrieval_condition.h"
    #include "dataaugmentation/retrieval/aip_retrieval_condition_vector.h"
    #include "dataaugmentation/retrieval/aip_retrieval_query.h"
    #include "dataaugmentation/retrieval/aip_retrieval_record.h"
    #include "dataaugmentation/aip_error_code.h"
  3. 初始化数据。

    RdbHelper::DeleteRdbStore("/data/test/rdb/vector_test.db");
    RdbStoreConfig vectorConfig("/data/test/rdb/vector_test.db");
    vectorConfig.SetIsVector(true);
    TestOpenDbCallback helper;
    int errCode = OHOS::NativeRdb::E_OK;
    int version = 2;
    std::shared_ptr<RdbStore> vectorStore = RdbHelper::GetRdbStore(vectorConfig, version, helper, errCode);
    std::string sqlCreateVectorTable = "CREATE TABLE IF NOT EXISTS vector ("
    "fileid TEXT PRIMARY KEY,"
    "filename_text TEXT,"
    "filename FLOATVECTOR(128),"
    "keywords_text TEXT,"
    "keywords FLOATVECTOR(128),"
    "chapter FLOATVECTOR(128),"
    "abstract FLOATVECTOR(128),"
    "int64_value BIGINT,"
    "double_value DOUBLE,"
    "bool_value BOOLEAN,"
    "blob_value BLOB"
    ");";
    auto createTablePair = vectorStore->Execute(sqlCreateVectorTable);

    std::string sqlInsertVector1 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract, int64_value, double_value, bool_value, blob_value) VALUES ('0', '运动直播场景', '[0.006954,-0.079041,0.046173,0.157959,-0.017212,0.037018,-0.072083,-0.028488,-0.099854,0.044037,-0.008911,-0.063049,0.035950,-0.105835,0.057739,0.060364,-0.062042,0.044159,0.143188,0.123901,-0.069641,-0.061920,-0.086731,-0.092468,0.092957,-0.027649,-0.005497,-0.039276,0.017502,-0.046570,-0.115906,0.081177,-0.153931,-0.040588,0.123474,-0.099060,0.062042,0.026352,-0.041382,-0.099548,0.071167,-0.120850,0.082642,0.026398,-0.035614,-0.008545,-0.076660,-0.031067,0.192017,-0.052582,0.005310,0.052734,0.199463,0.075195,-0.070740,-0.035950,0.073120,0.089172,0.075989,0.003582,0.050201,-0.012787,0.016647,-0.053619,0.001906,-0.060181,-0.068359,-0.114502,-0.045013,0.004547,-0.004673,-0.148071,0.126343,0.019394,-0.063110,-0.055908,0.071228,0.002369,0.041412,0.126709,-0.053467,0.127808,0.055420,0.206177,0.002169,-0.001452,0.095520,-0.042511,0.099243,-0.164185,0.093384,-0.014618,-0.129150,-0.238770,-0.085327,0.051300,-0.020004,0.010063,-0.084351,-0.003567,0.064941,-0.205322,-0.158936,-0.074768,0.104370,0.197021,-0.080688,-0.066772,-0.036346,0.034912,-0.019760,0.110474,0.128662,0.094727,0.024948,-0.033356,-0.081848,0.054474,-0.065857,-0.156494,0.002527,0.097595,-0.027420,0.039185,0.063965,0.220093,0.029556,-0.115417]', '运动,相机,直播,华为,外设', '[0.017029,0.008209,-0.037292,0.218262,0.066895,0.142944,-0.032501,-0.015961,-0.097229,-0.095398,-0.065186,-0.048401,0.000182,-0.118896,-0.036743,0.041534,-0.122742,0.118591,0.140869,0.009567,-0.059875,0.007156,-0.098999,-0.044861,0.000140,0.096985,-0.149658,0.002346,0.018112,0.052338,-0.046265,0.119690,-0.048737,0.001713,0.072937,-0.079346,-0.012535,0.032623,0.026627,0.034973,0.053528,-0.022110,0.026733,0.060089,-0.116516,-0.043518,-0.043488,-0.044159,0.157715,-0.030762,-0.019791,-0.052338,0.197876,-0.002966,-0.009422,-0.065125,0.061096,-0.001552,0.113220,-0.085083,0.112976,-0.037415,-0.020096,-0.104492,-0.078430,0.051971,-0.040314,0.006413,0.120361,-0.072876,-0.048584,-0.091797,0.079041,0.094971,0.072144,0.093323,-0.007469,-0.046417,0.023453,0.113220,-0.029449,0.015457,0.018341,0.076111,-0.041443,-0.023071,0.064941,-0.119324,0.003418,-0.183472,0.017746,0.037506,-0.092468,-0.247925,0.035217,0.042206,-0.043060,0.049866,-0.071533,0.055115,0.087463,-0.107849,-0.105774,-0.088013,0.138794,0.133667,-0.105591,0.080017,-0.291260,0.065918,-0.010307,0.137695,0.077942,0.031372,-0.031494,-0.066772,-0.184082,0.121826,0.027359,-0.025604,-0.125244,0.035828,0.082153,0.065979,0.053650,0.204834,0.141479,-0.093140]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]', '[0.012939,-0.063782,0.031616,0.127441,-0.055023,0.004395,-0.048828,0.045105,-0.079712,-0.024704,0.035126,-0.028763,0.033447,-0.102478,0.095581,0.066284,-0.001293,0.021500,0.074463,0.107361,-0.078918,-0.048767,-0.079773,-0.009651,0.115417,-0.087463,-0.055420,-0.059265,-0.019897,-0.050842,-0.187256,0.060608,-0.195801,-0.069092,0.148193,-0.093994,0.113037,0.062378,-0.014488,-0.116638,0.049225,-0.089050,0.122498,-0.005947,0.012444,-0.003235,-0.075439,0.046814,0.160522,-0.087769,0.039917,-0.022247,0.178955,0.099670,-0.016327,-0.021088,0.061279,0.109436,0.073547,0.035980,0.016708,0.017685,-0.053894,-0.045624,-0.031647,-0.041107,-0.079407,-0.067383,-0.015472,-0.054199,-0.014114,-0.164185,0.099182,-0.027191,-0.021957,-0.014603,0.093750,-0.001885,0.074951,0.094238,-0.001523,0.099731,0.045288,0.104187,-0.105957,0.030701,0.108154,-0.116394,0.090820,-0.153809,0.016983,0.059662,-0.109070,-0.269043,-0.109253,0.053131,-0.002453,0.025360,-0.108093,-0.054871,0.079834,-0.245972,-0.136841,-0.063293,0.174927,0.122498,-0.104980,-0.130249,-0.051605,0.057556,-0.071106,0.078369,0.081848,0.039459,0.021927,-0.000520,-0.001396,0.064575,-0.087463,-0.095398,-0.015175,0.164062,-0.089600,-0.004246,0.054199,0.225464,0.050018,-0.049957]', 1234567890123456781, 3.1411, true, '12345678');";
    auto indexPair = vectorStore->Execute(sqlInsertVector1.c_str());
    std::string sqlInsertVector2 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('1', '运动直播场景 (003)', '[-0.003141,-0.063965,0.010849,0.195190,-0.035919,0.008873,-0.073975,-0.051788,-0.065979,0.023376,0.004238,-0.077698,0.015045,-0.103027,0.076721,0.048279,-0.010628,0.049225,0.097290,0.110535,-0.062927,-0.033447,-0.081116,-0.075378,0.129883,-0.050323,-0.068604,-0.053894,0.007980,-0.032928,-0.126587,0.077515,-0.164429,-0.035339,0.124451,-0.038025,0.070129,0.049622,-0.016220,-0.088257,0.062744,-0.087097,0.068909,0.020096,0.003986,-0.050323,-0.062622,0.013992,0.213867,-0.041626,0.049622,0.052887,0.203613,0.114624,-0.074097,-0.079468,0.065613,0.131348,0.092529,-0.015388,0.030746,-0.002514,0.006256,-0.049622,0.008621,-0.047821,-0.050812,-0.119690,-0.014870,-0.007214,-0.033417,-0.141357,0.152954,0.018585,-0.082397,-0.047943,0.085571,0.030441,0.066162,0.094727,-0.047882,0.110535,0.047363,0.182983,-0.009979,-0.005951,0.063721,-0.027802,0.057617,-0.182739,0.082153,0.031738,-0.141968,-0.257568,-0.087891,0.040833,-0.032959,-0.003309,-0.085022,-0.030136,0.058167,-0.210693,-0.127441,-0.097961,0.133301,0.144897,-0.106506,-0.057770,-0.069336,0.049774,0.012436,0.123352,0.086914,0.090576,0.051117,-0.052094,-0.049744,0.042450,-0.074707,-0.174072,0.016159,0.088928,-0.064331,0.046722,0.072205,0.222412,0.021011,-0.087830]', '运动,相机,直播,华为,外设', '[0.017029,0.008209,-0.037292,0.218262,0.066895,0.142944,-0.032501,-0.015961,-0.097229,-0.095398,-0.065186,-0.048401,0.000182,-0.118896,-0.036743,0.041534,-0.122742,0.118591,0.140869,0.009567,-0.059875,0.007156,-0.098999,-0.044861,0.000140,0.096985,-0.149658,0.002346,0.018112,0.052338,-0.046265,0.119690,-0.048737,0.001713,0.072937,-0.079346,-0.012535,0.032623,0.026627,0.034973,0.053528,-0.022110,0.026733,0.060089,-0.116516,-0.043518,-0.043488,-0.044159,0.157715,-0.030762,-0.019791,-0.052338,0.197876,-0.002966,-0.009422,-0.065125,0.061096,-0.001552,0.113220,-0.085083,0.112976,-0.037415,-0.020096,-0.104492,-0.078430,0.051971,-0.040314,0.006413,0.120361,-0.072876,-0.048584,-0.091797,0.079041,0.094971,0.072144,0.093323,-0.007469,-0.046417,0.023453,0.113220,-0.029449,0.015457,0.018341,0.076111,-0.041443,-0.023071,0.064941,-0.119324,0.003418,-0.183472,0.017746,0.037506,-0.092468,-0.247925,0.035217,0.042206,-0.043060,0.049866,-0.071533,0.055115,0.087463,-0.107849,-0.105774,-0.088013,0.138794,0.133667,-0.105591,0.080017,-0.291260,0.065918,-0.010307,0.137695,0.077942,0.031372,-0.031494,-0.066772,-0.184082,0.121826,0.027359,-0.025604,-0.125244,0.035828,0.082153,0.065979,0.053650,0.204834,0.141479,-0.093140]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]','[-0.016586,-0.080139,0.018356,0.172485,-0.029541,0.013672,-0.051361,0.015236,-0.031677,-0.047821,0.052887,-0.046326,0.029282,-0.094116,0.080200,0.051178,0.007149,0.033295,0.082092,0.091553,-0.056488,-0.024429,-0.069275,-0.036346,0.130127,-0.090088,-0.116821,-0.073059,0.031738,-0.086914,-0.146362,0.052185,-0.167480,-0.023224,0.133911,-0.055115,0.123047,0.078613,-0.042145,-0.085754,0.073608,-0.066467,0.121887,-0.041382,0.046295,-0.044403,-0.064453,0.031616,0.257812,-0.050598,0.099243,0.016693,0.181763,0.080627,-0.028656,-0.048981,0.076904,0.147339,0.090271,-0.031189,0.010590,0.021484,-0.006908,-0.011154,-0.021194,-0.017334,-0.037018,-0.058807,0.005058,-0.001702,-0.061310,-0.129761,0.125000,-0.008171,-0.048950,-0.015549,0.074829,0.029999,0.068359,0.112122,-0.016327,0.073608,0.050323,0.098633,-0.061462,0.014740,0.083618,-0.090271,0.045746,-0.152344,0.049713,0.096619,-0.119202,-0.291016,-0.117004,0.017548,-0.021408,0.007607,-0.109314,-0.034119,0.070374,-0.247070,-0.138062,-0.100647,0.169922,0.106079,-0.095642,-0.078674,-0.035217,0.132202,-0.002275,0.111511,0.080200,0.077026,0.008347,-0.013390,-0.038239,0.023560,-0.090271,-0.132080,0.005173,0.103882,-0.130737,0.021820,0.063965,0.153931,0.015945,-0.031555]');";
    indexPair = vectorStore->Execute(sqlInsertVector2.c_str());
    std::string sqlInsertVector3 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('2', '运动手表遥控手机拍照需求汇报(OS RAT)v0.2', '[0.108093,-0.141846,-0.071594,0.169434,0.066162,-0.092407,-0.037842,-0.065491,-0.107300,-0.090637,0.167969,-0.096741,-0.092224,-0.099304,-0.134277,0.021255,0.010612,0.106445,0.021515,-0.018646,-0.070190,-0.089111,-0.083618,-0.087280,0.005318,-0.007362,-0.074097,-0.047546,0.057068,-0.049957,-0.005615,0.056824,0.100586,0.109985,-0.024094,-0.001211,-0.008827,-0.111084,-0.086975,-0.017532,-0.071716,-0.032440,-0.015160,-0.081726,-0.063843,-0.044098,-0.049835,0.023758,0.223389,0.153198,0.041840,-0.054932,0.293945,-0.000007,0.067200,0.076965,0.043121,0.174072,0.040070,-0.100830,0.017654,-0.059998,0.093506,0.063416,0.046356,0.017654,0.083069,0.041260,0.005947,-0.053619,0.161011,-0.033386,-0.000611,0.005615,0.095215,-0.019669,0.110352,0.034271,-0.072021,0.107910,-0.005352,0.005058,-0.036163,0.025620,-0.117981,-0.012497,-0.029205,0.075562,0.080994,-0.086060,0.125122,-0.090942,0.027649,-0.354980,0.095154,0.085571,0.030350,0.042664,0.013573,-0.060547,0.166870,-0.015533,0.085938,-0.028046,0.111084,0.003170,0.005360,0.015038,-0.005497,0.176147,-0.013756,0.024002,0.066345,-0.012794,0.031372,0.100037,-0.116150,0.036133,0.025665,0.021881,-0.013733,-0.099182,0.015991,0.001002,0.111694,0.147095,-0.116638,0.020996]', 'APP,传感器,DV,气压计,穿戴', '[0.042969,-0.105713,-0.038879,0.042511,-0.016510,0.015297,0.041962,0.028778,0.033539,-0.148438,0.029922,0.142334,-0.118652,0.051117,-0.063110,-0.039154,-0.003944,-0.004814,-0.047455,0.001533,0.091553,-0.005772,-0.156494,-0.102844,-0.016876,-0.008156,-0.046844,-0.040680,0.039215,0.083435,-0.211548,0.061859,0.109009,0.114258,0.043335,0.058960,0.114319,0.084534,0.121033,-0.053070,-0.054291,0.065063,0.078796,-0.067078,-0.030258,0.005074,-0.092346,-0.027252,0.174072,0.139526,0.017685,-0.037140,0.128540,0.008377,-0.023682,-0.041412,0.019928,-0.018661,0.030090,-0.017365,0.050964,0.014305,0.064819,-0.055023,-0.036438,-0.128174,0.005554,0.038208,0.186157,-0.038879,0.019775,0.028854,-0.122070,0.114624,0.048187,-0.092407,0.154663,0.034576,-0.078613,0.026093,0.013237,0.047272,-0.000809,0.044098,-0.085693,-0.047638,0.024277,0.208374,-0.022598,-0.194336,0.184326,0.043701,0.042053,-0.337402,0.011414,0.133057,0.061279,-0.103577,-0.008438,-0.030853,0.148193,0.063416,0.114075,0.143677,0.126709,0.067383,0.027908,-0.039215,-0.091309,0.109009,0.085815,0.169556,0.116394,-0.003960,0.120361,-0.055817,0.024521,-0.057098,0.015541,0.082886,-0.033966,-0.035645,0.155396,0.059448,-0.080566,-0.029282,0.032318,-0.004757]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]','[0.112305,-0.120239,-0.052948,0.135376,0.074463,-0.099365,-0.012161,-0.047913,-0.118286,-0.082397,0.152832,-0.080811,-0.104858,-0.093628,-0.100830,0.023743,0.045868,0.109558,0.045319,-0.004921,-0.035461,-0.110413,-0.100708,-0.088501,0.009941,0.013557,-0.085388,-0.048553,0.052551,-0.037170,-0.016464,0.061035,0.093506,0.087830,-0.009560,-0.033569,0.005718,-0.085266,-0.104553,-0.017044,-0.063354,-0.044037,-0.009949,-0.079651,-0.071106,-0.003210,-0.047394,0.028091,0.237915,0.170166,0.039795,-0.052643,0.274902,0.002653,0.076294,0.073730,0.073242,0.179565,0.056274,-0.099426,0.026825,-0.037231,0.109192,0.029007,0.065674,0.005486,0.073792,0.031860,0.051178,-0.046387,0.156860,-0.039551,-0.004505,-0.017822,0.076233,0.008659,0.121216,0.034180,-0.069946,0.109131,0.017502,0.003963,-0.048035,0.023926,-0.124939,0.011589,-0.035339,0.070557,0.074402,-0.106995,0.143188,-0.069153,0.016830,-0.312988,0.139771,0.086365,0.011269,0.058319,0.034027,-0.073425,0.170166,-0.006699,0.058197,-0.025864,0.142090,0.028625,0.009842,-0.000231,0.001409,0.208618,-0.038696,0.013191,0.063049,0.015221,0.030609,0.132568,-0.119568,0.063599,0.008369,0.023605,-0.025085,-0.102905,-0.010818,0.031616,0.111084,0.138306,-0.136841,0.028442]');";
    indexPair = vectorStore->Execute(sqlInsertVector3.c_str());
    std::string sqlInsertVector4 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('3', '运动健康设备虚拟化(二期)', '[-0.005596,0.060913,-0.027283,-0.084839,-0.116577,-0.045990,0.015900,0.066284,-0.020844,-0.079529,0.087402,-0.043365,-0.073669,-0.029922,0.008011,0.000314,-0.088196,0.093933,0.057495,0.134399,-0.087646,0.057190,-0.103088,0.026138,0.023666,-0.132202,0.025726,-0.116333,0.011986,-0.096008,-0.133423,0.072632,-0.038208,-0.060120,-0.014587,0.035645,0.008003,0.132690,-0.100464,0.013420,0.028015,0.064270,0.125244,0.110779,-0.053894,0.059906,0.041016,-0.023651,0.119263,0.099548,-0.066895,-0.049927,0.168335,-0.000125,-0.029083,-0.044250,0.012871,0.287598,0.079773,-0.007828,0.043335,-0.010239,0.023407,-0.134521,-0.067444,-0.055420,-0.075989,-0.064392,-0.074646,-0.048676,-0.135620,-0.126831,0.050690,0.102722,0.068970,0.073425,0.040863,0.035156,0.001891,0.066223,0.168457,0.058868,0.076172,0.067871,0.005325,0.041687,0.061249,-0.030991,0.025970,-0.047852,0.116821,-0.029648,0.040436,-0.269531,0.110596,-0.017075,0.041626,-0.008797,-0.097961,0.073608,0.255127,0.060913,-0.052734,-0.046234,0.018845,0.233154,0.082764,-0.031677,0.059479,-0.043152,-0.014572,-0.057800,0.044037,0.225586,0.051758,0.007748,0.049713,0.006744,0.046844,0.045288,0.064575,0.055298,-0.043152,-0.071960,0.232788,-0.130005,0.137329,0.021576]', 'APP,传感器,DV,气压计,穿戴', '[0.042969,-0.105713,-0.038879,0.042511,-0.016510,0.015297,0.041962,0.028778,0.033539,-0.148438,0.029922,0.142334,-0.118652,0.051117,-0.063110,-0.039154,-0.003944,-0.004814,-0.047455,0.001533,0.091553,-0.005772,-0.156494,-0.102844,-0.016876,-0.008156,-0.046844,-0.040680,0.039215,0.083435,-0.211548,0.061859,0.109009,0.114258,0.043335,0.058960,0.114319,0.084534,0.121033,-0.053070,-0.054291,0.065063,0.078796,-0.067078,-0.030258,0.005074,-0.092346,-0.027252,0.174072,0.139526,0.017685,-0.037140,0.128540,0.008377,-0.023682,-0.041412,0.019928,-0.018661,0.030090,-0.017365,0.050964,0.014305,0.064819,-0.055023,-0.036438,-0.128174,0.005554,0.038208,0.186157,-0.038879,0.019775,0.028854,-0.122070,0.114624,0.048187,-0.092407,0.154663,0.034576,-0.078613,0.026093,0.013237,0.047272,-0.000809,0.044098,-0.085693,-0.047638,0.024277,0.208374,-0.022598,-0.194336,0.184326,0.043701,0.042053,-0.337402,0.011414,0.133057,0.061279,-0.103577,-0.008438,-0.030853,0.148193,0.063416,0.114075,0.143677,0.126709,0.067383,0.027908,-0.039215,-0.091309,0.109009,0.085815,0.169556,0.116394,-0.003960,0.120361,-0.055817,0.024521,-0.057098,0.015541,0.082886,-0.033966,-0.035645,0.155396,0.059448,-0.080566,-0.029282,0.032318,-0.004757]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]', '[-0.001413,0.054657,-0.023270,-0.062927,-0.159302,-0.024277,0.029022,0.098877,-0.018753,-0.118408,0.113220,-0.052094,-0.034637,-0.001076,0.005955,-0.029724,-0.100830,0.085083,0.059692,0.105713,-0.104126,0.038391,-0.119751,0.047577,0.050201,-0.164551,0.013710,-0.112854,0.016068,-0.100281,-0.120728,0.056854,-0.020706,-0.053741,0.013748,0.019043,0.008018,0.091370,-0.126709,0.016510,0.000745,0.041351,0.130249,0.074219,-0.043091,0.072144,0.046295,-0.027817,0.103943,0.089050,-0.074219,-0.050049,0.191284,0.016495,-0.003389,-0.024780,0.026474,0.260010,0.084534,-0.005592,0.070007,-0.042145,-0.023438,-0.134155,-0.091919,-0.050537,-0.083008,-0.047089,-0.026245,-0.010971,-0.143921,-0.130493,0.032776,0.078430,0.085266,0.118896,0.039032,0.033691,0.014732,0.080811,0.211670,0.038696,0.069153,0.022339,-0.003193,0.069031,0.018311,-0.058777,0.008797,-0.046265,0.122192,0.029312,0.019028,-0.262695,0.108459,-0.040924,0.069092,0.008667,-0.134644,0.059021,0.247925,0.035583,-0.050201,-0.031647,0.054810,0.219482,0.063782,-0.009384,0.080566,0.025116,-0.020706,-0.050171,0.046478,0.198975,0.057465,-0.005650,0.054688,0.017578,0.047302,0.054810,0.062927,0.086487,-0.038086,-0.046539,0.211060,-0.139648,0.121521,0.035065]');";
    indexPair = vectorStore->Execute(sqlInsertVector4.c_str());
    std::string sqlInsertVector5 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('4', '中国汉服运动的本身及现状', '[0.062469,-0.134277,-0.107056,-0.036499,-0.060364,0.160400,0.122620,0.006508,0.048676,-0.065247,0.058014,-0.103882,0.031677,-0.275391,0.010498,0.064209,0.021576,0.028946,-0.041199,0.068542,0.108215,0.023331,-0.031281,-0.045807,-0.054413,-0.075745,0.146973,0.045807,0.062561,0.080322,0.097717,0.045227,-0.132812,-0.069275,0.167114,-0.026489,-0.065918,0.041992,0.065186,0.042023,-0.031342,0.007942,0.201904,0.171631,-0.088074,0.032166,0.038574,-0.046387,0.068237,0.007450,0.023697,-0.027267,-0.072754,-0.039551,0.093933,-0.047638,0.154785,0.209351,0.037537,-0.148804,-0.068298,-0.097778,-0.022964,-0.028656,-0.022385,-0.069397,-0.098083,-0.028152,0.039276,0.000283,-0.100281,-0.217651,-0.022629,0.083557,0.040710,-0.054840,-0.148560,-0.010498,0.164429,0.135620,-0.021912,0.056885,-0.030182,-0.060913,0.043030,-0.053802,-0.028915,-0.114807,-0.055878,-0.136353,0.151733,0.020477,-0.200806,-0.033783,-0.036865,-0.045074,0.016571,0.048767,0.043457,0.154907,0.118164,-0.054810,-0.046234,0.012108,0.103821,0.047668,0.008316,0.106750,-0.079041,-0.042450,0.073792,-0.022964,0.079895,0.038269,-0.013634,0.139404,-0.068787,0.038177,-0.083801,-0.137695,-0.000573,0.099670,0.059875,0.089233,0.107666,0.074158,0.061798,0.059906]', '汉服,传统,文化,运动,传承', '[0.043671,-0.086792,-0.046661,0.019867,-0.085999,0.120728,0.102844,0.011292,0.045319,-0.102051,0.060333,-0.122314,0.075806,-0.252441,0.010696,0.043365,-0.005116,0.071350,-0.104187,0.032745,0.025070,-0.023956,-0.105408,0.011047,0.011620,-0.054596,0.096924,-0.007324,0.004112,0.123840,0.018829,0.103882,-0.085449,-0.037018,0.168213,-0.045013,-0.061798,0.059540,0.006157,-0.041290,-0.078003,0.044495,0.169312,0.098633,-0.178345,0.035034,-0.045532,0.038300,0.128296,-0.051361,0.092102,-0.062805,-0.150513,-0.009544,0.144653,0.046387,0.146118,0.165039,-0.032745,-0.081421,0.002134,-0.146240,-0.060791,0.044281,-0.003738,-0.124207,-0.073547,0.017303,0.029037,0.017365,-0.167847,-0.172607,-0.116516,0.020981,0.075439,-0.024078,-0.062561,0.005821,0.113708,0.128052,0.053864,0.039215,-0.018555,-0.149780,0.058380,-0.033417,-0.142822,-0.043457,-0.123413,-0.152832,0.185547,0.029343,-0.216309,-0.085449,0.022247,0.006069,0.056244,0.052460,0.027451,0.040527,0.053955,-0.075195,-0.030060,0.035583,0.095093,0.028610,0.066833,0.121704,0.003088,0.002085,0.094238,-0.058929,0.128296,0.014153,-0.083008,0.147949,0.043274,0.007450,-0.104980,-0.059326,-0.046051,0.059875,0.081116,0.132690,0.073242,0.024429,0.090027,0.115540]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]', '[0.077576,-0.110535,-0.121216,-0.032562,-0.041290,0.179077,0.135986,0.062195,0.015930,-0.109192,0.043549,-0.084717,0.054291,-0.258545,0.063782,0.027573,0.007191,0.026550,-0.071350,0.073730,0.130981,0.005592,-0.026443,-0.003260,-0.038696,-0.067139,0.088196,0.036163,0.106079,0.057617,0.080750,0.048645,-0.122864,-0.078918,0.172729,-0.052307,-0.042603,0.034851,0.070129,0.053345,-0.036530,0.033875,0.172485,0.133911,-0.041840,0.052368,0.030533,-0.036530,0.085205,0.032135,-0.009331,-0.050964,-0.062805,-0.005779,0.078247,-0.022064,0.163330,0.193970,0.021652,-0.145264,-0.085571,-0.086548,-0.024597,-0.018860,-0.020981,-0.083618,-0.078613,-0.068604,0.108154,0.020599,-0.141846,-0.184692,-0.020569,0.057587,0.033691,-0.033905,-0.160278,-0.036957,0.154663,0.138306,0.008018,0.020981,-0.089111,-0.092468,0.013000,-0.028717,-0.006031,-0.140259,-0.066101,-0.134155,0.160034,0.061340,-0.207764,-0.049530,-0.047119,-0.022568,-0.006092,0.060547,0.033966,0.166016,0.135498,-0.080627,-0.062622,-0.014198,0.082031,0.069702,-0.036774,0.124329,-0.076965,-0.037384,0.033600,0.013237,0.039032,0.062561,-0.043304,0.116699,-0.061493,0.051849,-0.103516,-0.110229,-0.008461,0.120422,0.052277,0.071655,0.103882,0.050262,0.092712,0.099609]');";
    indexPair = vectorStore->Execute(sqlInsertVector5.c_str());
    std::string sqlInsertVector6 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('5', '武侠世界的内功外功', '[0.027634,0.015808,0.094604,0.001444,-0.063599,-0.117432,0.038483,-0.096313,-0.094910,0.119141,0.088013,-0.060150,0.069092,0.032532,0.064453,0.121826,0.107666,-0.220703,-0.052826,-0.002031,0.050293,0.010254,-0.014610,-0.077332,0.060974,-0.004623,0.067383,0.134155,-0.090393,0.026413,0.093079,0.125488,-0.145142,-0.041260,-0.068848,-0.031204,-0.011108,-0.071777,0.039917,0.156860,0.081482,-0.049896,0.076599,0.133545,-0.104248,0.021667,-0.024719,-0.117126,-0.119629,0.002636,0.064331,-0.007000,-0.014664,-0.002623,0.086060,0.009308,-0.026947,-0.040558,-0.032898,-0.155273,0.018982,-0.198486,0.048370,-0.183594,0.007584,-0.018723,-0.132812,0.220215,0.027039,-0.084717,-0.036591,-0.024277,-0.099731,0.073120,-0.123596,0.104248,-0.092102,-0.022720,0.002827,0.085938,0.204590,-0.127563,-0.030884,0.083008,-0.037170,-0.004574,0.093445,0.049866,-0.011414,-0.053406,-0.115051,-0.021851,-0.158813,-0.059479,-0.106262,-0.033722,0.076965,0.149292,-0.001477,0.094666,0.016464,0.116882,0.019012,-0.024094,0.138428,0.142578,0.066589,0.016968,-0.056274,-0.061798,-0.104919,0.027679,-0.057800,-0.138794,-0.100342,0.003929,-0.009445,0.191406,0.054779,-0.042572,-0.156494,0.078003,0.018448,0.113525,0.050995,-0.059937,0.022598,0.104248]', '内功,技能,修炼,text,Enter', '[0.068542,-0.026306,0.123169,0.087280,-0.002964,-0.088806,0.073975,-0.085388,-0.038208,0.077148,0.049744,-0.098328,0.068726,0.108704,0.109314,0.141357,0.058716,-0.159058,-0.010498,0.005276,0.077454,0.037048,-0.004944,-0.105652,0.184082,-0.050720,-0.016617,0.070801,-0.114319,0.071655,0.028290,0.108398,-0.082153,0.062439,-0.004105,0.068298,-0.011620,0.000884,-0.047546,0.074829,0.119629,-0.061798,0.068909,0.052246,-0.030090,-0.049133,-0.063782,-0.084229,0.056763,-0.063538,0.029190,-0.076477,-0.073853,0.075073,0.005505,0.070801,0.008224,0.046478,-0.091614,-0.047699,-0.016174,-0.228638,0.004379,-0.208130,0.099121,-0.118408,-0.076721,0.104126,0.071106,-0.029694,-0.059143,0.016922,-0.094604,0.000298,-0.068481,0.039459,-0.060669,0.043518,-0.011719,0.011391,0.184570,-0.111694,0.038818,-0.043182,0.143311,-0.010063,0.089233,-0.013672,-0.005341,0.003826,-0.043823,0.049591,-0.211304,-0.120972,-0.176147,0.012917,0.055206,0.087646,0.009041,0.037018,0.078796,0.067322,0.145752,0.033295,0.184082,0.121155,0.117249,0.055328,-0.033173,0.037292,-0.138428,-0.015869,-0.026627,-0.141846,-0.129761,-0.081909,-0.000997,0.093811,0.031647,-0.037659,-0.074341,0.032379,-0.131348,0.103394,0.083191,-0.231812,0.016373,0.171875]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]','[0.009941,0.003685,0.113525,-0.032654,-0.084412,-0.082275,0.106750,-0.021164,-0.089722,0.028473,0.150757,-0.082458,0.087708,0.008446,0.088440,0.058350,0.100769,-0.142578,-0.061340,-0.057739,0.058807,-0.014221,-0.058167,-0.061951,0.061310,0.056030,0.027313,0.098999,-0.112549,-0.003599,0.030197,0.141113,-0.162842,0.011551,-0.035980,-0.098633,0.014587,-0.072815,0.081116,0.113831,-0.000974,-0.009048,0.035797,0.168823,-0.050262,0.015190,-0.041840,-0.098938,-0.093079,0.001185,0.098267,-0.057495,-0.008141,-0.037598,0.144653,0.034393,0.016449,-0.097900,-0.084656,-0.203979,0.047241,-0.146484,-0.029816,-0.131592,0.050507,0.033081,-0.134033,0.217163,0.061890,-0.088623,-0.162231,-0.043304,-0.122681,0.025543,-0.120911,0.142700,-0.039673,0.018234,0.001247,0.046173,0.214233,-0.099731,-0.092834,0.069946,-0.076965,0.064026,0.024445,0.014320,-0.032410,-0.052094,-0.108459,0.019852,-0.109863,0.010910,-0.071655,-0.031342,0.085205,0.193970,-0.041351,0.031616,0.015167,0.051636,-0.012672,-0.064331,0.082947,0.127563,0.018875,0.009911,-0.106323,-0.067932,-0.104065,0.039062,-0.058472,-0.105164,-0.086304,-0.020340,0.079529,0.133423,0.064087,-0.049011,-0.191772,0.099365,0.050659,0.131348,0.076050,-0.133423,0.054443,0.124634]');";
    indexPair = vectorStore->Execute(sqlInsertVector6.c_str());
    std::string sqlInsertVector7 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('6', '华为运动健康和 HMF 融合需求', '[0.112244,-0.056091,0.030197,0.169678,0.040314,0.003168,0.012444,0.078125,-0.021118,-0.237793,0.010757,-0.107849,-0.052368,0.009567,0.008698,-0.086182,-0.121521,0.121948,0.192993,-0.031311,-0.094971,0.016724,-0.111816,0.024841,0.053467,0.001334,-0.075562,-0.003925,0.093933,-0.071045,0.055817,0.007950,-0.141113,0.027054,-0.105530,-0.009056,-0.056610,0.044800,-0.029587,-0.066223,0.058258,0.061584,-0.010841,0.037598,-0.223999,-0.006634,0.065674,-0.045654,0.176636,0.037323,0.008698,-0.025772,0.184448,-0.001676,0.004051,0.011642,0.077454,0.028503,0.116516,0.024338,-0.004490,-0.041260,0.069275,-0.163696,-0.050812,-0.000936,-0.001822,-0.091919,-0.093994,-0.161621,-0.066650,-0.020309,0.053436,0.001735,0.039398,0.037292,0.002871,-0.008331,-0.058899,0.211060,0.059387,-0.004269,0.037628,-0.010597,-0.011086,-0.046173,0.031799,-0.040741,-0.017792,-0.100281,0.226685,-0.077454,-0.041229,-0.186157,-0.037842,-0.151367,0.045929,0.046661,-0.007874,0.128540,0.208374,-0.029556,-0.085205,-0.045776,0.050995,-0.001581,0.017059,0.005444,-0.017731,-0.027878,-0.162964,0.064331,0.104187,0.141235,0.124390,0.115601,-0.136230,0.128418,-0.071533,-0.096069,0.042175,-0.097351,0.078796,0.062164,0.145996,0.013985,0.124512,0.037262]', 'HMF,健康,运动,场景,团队', '[0.074524,-0.019089,0.174438,0.093018,-0.069702,-0.022217,-0.084900,0.041595,-0.077087,-0.147217,0.064148,-0.125977,-0.024399,-0.003031,0.029282,0.012794,-0.155884,0.087219,0.138062,0.168945,0.021469,-0.020615,-0.140503,0.125732,0.041809,-0.116272,-0.003792,-0.019943,0.028351,-0.053528,-0.045654,0.040833,-0.159668,-0.065613,0.020325,-0.030151,-0.012794,0.015106,0.000332,-0.065430,0.093262,0.115173,0.045288,0.023514,-0.115112,0.008110,-0.000341,-0.078064,0.188232,-0.157715,-0.040527,0.067688,0.114075,-0.008392,0.003454,-0.077271,0.001431,-0.034515,0.225098,-0.028000,0.038208,0.052887,-0.018143,-0.187134,0.023712,-0.085632,-0.083923,-0.102295,-0.106262,0.016159,-0.059265,0.066467,0.051178,-0.018280,-0.040253,0.077332,-0.052765,0.119324,-0.002405,0.121643,-0.006714,0.067566,0.014984,0.049866,-0.003130,0.029968,0.065857,-0.020493,-0.065308,-0.030334,0.082397,-0.060028,0.035217,-0.230957,0.051117,-0.114746,0.037354,-0.007267,0.016083,0.111755,0.104675,-0.012680,-0.118164,0.087280,0.032501,0.148315,0.082642,-0.050629,-0.048279,0.070435,-0.242188,0.005199,0.108093,0.080933,0.165649,0.163330,0.015175,0.114563,-0.135742,-0.135864,0.057678,0.066956,0.061981,0.032898,0.056671,-0.055878,0.091309,0.119995]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]', '[0.091370,-0.032593,0.035004,0.143066,-0.013985,0.011482,-0.017365,0.137451,-0.027451,-0.256348,0.034973,-0.131348,-0.056641,0.019211,0.020889,-0.087830,-0.072754,0.150513,0.130249,-0.054962,-0.091919,0.000601,-0.086670,0.083435,0.048767,0.021729,-0.080444,-0.028152,0.092163,-0.053497,0.052704,0.021393,-0.091492,0.045868,-0.092468,-0.013466,-0.050262,0.044891,0.005005,-0.074036,0.079834,0.068726,-0.048187,0.029114,-0.213013,0.000719,0.066101,-0.018814,0.171997,0.050751,0.001227,-0.025085,0.154663,0.018036,0.010597,0.033783,0.081970,0.032013,0.109619,0.027176,-0.024185,-0.043762,0.085388,-0.182617,-0.062317,-0.012070,-0.005276,-0.090332,-0.063782,-0.171997,-0.088074,-0.046356,0.031235,-0.000472,0.051056,0.041138,0.018341,-0.018814,-0.106384,0.219238,0.068848,-0.014458,0.000063,-0.058075,-0.043213,-0.062988,0.033142,-0.034637,-0.028030,-0.113708,0.261475,-0.035706,-0.049011,-0.140381,-0.039215,-0.167236,0.060455,0.070496,-0.017914,0.106750,0.194092,-0.027084,-0.112610,-0.066040,0.053131,0.009445,0.003269,-0.000643,-0.006680,-0.004135,-0.197021,0.043549,0.105042,0.117310,0.160156,0.109619,-0.143188,0.114868,-0.071289,-0.094177,-0.000851,-0.087646,0.029694,0.072571,0.133057,0.011345,0.083191,0.051056]');";
    indexPair = vectorStore->Execute(sqlInsertVector7.c_str());
    std::string sqlInsertVector8 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('7', '华为运动健康HMF需求分析_V0.2(20180122)', '[0.131836,-0.014938,-0.017426,0.143555,0.060272,0.009422,0.015602,0.023468,-0.086914,-0.181763,0.102966,-0.115906,-0.069031,-0.016418,-0.058350,-0.089294,-0.083130,0.141479,0.206665,-0.006939,-0.039246,-0.026978,-0.092896,-0.007866,0.044556,-0.010933,-0.014633,0.024811,0.120972,-0.080078,0.017685,0.021149,-0.098999,0.043091,-0.048462,0.024185,-0.003632,-0.064880,-0.066895,-0.028107,0.048676,0.073486,-0.090820,0.104309,-0.240601,-0.012497,0.098633,-0.011002,0.154053,0.100952,-0.027573,-0.120178,0.175293,0.001878,0.025574,-0.067566,0.049347,0.116638,0.121277,0.017471,0.060455,-0.023056,-0.028244,-0.048828,-0.086914,0.033447,0.061798,-0.065308,-0.063782,-0.132812,-0.052704,0.007191,0.061798,-0.071533,-0.025864,0.018188,-0.023972,0.044861,-0.102783,0.152100,-0.038177,-0.000143,-0.007027,-0.043793,-0.016983,-0.109497,0.030655,-0.075989,-0.014534,-0.117065,0.132812,-0.103699,0.015793,-0.177124,-0.076660,-0.114136,0.073853,0.001899,-0.049622,0.170654,0.197632,-0.008728,-0.029495,-0.132446,0.008942,-0.027359,-0.045837,0.035370,-0.078552,0.054657,-0.185303,0.028839,-0.009712,0.116882,0.125244,0.114197,-0.071045,0.156982,-0.145996,-0.024170,0.113953,-0.116455,0.044922,0.072205,0.167358,-0.011177,0.142212,0.090088]', '用户,运动,卡片,场景,健康', '[0.139404,-0.182983,0.109985,-0.016052,-0.074036,-0.109070,-0.000155,0.105652,-0.055908,-0.081360,0.041382,-0.131592,0.035858,-0.008835,-0.079163,0.016541,-0.095215,-0.040192,0.084412,0.122437,0.121643,-0.100342,-0.015762,-0.086731,0.017700,-0.118225,-0.016937,-0.072144,0.159546,-0.118408,-0.063599,0.068237,-0.041870,-0.087769,0.009705,0.032959,0.015030,-0.100586,-0.005898,-0.022324,-0.014023,-0.039917,0.091431,0.074158,-0.130493,-0.019760,-0.118652,-0.112976,0.238647,-0.081726,-0.048920,0.003027,0.175659,0.102600,-0.022446,-0.095520,0.051727,0.041382,0.088989,0.079590,-0.001750,-0.049652,-0.084656,-0.054718,0.056396,-0.050751,0.051331,-0.105225,-0.006908,-0.027878,-0.049408,0.033600,-0.082581,-0.095581,0.026917,0.126221,0.175415,-0.076416,0.038483,0.044647,0.012299,0.043945,0.121155,-0.059082,-0.005798,0.069214,0.056610,-0.029068,0.200562,-0.100037,0.049438,-0.021194,0.018127,-0.254395,0.078308,-0.016937,-0.053589,-0.040100,-0.036560,0.053802,0.195190,0.053711,-0.065979,0.080688,0.091492,0.139160,0.074646,0.090271,-0.090759,-0.050812,-0.169312,0.080139,0.058563,0.104248,-0.036041,0.156372,-0.071838,0.194580,-0.070129,0.037109,0.066467,-0.026108,-0.050964,0.059021,-0.069580,-0.038788,0.021729,-0.006523]', '[0.038727,0.080627,0.012520,-0.097778,-0.079651,-0.080627,0.072510,0.233887,0.063354,0.089355,-0.100342,0.022797,0.071655,-0.029770,0.036591,0.004120,-0.107788,0.074402,0.158081,-0.136841,0.073792,0.012650,-0.062500,-0.005177,-0.011795,0.089233,0.091309,-0.053497,0.007099,-0.111084,-0.009789,0.107178,0.033752,-0.034943,-0.006947,-0.010880,-0.069763,-0.074768,0.031769,-0.041870,0.011497,-0.126343,0.004051,-0.104675,0.011032,-0.054047,0.055023,0.161987,-0.164551,0.123413,-0.059692,0.093262,-0.070251,-0.083435,0.007645,0.035187,0.016373,-0.101807,-0.049683,0.023773,-0.117249,0.076172,0.039886,0.032227,0.119385,-0.098328,-0.024857,0.098328,-0.148804,0.002064,-0.116150,-0.015526,0.060181,-0.213379,0.043121,-0.017761,-0.075012,-0.008507,-0.011986,0.002188,0.042938,0.152100,0.112793,0.095215,-0.020905,-0.202515,0.006176,-0.072998,0.022263,-0.116516,-0.092773,0.024002,0.086182,-0.016418,-0.125366,0.116821,-0.047943,0.076355,-0.056732,-0.284424,-0.076416,-0.120667,-0.178833,-0.066956,0.080627,0.037872,0.024857,0.038666,0.021423,-0.125854,-0.032867,0.062256,0.017380,0.040985,-0.127441,0.170898,-0.062408,-0.010910,-0.122925,0.041534,-0.036530,-0.108398,0.146973,0.110962,-0.067322,0.070740,0.013237,0.000191]', '[0.112000,-0.004730,-0.013077,0.109253,0.023682,0.010574,0.010529,0.096375,-0.097778,-0.171021,0.109802,-0.062744,-0.079529,-0.019943,-0.064636,-0.113953,-0.068604,0.153809,0.219971,-0.004444,-0.005245,-0.019623,-0.112488,0.022278,0.056335,-0.026245,-0.050140,0.006279,0.106506,-0.082397,0.024826,0.034424,-0.104614,0.036713,-0.047089,0.006557,0.012680,-0.039246,-0.038879,-0.028290,0.042633,0.118164,-0.075378,0.080444,-0.215210,-0.003464,0.118958,-0.011391,0.127075,0.080933,-0.002943,-0.074036,0.123291,-0.003998,-0.000894,-0.068542,0.066101,0.129028,0.135864,0.018738,0.071106,-0.033661,-0.037231,-0.077271,-0.093445,0.058990,0.064453,-0.097046,-0.038849,-0.140747,-0.079102,0.019089,0.068359,-0.069031,-0.020676,0.042694,-0.046539,0.038055,-0.108765,0.136353,-0.032654,0.015839,0.028198,-0.068542,-0.016678,-0.067078,0.057800,-0.078003,-0.018921,-0.123474,0.121277,-0.059631,0.019150,-0.141235,-0.082336,-0.102417,0.077942,-0.024384,-0.038330,0.172363,0.189453,-0.033356,-0.087036,-0.119080,0.018112,-0.000111,-0.060577,0.002394,-0.048035,0.048584,-0.197876,0.058075,-0.029037,0.163452,0.139526,0.130737,-0.078430,0.166016,-0.184448,-0.026199,0.116272,-0.090027,0.031204,0.086792,0.146851,-0.036194,0.138428,0.127686]');";
    indexPair = vectorStore->Execute(sqlInsertVector8.c_str());
    std::string sqlInsertVector9 =
    "INSERT INTO vector (fileid, filename_text, filename, keywords_text, keywords, chapter, abstract) VALUES ('8', 'how old are you', '[0.062650,0.117408,0.004371,-0.046344,-0.090719,-0.011607,0.162146,0.086306,-0.079142,0.096476,-0.150609,-0.029258,-0.029897,-0.063808,-0.173169,-0.044499,-0.153779,-0.203815,0.073298,-0.133464,-0.004015,0.172819,0.073305,0.085744,-0.024866,0.014089,-0.106608,-0.081278,0.107360,0.045736,-0.065544,0.037183,0.097371,0.040015,0.025403,0.186975,-0.123233,0.009749,0.054518,-0.026801,-0.078835,0.116625,-0.185772,-0.075354,0.110820,-0.023518,-0.134040,-0.053865,0.095511,-0.031333,0.080909,-0.049918,-0.019640,0.132287,0.114508,-0.062644,0.074355,-0.042376,0.028002,-0.026514,-0.048469,-0.012334,-0.043338,-0.094815,0.004115,0.117528,0.040216,0.046243,-0.114099,0.052793,-0.083400,0.055554,-0.014398,0.118908,-0.012090,0.104513,-0.015765,-0.152733,-0.073301,-0.066157,-0.083764,-0.011472,-0.082424,0.019969,-0.095536,-0.028566,-0.144718,-0.029092,0.019254,-0.083302,-0.063769,-0.109819,-0.132901,-0.010429,-0.012232,0.226949,-0.003659,0.007853,0.050311,0.092511,-0.084480,0.013467,-0.095115,-0.083914,-0.125114,0.057377,0.061942,-0.107255,0.047330,-0.045265,0.070185,0.026433,0.085425,0.129176,-0.096603,-0.013692,-0.120441,-0.009809,-0.038474,0.072574,0.124587,-0.021224,0.016377,0.051440,0.112341,-0.115525,0.089061,0.172560]', 'how old are you', '[0.062650,0.117408,0.004371,-0.046344,-0.090719,-0.011607,0.162146,0.086306,-0.079142,0.096476,-0.150609,-0.029258,-0.029897,-0.063808,-0.173169,-0.044499,-0.153779,-0.203815,0.073298,-0.133464,-0.004015,0.172819,0.073305,0.085744,-0.024866,0.014089,-0.106608,-0.081278,0.107360,0.045736,-0.065544,0.037183,0.097371,0.040015,0.025403,0.186975,-0.123233,0.009749,0.054518,-0.026801,-0.078835,0.116625,-0.185772,-0.075354,0.110820,-0.023518,-0.134040,-0.053865,0.095511,-0.031333,0.080909,-0.049918,-0.019640,0.132287,0.114508,-0.062644,0.074355,-0.042376,0.028002,-0.026514,-0.048469,-0.012334,-0.043338,-0.094815,0.004115,0.117528,0.040216,0.046243,-0.114099,0.052793,-0.083400,0.055554,-0.014398,0.118908,-0.012090,0.104513,-0.015765,-0.152733,-0.073301,-0.066157,-0.083764,-0.011472,-0.082424,0.019969,-0.095536,-0.028566,-0.144718,-0.029092,0.019254,-0.083302,-0.063769,-0.109819,-0.132901,-0.010429,-0.012232,0.226949,-0.003659,0.007853,0.050311,0.092511,-0.084480,0.013467,-0.095115,-0.083914,-0.125114,0.057377,0.061942,-0.107255,0.047330,-0.045265,0.070185,0.026433,0.085425,0.129176,-0.096603,-0.013692,-0.120441,-0.009809,-0.038474,0.072574,0.124587,-0.021224,0.016377,0.051440,0.112341,-0.115525,0.089061,0.172560]', '[0.062650,0.117408,0.004371,-0.046344,-0.090719,-0.011607,0.162146,0.086306,-0.079142,0.096476,-0.150609,-0.029258,-0.029897,-0.063808,-0.173169,-0.044499,-0.153779,-0.203815,0.073298,-0.133464,-0.004015,0.172819,0.073305,0.085744,-0.024866,0.014089,-0.106608,-0.081278,0.107360,0.045736,-0.065544,0.037183,0.097371,0.040015,0.025403,0.186975,-0.123233,0.009749,0.054518,-0.026801,-0.078835,0.116625,-0.185772,-0.075354,0.110820,-0.023518,-0.134040,-0.053865,0.095511,-0.031333,0.080909,-0.049918,-0.019640,0.132287,0.114508,-0.062644,0.074355,-0.042376,0.028002,-0.026514,-0.048469,-0.012334,-0.043338,-0.094815,0.004115,0.117528,0.040216,0.046243,-0.114099,0.052793,-0.083400,0.055554,-0.014398,0.118908,-0.012090,0.104513,-0.015765,-0.152733,-0.073301,-0.066157,-0.083764,-0.011472,-0.082424,0.019969,-0.095536,-0.028566,-0.144718,-0.029092,0.019254,-0.083302,-0.063769,-0.109819,-0.132901,-0.010429,-0.012232,0.226949,-0.003659,0.007853,0.050311,0.092511,-0.084480,0.013467,-0.095115,-0.083914,-0.125114,0.057377,0.061942,-0.107255,0.047330,-0.045265,0.070185,0.026433,0.085425,0.129176,-0.096603,-0.013692,-0.120441,-0.009809,-0.038474,0.072574,0.124587,-0.021224,0.016377,0.051440,0.112341,-0.115525,0.089061,0.172560]', '[0.062650,0.117408,0.004371,-0.046344,-0.090719,-0.011607,0.162146,0.086306,-0.079142,0.096476,-0.150609,-0.029258,-0.029897,-0.063808,-0.173169,-0.044499,-0.153779,-0.203815,0.073298,-0.133464,-0.004015,0.172819,0.073305,0.085744,-0.024866,0.014089,-0.106608,-0.081278,0.107360,0.045736,-0.065544,0.037183,0.097371,0.040015,0.025403,0.186975,-0.123233,0.009749,0.054518,-0.026801,-0.078835,0.116625,-0.185772,-0.075354,0.110820,-0.023518,-0.134040,-0.053865,0.095511,-0.031333,0.080909,-0.049918,-0.019640,0.132287,0.114508,-0.062644,0.074355,-0.042376,0.028002,-0.026514,-0.048469,-0.012334,-0.043338,-0.094815,0.004115,0.117528,0.040216,0.046243,-0.114099,0.052793,-0.083400,0.055554,-0.014398,0.118908,-0.012090,0.104513,-0.015765,-0.152733,-0.073301,-0.066157,-0.083764,-0.011472,-0.082424,0.019969,-0.095536,-0.028566,-0.144718,-0.029092,0.019254,-0.083302,-0.063769,-0.109819,-0.132901,-0.010429,-0.012232,0.226949,-0.003659,0.007853,0.050311,0.092511,-0.084480,0.013467,-0.095115,-0.083914,-0.125114,0.057377,0.061942,-0.107255,0.047330,-0.045265,0.070185,0.026433,0.085425,0.129176,-0.096603,-0.013692,-0.120441,-0.009809,-0.038474,0.072574,0.124587,-0.021224,0.016377,0.051440,0.112341,-0.115525,0.089061,0.172560]');";
    indexPair = vectorStore->Execute(sqlInsertVector9.c_str());
  4. 配置数据库相关的信息和上下文对象,并且生成检索器对象,用于后面的检索。

    // 创建检索器
    // 创建检索器配置
    OH_Retrieval_Config *config = OH_Retrieval_CreateConfig();
    // 创建数据库配置
    OH_Retrieval_DbConfig *dbConfig = OH_Retrieval_CreateDbConfig();
    // 创建关系型数据库的配置
    OH_Rdb_ConfigV2 *rdbConfig = OH_Rdb_CreateConfig();
    // 设置关系型数据库配置的目录
    int ret = OH_Rdb_SetDatabaseDir(rdbConfig, RDB_TEST_PATH);
    // 设置关系型数据库配置的数据库名
    ret = OH_Rdb_SetStoreName(rdbConfig, "vector_test.db");
    // 设置关系型数据库配置的应用包名
    ret = OH_Rdb_SetBundleName(rdbConfig, "retrievalTest");
    // 设置关系型数据库配置的加密状态
    ret = OH_Rdb_SetEncrypted(rdbConfig, false);
    // 设置关系型数据库配置的加密级别
    ret = OH_Rdb_SetSecurityLevel(rdbConfig, OH_Rdb_SecurityLevel::S1);
    // 设置关系型数据库配置的安全区域
    ret = OH_Rdb_SetArea(rdbConfig, RDB_SECURITY_AREA_EL1);
    // 设置数据库配置
    ret = OH_Retrieval_SetDbConfig(dbConfig, rdbConfig);
    // 把数据库配置添加到检索器中
    ret = OH_Retrieval_AddConfig(config, Retrieval_TYPE_VECTOR, dbConfig);
  5. 执行检索:使用前一步获取到的检索器,配合检索条件进行检索。

    // 创建检索器
    OH_Retrieval_Retriever* retriever = nullptr;
    ret = OH_Retrieval_CreateRetriever(config, &retriever);
    // 创建检索词
    // 创建检索词query
    OH_Retrieval_Query *query = OH_Retrieval_CreateQuery();
    // 设置检索词
    const char *question = "how old are you";
    int ret = OH_Retrieval_SetOriginalQuestion(query, question);
    // 创建检索条件
    OH_Retrieval_Condition *condition = OH_Retrieval_CreateCondition();
    // 创建向量检索条件
    OH_Retrieval_SubCondition *subCondition = OH_Retrieval_CreateVectorCondition();
    // 在检索条件中,设置向量检索结果数量上限
    int ret = OH_Retrieval_SetVectorRecallLimit(subCondition, 10);
    // 在检索条件中,设置向量检索的相似度阈值
    ret = OH_Retrieval_SetSimilarityThreshold(subCondition, 0.35);
    // 把向量检索条件添加到检索条件中
    ret = OH_Retrieval_AddSubCondition(condition, subCondition);
    // 创建检索结果
    OH_Retrieval_Record *records = AipRetrievalRecordBuilder::CreateAipRetrievalRecord();
    // 定义检索完成返回结果的回调函数
    static void Callback(void *context, OH_Retrieval_Record *record)
    {
    // 获取Record长度
    uint32_t length = 0;
    int ret = OH_Retrieval_GetRecordLength(record, &length);

    // 获取Record
    OH_Retrieval_RecordItem *item = nullptr;
    ret = OH_Retrieval_GetRecordItem(record, 0, &item);

    // 根据字段名获取Item size
    std::string fieldName = "filename_text";
    size_t size = 0;
    ret = OH_Retrieval_GetItemSize(item, fieldName.c_str(), &size);

    // 获取Item
    char value[size + 1];
    ret = OH_Retrieval_GetItemText(item, fieldName.c_str(), value, size);
    }

    // 执行检索
    // 进行检索,入参依次为上面创建的检索器retriever,检索词query,检索条件condition,以及检索完成返回结果的回调函数Callback
    int ret = OH_Retrieval_Retrieve(retriever, query, condition, &Callback);
  6. 销毁相关资源。

    // 销毁检索器配置
    int ret = OH_Retrieval_DestroyConfig(config);
    // 销毁数据库配置
    ret = OH_Retrieval_DestroyDbConfig(dbConfig);
    // 销毁关系型数据库的配置
    ret = OH_Rdb_DestroyConfig(rdbConfig);
    // 销毁检索器
    ret = OH_Retrieval_DestroyRetriever(retriever);
    // 销毁检索词query
    ret = OH_Retrieval_DestroyQuery(query);
    // 销毁向量检索条件
    ret = OH_Retrieval_DestroyVectorCondition(subCondition);
    // 销毁检索条件
    ret = OH_Retrieval_DestroyCondition(condition);

C++完整示例

#include "dataaugmentation/retrieval/aip_retrieval.h"
#include "dataaugmentation/retrieval/aip_retrieval_condition.h"
#include "dataaugmentation/retrieval/aip_retrieval_condition_vector.h"
#include "dataaugmentation/retrieval/aip_retrieval_query.h"
#include "dataaugmentation/retrieval/aip_retrieval_record.h"
#include "dataaugmentation/aip_error_code.h"
#include <string>

size_t g_size = 0;
char g_value[50];

static const char *RETRIEVE_RDB_TEST_PATH = "/data/storage/el2/database/";
const std::string RDB_STORE_PATH = "test.db";

void test() {
OH_Retrieval_Retriever* retriever = nullptr;
OH_Retrieval_Config *config = OH_Retrieval_CreateConfig();
OH_Retrieval_DbConfig *dbConfig = OH_Retrieval_CreateDbConfig();
OH_Rdb_ConfigV2 *rdbConfig = OH_Rdb_CreateConfig();
auto ret = OH_Rdb_SetDatabaseDir(rdbConfig, RETRIEVE_RDB_TEST_PATH);
ret = OH_Rdb_SetStoreName(rdbConfig, RDB_STORE_PATH.c_str());
ret = OH_Rdb_SetBundleName(rdbConfig, "retrievalTest");
ret = OH_Rdb_SetEncrypted(rdbConfig, false);
ret = OH_Rdb_SetSecurityLevel(rdbConfig, 1);
ret = OH_Rdb_SetArea(rdbConfig, 1);
ret = OH_Retrieval_SetDbConfig(dbConfig, rdbConfig);
ret = OH_Retrieval_AddConfig(config, RETRIEVAL_TYPE_VECTOR, dbConfig);
ret = OH_Retrieval_CreateRetriever(config, &retriever);
// build query
OH_Retrieval_Query *query = OH_Retrieval_CreateQuery();
const char *question = "运动";
ret = OH_Retrieval_SetOriginalQuestion(query, question);
// build condition
OH_Retrieval_Condition *condition = OH_Retrieval_CreateCondition();
OH_Retrieval_SubCondition *subCondition = OH_Retrieval_CreateVectorCondition();
ret = OH_Retrieval_SetVectorRecallLimit(subCondition, 10);
ret = OH_Retrieval_SetSimilarityThreshold(subCondition, 0.35);
ret = OH_Retrieval_AddSubCondition(condition, subCondition);
const OH_Retrieval_Callback callback = [](void *context, OH_Retrieval_Record *record, int errCode) {
uint32_t length = 0;
auto ret = OH_Retrieval_GetRecordLength(record, &length);
const OH_Retrieval_RecordItem *item = nullptr;

ret = OH_Retrieval_GetRecordItem(record, 0, &item);

std::string fieldName = "subject";

ret = OH_Retrieval_GetItemSize(item, fieldName.c_str(), &g_size);

ret = OH_Retrieval_GetItemText(item, fieldName.c_str(), g_value, g_size);

ret = OH_Retrieval_DestroyRecord(record);

};

ret = OH_Retrieval_Retrieve(retriever, query, condition, nullptr, &callback);

// destroy
ret = OH_Retrieval_DestroyConfig(config);

ret = OH_Retrieval_DestroyDbConfig(dbConfig);

ret = OH_Rdb_DestroyConfig(rdbConfig);

ret = OH_Retrieval_DestroyRetriever(retriever);

ret = OH_Retrieval_DestroyQuery(query);

ret = OH_Retrieval_DestroyVectorCondition(subCondition);

ret = OH_Retrieval_DestroyCondition(condition);
}