简体   繁体   中英

How can I get List of indexes from Aerospike server By C# client?

I have an application that persists its Data in an Aerospike database but in the first run of my application, I must create all Indices. Now I want to know is there any right approach to create these indices by My code? I know there is a CreateIndex method but I want to know the existence of indices and then create the absences.

Is there any way to get all names of indexes from the server? if the answer is no can I run an AQL query such as:

show indexes

by my client directly?

You will have to implement the Info class in C# client and get and parse "sindex-list:" - see this as a starting point: https://github.com/aerospike/aerospike-client-csharp/blob/b6c777c862000da1caf1281980e8dbe76bf931e7/Framework/AerospikeTest/Sync/Basic/TestServerInfo.cs You will have to use public static string Request( Connection conn, string name ) and use "sindex-list:" as the value to retrieve and then parse the semi-colon separated output. The server will return something like this (here I have two sindexes idx_age and idx_name): $ asinfo -v "sindex-list:" ns=test:set=testset:indexname=idx_age:bin=age:type=NUMERIC:indextype=NONE:path=age:state=RW;ns=test:set=testset:indexname=idx_name:bin=name:type=STRING:indextype=NONE:path=name:state=RW

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM