alibaba / havenask

Apache License 2.0
1.6k stars 302 forks source link

直写表是否支持向量索引? #167

Closed supercocoa closed 7 months ago

supercocoa commented 1 year ago
#本地单机模式下创建直写表:
hape create table -t in_direct_vector1 -p 1 -s /ha3_install/example/cases/vector/in0_schema.json -c /ha3_install/hape_conf/default

#插入两条测试数据
/ha3_install/sql_query.py  --address  http://127.0.0.1:45800 --query "insert into in_direct_vector1 (id,vector,url)values(1, '0.57350874,0.20913178,-0.28007376,-0.008224763,0.032035876,-0.06109254,0.016208794,0.2546715,-0.5938332,0.2194785,-0.603397,0.095939286,-0.4343296,0.29292983,0.19570276,0.07006806,0.4219676,0.008796717,-0.1956801,0.10365201,-0.18756211,-0.1959297,-0.64994687,-0.0043594907,-0.12155021,-0.37211925,-0.033330534,0.37927315,0.14685613,0.14631498,0.2263155,0.020013737,-0.48688003,0.38279092,-0.14551091,-0.14309452,0.0836372,-0.2602252,-0.68886805,-0.18670991,0.026953692,-0.1361577,0.54825664,0.5495113,-0.11404511,0.020755235,-0.3592109,0.35327643,-0.17384957,0.06951289,-0.33219633,0.32536888,0.4178303,0.06838637,-0.32600296,-0.39717215,0.37040582,0.2577843,-0.022891786,-0.19590716,-0.34784496,0.45056996,-0.16618372,-0.048093718,-0.4501398,0.16741453,0.0021240758,-0.22811683,-0.30895764,-0.29165566,0.51220524,0.26545066,-0.46743664,-0.18925984,0.11317849,0.01674415,-0.41176468,-0.41503182,-0.52814317,-0.52559006,0.5788051,0.12608618,0.62300944,0.20152776,-0.39167175,0.099368036,0.34757188,-0.2860248,0.47917366,0.44290003,-0.3663736,0.074007034,-0.44493687,0.5212625,0.5742631,0.06809457,0.20434684,-0.2527957,0.08273791,-0.5062737,0.30677673,0.0037546167,0.53646725,0.6939553,-0.19357872,0.62397563,-0.25602227,-0.73345435,0.23730282,-0.11466419,-0.22964483,-0.18373214,-0.28414255,0.67296755,0.38798898,-0.0795316,0.050292946,0.51636153,-0.3399461,0.14268692,-0.5273593,-0.055386372,-0.29121432,-0.36689624,0.762627,0.14242941,0.14173277,0.08323621', 'xxxxx/image1.jpg')"

/ha3_install/sql_query.py  --address  http://127.0.0.1:45800 --query "insert into in_direct_vector1 (id,vector,url)values(2, '-0.35924008,-0.13930316,0.18632334,-0.049376365,0.10277805,0.31108105,0.42331377,0.44774255,0.08123136,0.29325688,0.45717216,-0.02390457,0.05483234,0.4175739,-0.46713817,-0.06452753,0.4286885,0.3744277,0.15439382,0.55404866,0.5342495,0.46050805,-0.03884911,-0.019017374,0.10130607,-0.21174453,0.39987513,0.26442122,-0.35893446,-0.36284935,0.11842794,-0.34458843,-0.06558441,0.08548755,-0.6601133,0.091081105,-0.03206316,-0.2888596,-0.38375577,-0.5003725,0.016377972,0.442732,-0.3569754,0.3478197,0.46378177,0.025638321,-0.4501313,-0.42392847,0.05736165,0.29771292,-0.15028134,-0.12384661,-0.23179723,0.2059954,-0.102884315,-0.2754259,-0.30828795,0.19638318,-0.19054835,-0.6414785,-0.2647812,0.057648554,0.04965813,-0.28074825,-0.32216832,-0.38855934,0.09908297,0.05360724,0.12622863,-0.074440636,-0.7750558,0.15636945,-0.7046008,0.15720405,0.7530303,-0.40988195,-0.19618246,0.48107624,0.13173543,0.24198954,0.03513013,0.20660909,-0.34926963,-0.20776041,-0.1051571,0.7480082,-0.17043045,0.43317652,0.3295459,-0.12615016,0.18828143,0.15157636,-0.07326457,0.09717075,-0.0011057385,-0.7695231,0.3937015,0.19094227,0.43463233,0.6424432,-0.39811704,-0.06953235,0.44360211,-0.087331794,0.016823096,-0.39307374,-0.8374116,-0.059896108,0.10598784,-0.09788999,0.5688673,0.1977485,-0.31525692,0.509286,-0.61332095,-0.023960741,-0.2559408,0.29615593,-0.0066333786,0.056579597,0.12605546,0.30335674,-0.49338692,0.19770066,0.42003533,0.39307922,0.24363708,-0.47094932', 'xxxxx/image2.jpg')"

