How to create a TEXT index in CouchDB 2.0?
Asked Answered
U

1

7

I'm reading this article https://cloudant.com/blog/mango-json-vs-text-indexes and I would like to create a TEXT index in my CouchDB

In the Fauxton -> Mango Indexes page, I posted

{
  "index": {
    "fields": [
      {
        "name": "id_str",
        "type": "number"
      }
    ]
  },
  "name": "doc_id",
  "type": "text"
}

...but got a 503 error with the following message:

{"error":"required index service unavailable","reason":"text"}

I wasn't able to find even any related info in their documentation and I feel really lost now.

So:

  1. How to create a TEXT index in CouchDB?
  2. Where can I find a decent introduction to indexes in CouchDB?

Please help, thanks.

Unlettered answered 21/4, 2017 at 4:51 Comment(6)
The documentation on indexes are in the section about the Mango query server. I don't believe "text" is available, you should use "string" instead. (though I'm partly guessing, so I'm using a comment instead of an answer to start)Harris
@DominicBarnes No luck :( Tried several combinations of field types and index types and failed with either required index service unavailable or invalid_indexUnlettered
It's telling you that you don't have the dreyfus_index module. How to add it and why it might not work to add it late: github.com/apache/couchdb/pull/480#issuecomment-294981458Detent
@Detent So the original Apache CouchDB supports only json index?Unlettered
Yes, when built with the defaults, since couchdb's text index support is via an external module that is not a default dependency. Binaries from after that recent pull will now recognize the module if added later, while before that pull the only option was rebuilding couchdb from source with dreyfus present, i.e. via the line for it in the rebar config.Detent
@Detent Many thanks. Could you please add an answer so I can accept it?Unlettered
D
4

This error is different than an unknown index type since Couchdb 2.0 has stubs for text indexes, but doesn't directly implement them. These stubs depend on a dreyfus text index module provided by cloudant.

A guide to configuring and recompiling couchdb 2.0+ with Dreyfus (and its Clouseau dependency) can be found here. (I verified that these instructions work with the latest couchdb and dreyfus master branches as of 2017-04-22.)

Detent answered 23/4, 2017 at 21:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.