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.

Frederick Zhang
  • 3,243
  • 4
  • 25
  • 45
  • The [documentation on indexes](http://docs.couchdb.org/en/2.0.0/api/database/find.html#db-index) 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) – Dominic Barnes Apr 21 '17 at 07:06
  • @DominicBarnes No luck :( Tried several combinations of field types and index types and failed with either `required index service unavailable` or `invalid_index` – Frederick Zhang Apr 21 '17 at 07:11
  • 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: https://github.com/apache/couchdb/pull/480#issuecomment-294981458 – lossleader Apr 21 '17 at 13:45
  • 1
    @lossleader So the original Apache CouchDB supports only `json` index? – Frederick Zhang Apr 22 '17 at 11:53
  • 1
    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. – lossleader Apr 22 '17 at 13:31
  • 1
    @lossleader Many thanks. Could you please add an answer so I can accept it? – Frederick Zhang Apr 22 '17 at 13:43

1 Answers1

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.)

lossleader
  • 12,197
  • 1
  • 23
  • 38