Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

loopback API GET no usable index for cloudant database

3100004SW4 gravatar image
Question by amilab  (81) | Jan 06, 2016 at 08:15 PM apicloudantibmcloudloopback

I am using loopback-connector-cloudant and I am able to connect to the IBM bluemix cloudant service by using the credentials.

I am able to post json data record into the created database in the cloudant by using the loopback API explorer POST method for the model.

However when I tried to use loopback API explorer GET to read the posted data from the cloudant database, I got the "no_usable_index" error.

 {
   "error": {
     "name": "Error",
     "status": 400,
     "message": "No index matches the index specified with \"use_index\"",
     "error": "no_usable_index",
     "reason": "No index matches the index specified with \"use_index\"",
     "scope": "couch",
     "statusCode": 400,
     "request": {
       "method": "post",
       "headers": {
         "content-type": "application/json",
         "accept": "application/json"
       },
       "uri": "https://XXXXXX:XXXXXX@c381c9d9-7502-4bff-ae2f-69f7ba646ade-bluemix.cloudant.com/camera/_find",
       "body": "{\"selector\":{\"loopback__model__name\":\"Camera\"},\"use_index\":[\"lb-index-ddoc-Camera\",\"lb-index-Camera\"]}"
     },
     "headers": {
       "x-couch-request-id": "d2d09498da",
       "date": "Thu, 07 Jan 2016 02:06:47 GMT",
       "content-type": "application/json",
       "cache-control": "must-revalidate",
       "strict-transport-security": "max-age=31536000",
       "x-content-type-options": "nosniff;",
       "connection": "close",
       "statusCode": 400,
       "uri": "https://XXXXXX:XXXXXX@c381c9d9-7502-4bff-ae2f-69f7ba646ade-bluemix.cloudant.com/camera/_find"
     },
     "errid": "non_200",
     "description": "couch returned 400",
     "stack": "Error: No index matches the index specified with \"use_index\"\n    at Request._callback (/home/vcap/app/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/nano/lib/nano.js:248:15)\n    at Request.self.callback (/home/vcap/app/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/nano/node_modules/request/request.js:198:22)\n    at Request.emit (events.js:110:17)\n    at Request.<anonymous> (/home/vcap/app/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/nano/node_modules/request/request.js:1082:10)\n    at Request.emit (events.js:129:20)\n    at IncomingMessage.<anonymous> (/home/vcap/app/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/nano/node_modules/request/request.js:1009:12)\n    at Object.forward (/home/vcap/app/node_modules/strong-start/node_modules/strong-pm/node_modules/strong-runner/node_modules/strong-supervisor/node_modules/strong-agent/lib/proxy.js:79:23)\n    at IncomingMessage.eval (eval at wrap (/home/vcap/app/node_modules/strong-start/node_modules/strong-pm/node_modules/strong-runner/node_modules/strong-supervisor/node_modules/strong-agent/lib/proxy.js:201:20), <anonymous>:3:21)\n    at IncomingMessage.emit (events.js:129:20)"
   }
 }

I can see that the loopback is trying to use index of lb-index-ddoc-Camera and lb-index-Camera but couldn't find the matches index in the database.

What should I do? Should I create such index with the same name as lb-index-ddoc-Camera and lb-index-Camera? Where are these index come from?

Anyone have been successfully used the loopback-connector-cloudant?

In the meantime I will try to use loopback-connector-couch instead.

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

6 answers

  • Sort: 
3100004SW4 gravatar image
Accepted answer

Answer by amilab (81) | Jan 06, 2016 at 09:16 PM

I solved the issue.

The reason my GET method is not working for loopback is that the index is not build when using the loopback-connector-cloudant due to wrong configuration format in the datasource.json file.

I used the below format and it works.

 "mydb": {
   "name": "mydb",
   "connector": "cloudant",
   "username": "XXXX-bluemix",
   "password": "YYYYYYYYYYYY",
   "database": "test"
 }
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
27000599UN gravatar image

Answer by Ryan Cox (95) | Sep 30, 2016 at 03:48 PM

Can you explain what you changed in the datasource.json that made this work? I'm having the same issue and it looks like you only removed the "modelIndex" attribute. I've removed this attribute as well and still get the same "No index matches the index specified with \"use_index\"" error.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270002T4FQ gravatar image

Answer by Sebastián Vergara (1) | May 01, 2017 at 07:17 PM

I removed the url property, added the username and password and started working.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270005CMYX gravatar image

Answer by Henrik_Warfvinge (1) | Jan 09, 2018 at 07:31 AM

Hi, you must have done something different then just this no ? I have this problem now. First time I get it and it should work. Will look more for answers but any more thoughts around this ?? Thanks!

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270005CMYX gravatar image

Answer by Henrik_Warfvinge (1) | Jan 09, 2018 at 07:55 AM

Okey, so should not have anything to do with the URL to cloudant. My misstake was to now have created a GET service in my node.js loopback app - which in turn made my request fail. It works even with the URL included in the datascource.json file. Cheers

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270007TC5N gravatar image

Answer by NorthDecoder (3) | Feb 28, 2018 at 10:22 AM

Just using the Loopback API explorer GET try this button I am getting a very similar result:

 {
   "error": {
     "statusCode": 400,
     "name": "Error",
     "message": "No index exists for this sort, try indexing by the sort fields.",
     "error": "no_usable_index",
     "reason": "No index exists for this sort, try indexing by the sort fields.",
     "scope": "couch", ...

So I tried searching the lb3 documentation and found a cloudant-connector :link: that describes the index feature as "To be updated". Hmmm, it is listed as a feature backlog.

Then I found :link: to the Model-definition-JSON-file which describes manually adding an indexes property. I tried:

   // common -> models -> center.json
   "indexes": {
       "name_index": {"name": 1}
   }, ...

I also tried the suggestion: "You can specify indexes at the model property level too, for example:"

   "properties": {
     "name": {
       "type": "string",
       "required": true,
       "index": true   // added this (but without the comment :)
     }, ...

Alas, none of this worked. I am still getting the error.

I have watched several youtube videos of Loopback with MongoDB, but it is curious that there is not much available showing exactly how to get the Loopback-connector to work with Cloudant.


After much troubleshooting in the old version I found that the error went away when I changed

FROM loopback-connector-cloudant@1.2.5 3-Aug 2017

TO loopback-connector-cloudant@2.0.5 23-Mar 2018

by updating the package.json and running an npm update

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

56 people are following this question.

Answers

Answers & comments

Related questions

Restaging of application in Bluemix failed 0 Answers

One Database Per User Design for Cloudant Loopback (NodeJS) IOS mobile 0 Answers

HTTP 500 Internal Server Error using all APIs on Bluemix Apiconnect 2 Answers

APIC to Cloudant on Bluemix 2 Answers

Cloudant Heavy API calls charging 3 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges