Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (20 sloc) 1.435 kB
47d118f @hardtke new public couchapp
hardtke authored
1 # jsindexer
2
3 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.
4
5 ## Requirements
6
7 cloudant hosted account (sign up at <https://cloudant.com/#!/solutions/cloud>), couchapp
8
9 ## Install
10
11 <pre><code>cd jsindexer
12 cat > .couchapprc
13 {"env":{"default":{"db":"http://&lt;user&gt;:&lt;pass&gt;@&lt;user&gt;.cloudant.com:5984/&lt;db_or_couchapp_you_want_to_search&gt;"}}}
14 ^C</code></pre>
15
16 *that last line means hit **CTRL-C***
17
18 To configure the indexing of documents, modify the file:
19
20 views/whitespace/map.js
21
22 Cloudant search expects key,value pairs with the following format:
23
24 <pre><code>emit([field,token],[[1,6,8]]);</code></pre>
25
26 where 1,6,8 are the positions of that token in the field. The positions enable phrase searches.
27
28 <pre><code>couchapp push</code></pre>
29
30 Now trigger indexing with:
31
32 <pre><code>http://&lt;user&gt;.cloudant.com:5984/&lt;db_or_couchapp_you_want_to_search&gt;/_design/jsindexer/_view/whitespace</code></pre>
33
34 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:
35
36 <pre><code>http://&lt;user&gt;.cloudant.com:5984/&lt;db_or_couchapp_you_want_to_search&gt;/_search?q=myfield:"some phrase"&index=_design/jsindexer/_view/whitespace</code></pre>
37
Something went wrong with that request. Please try again.