couchbasecouchbase-analyticscouchbase-indexing

Couchbase analytics: create index compilation error


I'm trying to create an index on a couchbase analytics node:

CREATE INDEX `index_analytics_user_id` 
ON `requests`(userId:string)

When I run this on a couchbase I have running locally it works fine. However when I run it on the larger scale development environment (with multiple data and index nodes and a separate analytics node) I get an error. Locally I run Couchbase 6.5.0. and the development environment runs Couchbase 6.0.2:

[
  {
    "code": 24001,
    "msg": "Compilation error: Dataset Default.requests is currently being fed into by the following active entities.\nDefault.Local.data(CouchbaseMetadataExtension)\n (in line 1, at column 1)",
    "query_from_user": "CREATE INDEX `index_analytics_user_id` \nON `requests`(userId:string)"
  }
]

How do I fix this? thanks!


Solution

  • In Couchbase Analytics 6.0.x you need to manually stop data ingestion (disconnect the link) before issuing CREATE INDEX statement:

    DISCONNECT LINK Local;
    CREATE INDEX ...
    CONNECT LINK Local;
    

    For more information see https://docs.couchbase.com/server/6.0/analytics/5_ddl.html#Connecting_and_disconnecting

    In 6.5.0 this step is no longer necessary. The system automatically disconnects the link when processing CREATE INDEX and reconnects it after the index is built.