Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An example CouchApp based CouchDB javascript view that creates and inverted index using CouchDB map-reduce
JavaScript
branch: master
Failed to load latest commit information.
views/whitespace new public couchapp
README.md new public couchapp

README.md

jsindexer

jsindexer is an example javascript view that creates an inverted index needed to do full text search on a CouchApp or CouchDB database hosted on cloudant.com. This is an alternative to the Java/Lucene indexers used by default.

Requirements

cloudant hosted account (sign up at https://cloudant.com/#!/solutions/cloud), couchapp

Install

cd jsindexer
cat > .couchapprc
{"env":{"default":{"db":"http://<user>:<pass>@<user>.cloudant.com:5984/<db_or_couchapp_you_want_to_search>"}}}
^C

that last line means hit *CTRL-C***

To configure the indexing of documents, modify the file:

views/whitespace/map.js

Cloudant search expects key,value pairs with the following format:

emit([field,token],[[1,6,8]]);

where 1,6,8 are the positions of that token in the field. The positions enable phrase searches.

couchapp push

Now trigger indexing with:

http://<user>.cloudant.com:5984/<db_or_couchapp_you_want_to_search>/_design/jsindexer/_view/whitespace

Once indexing is done, you can use the regular search syntax (http://support.cloudant.com/kb/search/search-api), but yon need to specify the index:

http://<user>.cloudant.com:5984/<db_or_couchapp_you_want_to_search>/_search?q=myfield:"some phrase"&index=_design/jsindexer/_view/whitespace
Something went wrong with that request. Please try again.