#全量查询有结果返回
/ha3_install/sql_query.py  --address  http://127.0.0.1:45800 --query "select * from in_direct_vector1"

Request address:[http://127.0.0.1:45800/QrsService/searchSql] query:[select * from in_direct_vector1&&kvpair=databaseName:database;formatType:string]
USE_TIME: 54.021ms, ROW_COUNT: 2, HAS_SOFT_FAILURE: 0, COVERAGE: 1

------------------------------- TABLE INFO ---------------------------
total:2, rows:[0, 2), cols:3
                 id (uint32) |            url (multi_char) |         vector (multi_char) |
                           1 |            xxxxx/image1.jpg |0.57350874,0.20913178,-0.28007376,-0.008224763,0.032035876,-0.06109254,0.016208794,0.2546715,-0.5938332,0.2194785,-0.603397,0.095939286,-0.4343296,0.29292983,0.19570276,0.07006806,0.4219676,0.008796717,-0.1956801,0.10365201,-0.18756211,-0.1959297,-0.64994687,-0.0043594907,-0.12155021,-0.37211925,-0.033330534,0.37927315,0.14685613,0.14631498,0.2263155,0.020013737,-0.48688003,0.38279092,-0.14551091,-0.14309452,0.0836372,-0.2602252,-0.68886805,-0.18670991,0.026953692,-0.1361577,0.54825664,0.5495113,-0.11404511,0.020755235,-0.3592109,0.35327643,-0.17384957,0.06951289,-0.33219633,0.32536888,0.4178303,0.06838637,-0.32600296,-0.39717215,0.37040582,0.2577843,-0.022891786,-0.19590716,-0.34784496,0.45056996,-0.16618372,-0.048093718,-0.4501398,0.16741453,0.0021240758,-0.22811683,-0.30895764,-0.29165566,0.51220524,0.26545066,-0.46743664,-0.18925984,0.11317849,0.01674415,-0.41176468,-0.41503182,-0.52814317,-0.52559006,0.5788051,0.12608618,0.62300944,0.20152776,-0.39167175,0.099368036,0.34757188,-0.2860248,0.47917366,0.44290003,-0.3663736,0.074007034,-0.44493687,0.5212625,0.5742631,0.06809457,0.20434684,-0.2527957,0.08273791,-0.5062737,0.30677673,0.0037546167,0.53646725,0.6939553,-0.19357872,0.62397563,-0.25602227,-0.73345435,0.23730282,-0.11466419,-0.22964483,-0.18373214,-0.28414255,0.67296755,0.38798898,-0.0795316,0.050292946,0.51636153,-0.3399461,0.14268692,-0.5273593,-0.055386372,-0.29121432,-0.36689624,0.762627,0.14242941,0.14173277,0.08323621 |
                           2 |            xxxxx/image2.jpg |-0.35924008,-0.13930316,0.18632334,-0.049376365,0.10277805,0.31108105,0.42331377,0.44774255,0.08123136,0.29325688,0.45717216,-0.02390457,0.05483234,0.4175739,-0.46713817,-0.06452753,0.4286885,0.3744277,0.15439382,0.55404866,0.5342495,0.46050805,-0.03884911,-0.019017374,0.10130607,-0.21174453,0.39987513,0.26442122,-0.35893446,-0.36284935,0.11842794,-0.34458843,-0.06558441,0.08548755,-0.6601133,0.091081105,-0.03206316,-0.2888596,-0.38375577,-0.5003725,0.016377972,0.442732,-0.3569754,0.3478197,0.46378177,0.025638321,-0.4501313,-0.42392847,0.05736165,0.29771292,-0.15028134,-0.12384661,-0.23179723,0.2059954,-0.102884315,-0.2754259,-0.30828795,0.19638318,-0.19054835,-0.6414785,-0.2647812,0.057648554,0.04965813,-0.28074825,-0.32216832,-0.38855934,0.09908297,0.05360724,0.12622863,-0.074440636,-0.7750558,0.15636945,-0.7046008,0.15720405,0.7530303,-0.40988195,-0.19618246,0.48107624,0.13173543,0.24198954,0.03513013,0.20660909,-0.34926963,-0.20776041,-0.1051571,0.7480082,-0.17043045,0.43317652,0.3295459,-0.12615016,0.18828143,0.15157636,-0.07326457,0.09717075,-0.0011057385,-0.7695231,0.3937015,0.19094227,0.43463233,0.6424432,-0.39811704,-0.06953235,0.44360211,-0.087331794,0.016823096,-0.39307374,-0.8374116,-0.059896108,0.10598784,-0.09788999,0.5688673,0.1977485,-0.31525692,0.509286,-0.61332095,-0.023960741,-0.2559408,0.29615593,-0.0066333786,0.056579597,0.12605546,0.30335674,-0.49338692,0.19770066,0.42003533,0.39307922,0.24363708,-0.47094932 |

------------------------------- PLAN INFO ---------------------------
SQL QUERY:
select * from in_direct_vector1&&kvpair=databaseName:database;formatType:string
IQUAN_RESULT:
{"error_code":0,"error_message":"","result":{"rel_plan_version":"","rel_plan":[],"exec_params":{}}}

------------------------------- TRACE INFO ---------------------------

#向量索引查询没有结果返回
/ha3_install/sql_query.py  --address  http://127.0.0.1:45800 --query "select id,url from in_direct_vector1 where MATCHINDEX('vector_index', '0.57350874,0.20913178,-0.28007376,-0.008224763,0.032035876,-0.06109254,0.016208794,0.2546715,-0.5938332,0.2194785,-0.603397,0.095939286,-0.4343296,0.29292983,0.19570276,0.07006806,0.4219676,0.008796717,-0.1956801,0.10365201,-0.18756211,-0.1959297,-0.64994687,-0.0043594907,-0.12155021,-0.37211925,-0.033330534,0.37927315,0.14685613,0.14631498,0.2263155,0.020013737,-0.48688003,0.38279092,-0.14551091,-0.14309452,0.0836372,-0.2602252,-0.68886805,-0.18670991,0.026953692,-0.1361577,0.54825664,0.5495113,-0.11404511,0.020755235,-0.3592109,0.35327643,-0.17384957,0.06951289,-0.33219633,0.32536888,0.4178303,0.06838637,-0.32600296,-0.39717215,0.37040582,0.2577843,-0.022891786,-0.19590716,-0.34784496,0.45056996,-0.16618372,-0.048093718,-0.4501398,0.16741453,0.0021240758,-0.22811683,-0.30895764,-0.29165566,0.51220524,0.26545066,-0.46743664,-0.18925984,0.11317849,0.01674415,-0.41176468,-0.41503182,-0.52814317,-0.52559006,0.5788051,0.12608618,0.62300944,0.20152776,-0.39167175,0.099368036,0.34757188,-0.2860248,0.47917366,0.44290003,-0.3663736,0.074007034,-0.44493687,0.5212625,0.5742631,0.06809457,0.20434684,-0.2527957,0.08273791,-0.5062737,0.30677673,0.0037546167,0.53646725,0.6939553,-0.19357872,0.62397563,-0.25602227,-0.73345435,0.23730282,-0.11466419,-0.22964483,-0.18373214,-0.28414255,0.67296755,0.38798898,-0.0795316,0.050292946,0.51636153,-0.3399461,0.14268692,-0.5273593,-0.055386372,-0.29121432,-0.36689624,0.762627,0.14242941,0.14173277,0.08323621&n=10')"

Request address:[http://127.0.0.1:45800/QrsService/searchSql] query:[select id,url from in_direct_vector1 where MATCHINDEX('vector_index', '0.57350874,0.20913178,-0.28007376,-0.008224763,0.032035876,-0.06109254,0.016208794,0.2546715,-0.5938332,0.2194785,-0.603397,0.095939286,-0.4343296,0.29292983,0.19570276,0.07006806,0.4219676,0.008796717,-0.1956801,0.10365201,-0.18756211,-0.1959297,-0.64994687,-0.0043594907,-0.12155021,-0.37211925,-0.033330534,0.37927315,0.14685613,0.14631498,0.2263155,0.020013737,-0.48688003,0.38279092,-0.14551091,-0.14309452,0.0836372,-0.2602252,-0.68886805,-0.18670991,0.026953692,-0.1361577,0.54825664,0.5495113,-0.11404511,0.020755235,-0.3592109,0.35327643,-0.17384957,0.06951289,-0.33219633,0.32536888,0.4178303,0.06838637,-0.32600296,-0.39717215,0.37040582,0.2577843,-0.022891786,-0.19590716,-0.34784496,0.45056996,-0.16618372,-0.048093718,-0.4501398,0.16741453,0.0021240758,-0.22811683,-0.30895764,-0.29165566,0.51220524,0.26545066,-0.46743664,-0.18925984,0.11317849,0.01674415,-0.41176468,-0.41503182,-0.52814317,-0.52559006,0.5788051,0.12608618,0.62300944,0.20152776,-0.39167175,0.099368036,0.34757188,-0.2860248,0.47917366,0.44290003,-0.3663736,0.074007034,-0.44493687,0.5212625,0.5742631,0.06809457,0.20434684,-0.2527957,0.08273791,-0.5062737,0.30677673,0.0037546167,0.53646725,0.6939553,-0.19357872,0.62397563,-0.25602227,-0.73345435,0.23730282,-0.11466419,-0.22964483,-0.18373214,-0.28414255,0.67296755,0.38798898,-0.0795316,0.050292946,0.51636153,-0.3399461,0.14268692,-0.5273593,-0.055386372,-0.29121432,-0.36689624,0.762627,0.14242941,0.14173277,0.08323621&n=10')&&kvpair=databaseName:database;formatType:string]
USE_TIME: 66.34ms, ROW_COUNT: 0, HAS_SOFT_FAILURE: 0, COVERAGE: 1

------------------------------- TABLE INFO ---------------------------
total:0, rows:[0, 0), cols:2
                 id (uint32) |            url (multi_char) |

------------------------------- PLAN INFO ---------------------------
SQL QUERY:
select id,url from in_direct_vector1 where MATCHINDEX('vector_index', '0.57350874,0.20913178,-0.28007376,-0.008224763,0.032035876,-0.06109254,0.016208794,0.2546715,-0.5938332,0.2194785,-0.603397,0.095939286,-0.4343296,0.29292983,0.19570276,0.07006806,0.4219676,0.008796717,-0.1956801,0.10365201,-0.18756211,-0.1959297,-0.64994687,-0.0043594907,-0.12155021,-0.37211925,-0.033330534,0.37927315,0.14685613,0.14631498,0.2263155,0.020013737,-0.48688003,0.38279092,-0.14551091,-0.14309452,0.0836372,-0.2602252,-0.68886805,-0.18670991,0.026953692,-0.1361577,0.54825664,0.5495113,-0.11404511,0.020755235,-0.3592109,0.35327643,-0.17384957,0.06951289,-0.33219633,0.32536888,0.4178303,0.06838637,-0.32600296,-0.39717215,0.37040582,0.2577843,-0.022891786,-0.19590716,-0.34784496,0.45056996,-0.16618372,-0.048093718,-0.4501398,0.16741453,0.0021240758,-0.22811683,-0.30895764,-0.29165566,0.51220524,0.26545066,-0.46743664,-0.18925984,0.11317849,0.01674415,-0.41176468,-0.41503182,-0.52814317,-0.52559006,0.5788051,0.12608618,0.62300944,0.20152776,-0.39167175,0.099368036,0.34757188,-0.2860248,0.47917366,0.44290003,-0.3663736,0.074007034,-0.44493687,0.5212625,0.5742631,0.06809457,0.20434684,-0.2527957,0.08273791,-0.5062737,0.30677673,0.0037546167,0.53646725,0.6939553,-0.19357872,0.62397563,-0.25602227,-0.73345435,0.23730282,-0.11466419,-0.22964483,-0.18373214,-0.28414255,0.67296755,0.38798898,-0.0795316,0.050292946,0.51636153,-0.3399461,0.14268692,-0.5273593,-0.055386372,-0.29121432,-0.36689624,0.762627,0.14242941,0.14173277,0.08323621&n=10')&&kvpair=databaseName:database;formatType:string
IQUAN_RESULT:
{"error_code":0,"error_message":"","result":{"rel_plan_version":"","rel_plan":[],"exec_params":{}}}

------------------------------- TRACE INFO ---------------------------

看日志一直在报这个错

[2023-10-22 10:36:55.959548] [ERROR] [1374,aios/storage/indexlib/framework/VersionMerger.cpp -- InnerExecuteTask():244] [[in_direct_vector1/0/0_65535] [0x10108f0150] currentVersionId is invalid version]
dyuyang commented 1 year ago

example里面的向量索引例子vector能正常运行吗

supercocoa commented 1 year ago

就是用的example里的 @dyuyang

dyuyang commented 1 year ago

跑case应该是用python /ha3_install/example/common/case.py run --case vector命令吧,直接用这个命令能查询吗