Navid_pdp11
Navid_pdp11

Reputation: 4012

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?

Upvotes: 2

Views: 255

Answers (1)

pgupta
pgupta

Reputation: 5415

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

Upvotes: 4

Related Questions