Package: dingodb
python-dingodbThe DingoDB python sdkFirst, you have prepared the DingoDB environment, see the docs athttps://github.com/dingodb/dingo-deploy.gitFor more information about DingoDB, see the docs athttps://dingodb.readthedocs.io/en/latest/How to Contribute1. Compilepip install -r requirements.txt
git submodule update --init --recursive2. ReleaseUsageInstallationInstall from pypipip3installdingodbInstall from Sourcepipinstallgit+https://github.com/dingodb/pydingo.gitBasic APICreating an indexThe following example creates an index without a metadata configuration.>>>importdingodb>>>dingo_client=dingodb.DingoDB("user","password",["172.20.3.20:13000"])>>>dingo_client.create_index("testdingo",6,index_type="flat")Truedingodb provides flexible indexing parameters.>>>help(dingo_client.create_index)create_index(index_name,dimension,index_type='hnsw',metric_type='euclidean',replicas=3,index_config=None,metadata_config=None,partition_rule=None,auto_id=True)Get indexThe following example returns all indexes in your schema.>>>dingo_client.get_index()['testdingo']Get index infoThe following example returns the info in specified index.>>>dingo_client.describe_index_info("testdingo"){'name':'testdingo','version':0,'replica':3,'autoIncrement':1,'indexParameter':{'indexType':'INDEX_TYPE_VECTOR','vectorIndexParameter':{'vectorIndexType':'VECTOR_INDEX_TYPE_FLAT','flatParam':{'dimension':6,'metricType':'METRIC_TYPE_L2'},'ivfFlatParam':None,'ivfPqParam':None,'hnswParam':None,'diskAnnParam':None}}}Add vectorThe following example add vector to database.>>>dingo_client.vector_add("testdingo",[{"a1":"b1","aa1":"bb1"},{"a1":"b1"}],[[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926],[0.27746424078941345,0.801872193813324,0.9581393599510193,0.8759326338768005,0.35781726241111755,0.5009950995445251]])[{'id':1,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926],'binaryValues':[]},'scalarData':{'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]},'aa1':{'fieldType':'STRING','fields':[{'data':'bb1'}]}}},{'id':2,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[0.27746424,0.8018722,0.95813936,0.87593263,0.35781726,0.5009951],'binaryValues':[]},'scalarData':{'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]}}}]Get MAX IDyou can use autoIncrement id, The following example get max id>>>dingo_client.get_max_index_row("testdingo")2Search VectorThe following example Basic Search without metata.>>>dingo_client.vector_search("testdingo",[[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926]],10)[{'vectorWithDistances':[{'id':1,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[],'binaryValues':[]},'scalarData':{'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]},'aa1':{'fieldType':'STRING','fields':[{'data':'bb1'}]}},'distance':0.0},{'id':2,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[],'binaryValues':[]},'scalarData':{'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]}},'distance':0.5491189}]}]The following example Search with metata.>>>dingo_client.vector_search("testdingo",[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926],10,{"meta_expr":{"aa1":"bb1"}}){'vectorWithDistances':[{'id':1,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[],'binaryValues':[]},'scalarData':{'aa1':{'fieldType':'STRING','fields':[{'data':'bb1'}]},'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]}},'distance':0.0}]}Query vector with idsThe following example Query vector with ids.>>>dingo_client.vector_get("testdingo",[2])[{'id':2,'vector':{'dimension':6,'valueType':'FLOAT','floatValues':[0.27746424,0.8018722,0.95813936,0.87593263,0.35781726,0.5009951],'binaryValues':[]},'scalarData':{'a1':{'fieldType':'STRING','fields':[{'data':'b1'}]}}}]Detele vector with idsThe following example Detele vector with ids.>>>dingo_client.vector_delete("testdingo",[2])[True]Drop indexThe following example Drop one index.>>>dingo_client.delete_index("testdingo")True