Getting NullPointerException while creating FTS index on newly couchbase docker image
Description
I am getting Null pointer exception in following class:
AsyncSearchIndexManager.java:171
-> getAllIndexes()
-> return new ArrayList<>(indexes.values());
Here indexes is null and because of that I am getting error.
Reproduce step:
Start fresh Couchbase docker image,
try to create FTS index from java code, it fails due to NullPointerException.
Workaround:
1. Create any FTS index from Couchbase UI
2. Remove created FTS index ( remove if u want, that does not matter )
3. Run java code to execute FTS index, it works.
It works only if we create at-least one manually.
The reason is because
"/api/index" is returning response { "status" : "ok", "indexDefs" : null } when we try to create index on fresh docker image because here indexDefs is null, it causing NullPointerException.
And after we create & delete any FTS index manually and after that we are getting different response { "status" : "ok", "indexDefs" : { "uuid" :"XXXX", "indexDefs": {}, "implVersion" :"5.6.0" } }
@Hiren Soni yeah I reproduced your issue locally, it is as you described. We have the same issue in the scala SDK so I fixed it there as well in one go.
Hiren Soni August 19, 2022 at 7:23 AM
I was trying to create an search index from code. It was internally performing getIndex by name and if it exists then update and if not create index.
so here in desc i mentioned that i am getting error in create index but it is incorrect. i was getting error in get Index by name sdk api.
I am sure by looking at screenshot you might have figured it out. But just wanted to clarify. Thanks.
Right now i have taken care by handling NullPointerException.
Michael Nitschinger August 19, 2022 at 7:20 AM
Thank you for reporting! Bugfix is underway and will be part of our september release.
Fixed
Pinned fields
Click on the next to a field label to start pinning.
I am getting Null pointer exception in following class:
AsyncSearchIndexManager.java:171
-> getAllIndexes()
-> return new ArrayList<>(indexes.values());
Here indexes is null and because of that I am getting error.
Reproduce step:
Start fresh Couchbase docker image,
try to create FTS index from java code, it fails due to NullPointerException.
Workaround:
1. Create any FTS index from Couchbase UI
2. Remove created FTS index ( remove if u want, that does not matter )
3. Run java code to execute FTS index, it works.
It works only if we create at-least one manually.
The reason is because
"/api/index" is returning response { "status" : "ok", "indexDefs" : null } when we try to create index on fresh docker image because here indexDefs is null, it causing NullPointerException.
And after we create & delete any FTS index manually and after that we are getting different response { "status" : "ok", "indexDefs" : { "uuid" :"XXXX", "indexDefs": {}, "implVersion" :"5.6.0" } }