I have a question about 'IndexDoesNotExistException' with java in couchbase



Hi! guys.
I have a problem about exception. I need your help.

This is my test code. My bucket name is ‘test’ and it doesn’t have index. Then, I think that code throws the ‘IndexDoesNotExistException’. but Nothing happened. Why?

(*IndexDoesNotExistException) - reference middle of this document

I have other bucket with index. This case is successful. So, I guess that cause of the problem is index.

Do I have to use the ‘finalSuccess()’? I don’t want to make every exception handling.

I added dependency in my pom.xml


My env.

  • java (jdk 1.8) with spring framework (not use spring-data)
  • couchbase server 5.0.1


So it sounds like you don’t have an index setup on your bucket, you’re running a N1QL query against it, and you’re not getting the IndexDoesNotExistException you expect - is that correct?

Does the primary index definitely not exist, e.g. you’ve confirmed in the UI Index tab?


Thank you for reply. graham.pople :slight_smile:

yeah, You’re right. I don’t get the IndexDoesNotExistException.
My ‘test’ bucket doesn’t have a primary index either.

Primary index is kind of index. right? So, I expect to get the exception. but, It’s not.

If I use dropN1qlIndex() when didn’t setup index on my ‘test’ bucket, and I get the IndexDoesNotExistException. Is it only for dropN1qlIndex()? Do I make exception handling every time?


Ok, thanks for confirming. And yes I’d expect you to get an error without an index.

Can you double-check that the index doesn’t exist? You can query which indexes exist using the methods in this doc https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0003-indexmanagement.md#listing-indexes.

E.g. a N1QL query “SELECT idx.* FROM system:indexes AS idx WHERE keyspace_id = BUCKET_NAME_INJECTED_HERE AND using = “gsi” ORDER BY is_primary DESC, name ASC;”

or method listN1qlIndexes().


Exactly, I have no index in ‘test’ bucket.
I have only ‘board’ bucket index. If I drop the index in ‘board’ bucket, and difference is nothing.


Ok, thank you for confirming.

I checked with my colleagues, and in the advent of a lack of index, you’re going to get an error in your results, as opposed to a thrown exception (as a sidenote, this is with the exception of a handful of N1QL queries that don’t need an index - see https://blog.couchbase.com/perform-various-n1ql-queries-without-indexes-couchbase-server/ if interested).


You need to check status field before accessing rest of the results

status enum The status of the request. Possible values are: success, running, errors, completed, stopped, timeout, fatal.