couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <j...@couchbase.com>
Subject Re: custom index
Date Mon, 20 May 2013 16:55:13 GMT

On May 20, 2013, at 12:18 AM, Jürgen Jakobitsch SWC <j.jakobitsch@semantic-web.at>
wrote:

> i need to be able to create a custom index (btree) on
> what was once a table column. 
> i saw that there's an geo spatial extension which was always a sign of
> custom indizes.
> i need to create a special btree (a regex btree) for a certain key in a
> json document that does some magic.

It depends on how “custom” the index needs to be. As Jonas said, CouchDB’s built-in
indexing mechanism is called “views”. It’s fairly flexible — your map function can
define any JSON value as a key for a document, and you can later query on specific keys or
key ranges. This becomes especially powerful if you use arrays as keys, as it lets you set
up primary/secondary search criteria.

But views aren’t all-powerful. Geospatial queries are one example of something regular views
can’t handle, because they require range tests on multiple axes at once. That’s why they
had to be added as a custom index type in CouchDB. I have no knowledge of how custom indexes
are added, but I suspect it’s difficult (because it’s rarely done) and it would definitely
require knowledge of Erlang.

Why don’t you describe your requirements in more detail. A lot of the time we can come up
with a fairly clean way to implement people’s indexing needs using regular views — they’re
surprisingly powerful.

—Jens
Mime
View raw message