N1QL C# queries always return index out of range errors

4.1
.net
n1ql

#1

I’ve been attempting to use N1QL for what seems to be an eternity now. Nothing ever works. Running queries through the couchbase-cli works fine (kindof).

Attempting to run N1QL queries from the .Net SDK has been like trying to enter your car while the keys are locked inside, using only your teeth.

*Or at least for the moment…

I’ve been unable to find any decent example - I know the primary index is supposed to be built (even though that isn’t in the documentation…), however even THAT doesn’t seem to work;

Here is what I’m trying at the moment:

var createIndexQuery = new QueryRequest().Statement("CREATE PRIMARY INDEX ON 'DataBoard' USING GSI");
result = _bucket.Query<dynamic>(createIndexQuery);

the result is always: Index was out of range. Must be non-negative and less than the size of the collection.

Checking to see if an index is already created is just as unsuccessful. Same goes with any select N1QL queries.

I have a cluster which has 3 nodes with Index, Query and Data enabled


#2

So no clue why but after building and then dropping the primary index with cbq I was then finally able to create the primary index through the sdk.

_bucket.Query<dynamic>(QueryRequest.Create("CREATE PRIMARY INDEX ON DataBoard"));