Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 562 lines (446 sloc) 18.22 kB
6d1c074 @rnewson add notes about version compatibility.
authored
1 <h1>Version Compatibility</h1>
2
3 <table>
4 <tr><th>CouchDB</th><th>couchdb-lucene</th></tr>
5 <tr><td>0.9.1, 0.10</td><td>0.4</td></tr>
5cd5577 @rnewson 0.11 is now released.
authored
6 <tr><td>0.11</td><td>0.4-maint (0.4 with patch for trunk compatibility)</td></tr>
79285e8 @rnewson remove warning about 0.5 now it's out.
authored
7 <tr><td>0.10.x and 0.11.x</td><td>0.5.x</td></tr>
6d1c074 @rnewson add notes about version compatibility.
authored
8 </table>
9
9084540 @rnewson add breaking changes section.
authored
10 <h1>Breaking Changes</h1>
11
12 <ul>
79285e8 @rnewson remove warning about 0.5 now it's out.
authored
13 <li>couchdb-lucene 0.5.x runs as a standalone daemon (0.4 was run directly by couchdb).
9084540 @rnewson add breaking changes section.
authored
14 <li>URL's now require the full design document id (where you would say "foo", you must now say "_design/foo").
15 </ul>
16
c6356fd @rnewson update README.md and TODO to reflect progress.
authored
17 <h1>Issue Tracking</h1>
a785480 @rnewson lighthouse sucks at formatting anything, abandon ship.
authored
18
7a0d1d3 @rnewson lighthouse sucks at formatting anything, abandon ship.
authored
19 Issue tracking at <a href="http://github.com/rnewson/couchdb-lucene/issues">github</a>.
5d4e56a @rnewson update readme.
authored
20
7dc5bac @rnewson reorg begins.
authored
21 <h1>Minimum System Requirements</h1>
ef3f787 @rnewson add sysreq for Sun JDK.
authored
22
796a42b @rnewson jdk 5 compatibility for readme.
authored
23 Java 1.5 (or above) is required; the Sun version is recommended as it's regularly tested against.
ef3f787 @rnewson add sysreq for Sun JDK.
authored
24
5220b65 @rnewson tweak README.md
authored
25 <h1>Build couchdb-lucene</h1>
b207965 @rnewson improve README readability.
authored
26
27 <ol>
28 <li>Install Maven 2.
29 <li>checkout repository
30 <li>type 'mvn'
31 <li>configure couchdb (see below)
32 </ol>
33
2d6180b @rnewson include properties file in zip. still not available to run script, th…
authored
34 You will now have a zip file in the target/ directory. This contains all the couchdb-lucene code, dependencies, startup scripts and configuration files to run couchdb-lucene.
35
b207965 @rnewson improve README readability.
authored
36 <h1>Configure CouchDB</h1>
37
38 <pre>
0563120 @rnewson fixes.
authored
39 [couchdb]
40 os_process_timeout=60000 ; increase the timeout from 5 seconds.
41
b207965 @rnewson improve README readability.
authored
42 [external]
5675f7a @rnewson fix path
authored
43 fti=/path/to/python /path/to/couchdb-lucene/tools/couchdb-external-hook.py
b207965 @rnewson improve README readability.
authored
44
45 [httpd_db_handlers]
46 _fti = {couch_httpd_external, handle_external_req, <<"fti">>}
47 </pre>
48
cbfe065 @rnewson remove registry and indexkey, change output paths
authored
49 <h2>Hook options</h2>
50
51 <table>
52 <tr><th>Option</th><th>Meaning</th><th>Default Value</th></tr>
53 <tr><td>--remote-host</td><td>The hostname of the couchdb-lucene server</td><td>localhost</td></tr>
54 <tr><td>--remote-port</td><td>The port of the couchdb-lucene server</td><td>5985</td></tr>
c47c494 @rnewson updated README to reflect latest Python scripts settings
authored
55 <tr><td>--local-key</td><td>The key for the local couchdb instance as known to the couchdb-lucene server</td><td>local</td></tr>
cbfe065 @rnewson remove registry and indexkey, change output paths
authored
56 </table>
b047e4a @rnewson update README.md to reflect (future) start/stop and config changes.
authored
57
cbfe065 @rnewson remove registry and indexkey, change output paths
authored
58 <h1>Configure couchdb-lucene</h1>
b047e4a @rnewson update README.md to reflect (future) start/stop and config changes.
authored
59
cbfe065 @rnewson remove registry and indexkey, change output paths
authored
60 couchdb-lucene runs in a single, standalone JVM. As such, you can choose to locate your couchdb-lucene server on a different machine to couchdb if you wish, or keep it on the same machine, it's your call.
b047e4a @rnewson update README.md to reflect (future) start/stop and config changes.
authored
61
62 <h1>Start couchdb-lucene</h1>
63
64 To start couchdb-lucene, run;
65 <pre>
2d6180b @rnewson include properties file in zip. still not available to run script, th…
authored
66 bin/run
b047e4a @rnewson update README.md to reflect (future) start/stop and config changes.
authored
67 </pre>
68
2d6180b @rnewson include properties file in zip. still not available to run script, th…
authored
69 To stop couchdb-lucene, simply kill the Java process.
b047e4a @rnewson update README.md to reflect (future) start/stop and config changes.
authored
70
b207965 @rnewson improve README readability.
authored
71 <h1>Indexing Strategy</h1>
72
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
73 <h2>Document Indexing</h2>
74
4c21806 @rnewson mention that you can return Document[] from an index function.
authored
75 You must supply a index function in order to enable couchdb-lucene as, by default, nothing will be indexed. To suppress a document from the index, return null. It's more typical to return a single Document object which contains everything you'd like to query and retrieve. You may also return an array of Document objects if you wish.
a2e9024 @rnewson wip
authored
76
437eae9 @rnewson s/view/fulltext in README.md
authored
77 You may add any number of index views in any number of design documents. All searches will be constrained to documents emitted by the index functions.
c207a60 @rnewson update README
authored
78
5077366 @rnewson clarify design document and add matching query URL's.
authored
79 Here's an complete example of a design document with couchdb-lucene features:
a2e9024 @rnewson wip
authored
80
697884b @rnewson documentation of future features.
authored
81 <pre>
82 {
3d2fb72 @rnewson fix example in README.
authored
83 "_id":"_design/foo",
5077366 @rnewson clarify design document and add matching query URL's.
authored
84 "fulltext": {
85 "by_subject": {
86 "index":"function(doc) { var ret=new Document(); ret.add(doc.subject); return ret }"
87 },
88 "by_content": {
89 "index":"function(doc) { var ret=new Document(); ret.add(doc.content); return ret }"
90 }
697884b @rnewson documentation of future features.
authored
91 }
92 }
93 </pre>
94
5077366 @rnewson clarify design document and add matching query URL's.
authored
95 Here are some example URL's for the given design document;
96
97 <pre>
6b73dc6 @rnewson commit to _design/foo in paths, use regexp to be sure.
authored
98 http://localhost:5984/database/_fti/_design/foo/by_subject?q=hello
99 http://localhost:5984/database/_fti/_design/foo/by_content?q=hello
5077366 @rnewson clarify design document and add matching query URL's.
authored
100 </pre>
101
697884b @rnewson documentation of future features.
authored
102 A fulltext object contains multiple index view declarations. An index view consists of;
103
104 <dl>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
105 <dt>analyzer</dt><dd>(optional) The analyzer to use</dd>
106 <dt>defaults</dt><dd>(optional) The default for numerous indexing options can be overridden here. A full list of options follows.</dd>
697884b @rnewson documentation of future features.
authored
107 <dt>index</dt><dd>The indexing function itself, documented below.</dd>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
108 </dl>
697884b @rnewson documentation of future features.
authored
109
110 <h3>The Defaults Object</h3>
111
112 The following indexing options can be defaulted;
113
114 <table>
115 <tr>
116 <th>name</th>
117 <th>description</th>
118 <th>available options</th>
119 <th>default</th>
120 </tr>
121 <tr>
a40523d @rnewson documentation of future features.
authored
122 <th>field</th>
123 <td>the field name to index under</td>
124 <td>user-defined</td>
125 <td>default</td>
d2e1e9e @rnewson add notes about typing.
authored
126 </tr>
127 <tr>
128 <th>type</th>
129 <td>the type of the field</td>
38ef320 @rnewson fix documentation s/integer/int
authored
130 <td>date, double, float, int, long, string</td>
d2e1e9e @rnewson add notes about typing.
authored
131 <td>string</td>
132 </tr>
a40523d @rnewson documentation of future features.
authored
133 <tr>
697884b @rnewson documentation of future features.
authored
134 <th>store</th>
f16fc9c @rnewson docs
authored
135 <td>whether the data is stored. The value will be returned in the search result.</td>
697884b @rnewson documentation of future features.
authored
136 <td>yes, no</td>
137 <td>no</td>
d2e1e9e @rnewson add notes about typing.
authored
138 </tr>
697884b @rnewson documentation of future features.
authored
139 <tr>
140 <th>index</th>
141 <td>whether (and how) the data is indexed</td>
8328332 @rnewson typo
authored
142 <td>analyzed, analyzed_no_norms, no, not_analyzed, not_analyzed_no_norms</td>
697884b @rnewson documentation of future features.
authored
143 <td>analyzed</td>
d2e1e9e @rnewson add notes about typing.
authored
144 </tr>
f6bfce8 @rnewson add EXPERIMENTAL index-time field boosting feature.
authored
145 <tr>
b00fb7f add termvector to the possible options for Field.
Santiago M. Mola authored
146 <th>termvector</th>
147 <td>whether and how a field should have term vectors</td>
148 <td>no, with_offsets, with_positions, with_positions_offsets, yes</td>
149 <td>no</td>
150 </tr>
151 <tr>
f6bfce8 @rnewson add EXPERIMENTAL index-time field boosting feature.
authored
152 <th>boost</th>
153 <td>Sets the boost factor hits on this field. This value will be multiplied into the score of all hits on this this field of this document.</td>
154 <td>floating-point value</td>
155 <td>1.0</td>
156 </tr>
697884b @rnewson documentation of future features.
authored
157 </table>
087dcec @rnewson update documentation.
authored
158
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
159 <h3>The Analyzer Option</h3>
160
161 Lucene has numerous ways of converting free-form text into tokens, these classes are called Analyzer's. By default, the StandardAnalyzer is used which lower-cases all text, drops common English words ("the", "and", and so on), among other things. This processing might not always suit you, so you can choose from several others by setting the "analyzer" field to one of the following values;
162
163 <ul>
164 <li>brazilian</li>
165 <li>chinese</li>
166 <li>cjk</li>
167 <li>czech</li>
168 <li>dutch</li>
169 <li>english</li>
170 <li>french</li>
171 <li>german</li>
172 <li>keyword</li>
76d290d @rnewson add perfield analyzer support
authored
173 <li>perfield</li>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
174 <li>porter</li>
175 <li>russian</li>
176 <li>simple</li>
177 <li>standard</li>
178 <li>thai</li>
179 </ul>
180
76d290d @rnewson add perfield analyzer support
authored
181 The "perfield" option lets you use a different analyzer for different fields and is configured as follows;
182
183 <pre>
b9ea0b2 @rnewson tidy document about analyzer
authored
184 "analyzer":"perfield:{field_name:\"analyzer_name\"}"
76d290d @rnewson add perfield analyzer support
authored
185 </pre>
186
86569b1 @rnewson use 'default' consistently.
authored
187 Unless overridden, any field name not specified will be handled by the standard analyzer. To change the default, use the special default field name;
76d290d @rnewson add perfield analyzer support
authored
188
189 <pre>
b9ea0b2 @rnewson tidy document about analyzer
authored
190 "analyzer":"perfield:{default:\"keyword\"}"
76d290d @rnewson add perfield analyzer support
authored
191 </pre>
192
087dcec @rnewson update documentation.
authored
193 <h3>The Document class</h3>
194
195 You may construct a new Document instance with;
196
197 <pre>
198 var doc = new Document();
199 </pre>
200
a40523d @rnewson documentation of future features.
authored
201 Data may be added to this document with the add method which takes an optional second object argument that can override any of the above default values.
087dcec @rnewson update documentation.
authored
202
203 <pre>
a40523d @rnewson documentation of future features.
authored
204 // Add with all the defaults.
205 doc.add("value");
206
d2e1e9e @rnewson add notes about typing.
authored
207 // Add a numeric field.
38ef320 @rnewson fix documentation s/integer/int
authored
208 doc.add(35, {"type":"int"});
d2e1e9e @rnewson add notes about typing.
authored
209
4670582 @rnewson use NumericField. currently broken.
authored
210 // Add a date field.
211 doc.add(new Date("2009-01-01"), {"type":"date"});
212
d2e1e9e @rnewson add notes about typing.
authored
213 // Add a date field (object must be a Date object
214
a40523d @rnewson documentation of future features.
authored
215 // Add a subject field.
216 doc.add("this is the subject line.", {"field":"subject"});
9a71557 @rnewson formatting
authored
217
a40523d @rnewson documentation of future features.
authored
218 // Add but ensure it's stored.
219 doc.add("value", {"store":"yes"});
9a71557 @rnewson formatting
authored
220
a40523d @rnewson documentation of future features.
authored
221 // Add but don't analyze.
222 doc.add("don't analyze me", {"index":"not_analyzed"});
9a71557 @rnewson formatting
authored
223
fae7be0 @rnewson add example for attachment with default field.
authored
224 // Extract text from the named attachment and index it.
225 doc.attachment("attachment name");
226
227 // Extract text from the named attachment and index it to a separate field
a40523d @rnewson documentation of future features.
authored
228 doc.attachment("attachment name", {"field":"attachments"});
9f99f19 @rnewson add log.info example
authored
229
230 // log an event (trace, debug, info, warn and error are available)
231 if (doc.foo) {
232 log.info("doc has foo property!");
233 }
087dcec @rnewson update documentation.
authored
234 </pre>
235
ccb81a8 @rnewson add example transforms section.
authored
236 <h3>Example Transforms</h3>
237
390858a @rnewson re-add Index Everything example.
authored
238 <h4>Index Everything</h4>
239
240 <pre>
241 function(doc) {
7bad7dc @rnewson correct syntax error in JS fun.
authored
242 var ret = new Document();
243
244 function idx(obj) {
245 for (var key in obj) {
246 switch (typeof obj[key]) {
247 case 'object':
248 idx(obj[key]);
249 break;
250 case 'function':
251 break;
252 default:
253 ret.add(obj[key]);
254 break;
255 }
256 }
257 };
258
259 idx(doc);
260
261 if (doc._attachments) {
262 for (var i in doc._attachments) {
263 ret.attachment("attachment", i);
264 }
390858a @rnewson re-add Index Everything example.
authored
265 }
d2e1e9e @rnewson add notes about typing.
authored
266
7bad7dc @rnewson correct syntax error in JS fun.
authored
267 return ret;
390858a @rnewson re-add Index Everything example.
authored
268 }
269 </pre>
270
ccb81a8 @rnewson add example transforms section.
authored
271 <h4>Index Nothing</h4>
272
273 <pre>
274 function(doc) {
275 return null;
276 }
277 </pre>
278
c207a60 @rnewson update README
authored
279 <h4>Index Select Fields</h4>
ccb81a8 @rnewson add example transforms section.
authored
280
281 <pre>
282 function(doc) {
c207a60 @rnewson update README
authored
283 var result = new Document();
c6356fd @rnewson update README.md and TODO to reflect progress.
authored
284 result.add(doc.subject, {"field":"subject", "store":"yes"});
285 result.add(doc.content, {"field":"subject"});
5cfa20c @rnewson fix error in example
authored
286 result.add(new Date(), {"field":"indexed_at"});
c207a60 @rnewson update README
authored
287 return result;
ccb81a8 @rnewson add example transforms section.
authored
288 }
289 </pre>
290
c207a60 @rnewson update README
authored
291 <h4>Index Attachments</h4>
ccb81a8 @rnewson add example transforms section.
authored
292
293 <pre>
294 function(doc) {
c207a60 @rnewson update README
authored
295 var result = new Document();
296 for(var a in doc._attachments) {
244df30 @rnewson fix mistake in README
authored
297 result.attachment(a, {"field":"attachment"});
ccb81a8 @rnewson add example transforms section.
authored
298 }
c207a60 @rnewson update README
authored
299 return result;
300 }
301 </pre>
302
303 <h4>A More Complex Example</h4>
304
305 <pre>
306 function(doc) {
307 var mk = function(name, value, group) {
c6356fd @rnewson update README.md and TODO to reflect progress.
authored
308 var ret = new Document();
2946c9a @rnewson fix example.
authored
309 ret.add(value, {"field": group, "store":"yes"});
c6356fd @rnewson update README.md and TODO to reflect progress.
authored
310 ret.add(group, {"field":"group", "store":"yes"});
c207a60 @rnewson update README
authored
311 return ret;
312 };
313 if(doc.type != "reference") return null;
a313b24 @rnewson lots of stuff.
authored
314 var ret = new Array();
c207a60 @rnewson update README
authored
315 for(var g in doc.groups) {
a313b24 @rnewson lots of stuff.
authored
316 ret.push(mk("library", doc.groups[g].library, g));
317 ret.push(mk("method", doc.groups[g].method, g));
318 ret.push(mk("target", doc.groups[g].target, g));
c207a60 @rnewson update README
authored
319 }
320 return ret;
321 }
322 </pre>
b207965 @rnewson improve README readability.
authored
323
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
324 <h2>Attachment Indexing</h2>
325
8059ce0 @rnewson s/couchdb/couchdb-lucene
authored
326 Couchdb-lucene uses <a href="http://lucene.apache.org/tika/">Apache Tika</a> to index attachments of the following types, assuming the correct content_type is set in couchdb;
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
327
ec94e21 @rnewson updated README.md
authored
328 <h3>Supported Formats</h3>
329
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
330 <ul>
331 <li>Excel spreadsheets (application/vnd.ms-excel)
332 <li>HTML (text/html)
333 <li>Images (image/*)
334 <li>Java class files
335 <li>Java jar archives
336 <li>MP3 (audio/mp3)
337 <li>OpenDocument (application/vnd.oasis.opendocument.*)
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
338 <li>Outlook (application/vnd.ms-outlook)
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
339 <li>PDF (application/pdf)
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
340 <li>Plain text (text/plain)
341 <li>Powerpoint presentations (application/vnd.ms-powerpoint)
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
342 <li>RTF (application/rtf)
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
343 <li>Visio (application/vnd.visio)
344 <li>Word documents (application/msword)
345 <li>XML (application/xml)
4a60080 @rnewson use couchdb's content_type rather than auto-detect.
authored
346 </ul>
347
b207965 @rnewson improve README readability.
authored
348 <h1>Searching with couchdb-lucene</h1>
349
2b14b76 @rnewson describ syntax for all forms of numeric range query
authored
350 You can perform all types of queries using Lucene's default <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">query syntax</a>.
351
352 <h2>Numeric range queries</h2>
353
e0c2000 @rnewson fix grammar, thanks tisba.
authored
354 In addition to normal text-based range searches (using the "field:[lower TO upper]" syntax), couchdb-lucene also supports numeric range searches for the following types: int, long, float, double and date. The type is specified after the field name, as follows;
2b14b76 @rnewson describ syntax for all forms of numeric range query
authored
355
356 <table>
bf989bc @rnewson make type of range query explicit.
authored
357 <tr><td>type</td><td>example</td></tr>
38ef320 @rnewson fix documentation s/integer/int
authored
358 <tr><td>int</td><td>field&lt;int>:[0 TO 100]</td></tr>
20c9be3 @rnewson update docs on numeric range queries
authored
359 <tr><td>long</td><td>field&lt;long>:[0 TO 100]</td></tr>
360 <tr><td>float</td><td>field&lt;float>:[0.0 TO 100.0]</td></tr>
361 <tr><td>double</td><td>field&lt;double>:[0.0 TO 100.0]</td></tr>
362 <tr><td>date</td><td>field&lt;date>:[2001-01-01 TO 2010-01-01] or field&lt;date>:[2000-01-01T00:00:00-0500 TO 2010-01-01T00:00:00-0500]</td></tr>
2b14b76 @rnewson describ syntax for all forms of numeric range query
authored
363 </table>
364
460f5c6 @rnewson add example spatial/geographical query
authored
365 An example numeric range query for spatial searching.
366
367 <pre>
1217f9f @rnewson update docs on numeric range queries
authored
368 ?q=pizza AND lat&lt;double>:[51.4707 TO 51.5224] AND long&lt;double>:[-0.6622 TO -0.5775]
460f5c6 @rnewson add example spatial/geographical query
authored
369 </pre>
370
2b14b76 @rnewson describ syntax for all forms of numeric range query
authored
371 The following parameters can be passed for more sophisticated searches;
b207965 @rnewson improve README readability.
authored
372
373 <dl>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
374 <dt>callback</dt><dd>Specify a JSONP callback wrapper. The full JSON result will be prepended with this parameter and also placed with parentheses."
71cbc0b @rnewson correct description of debug setting.
authored
375 <dt>debug</dt><dd>Setting this to true disables response caching (the query is executed every time) and indents the JSON response for readability.</dd>
ea19e55 @rnewson add force_json=true to force 'application/json' response type.
authored
376 <dt>force_json<dt><dd>Usually couchdb-lucene determines the Content-Type of its response based on the presence of the Accept header. If Accept contains "application/json", you get "application/json" in the response, otherwise you get "text/plain;charset=utf8". Some tools, like JSONView for FireFox, do not send the Accept header but do render "application/json" responses if received. Setting force_json=true forces all response to "application/json" regardless of the Accept header.</dd>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
377 <dt>include_docs</dt><dd>whether to include the source docs</dd>
f9c61e3 @rnewson format README
authored
378 <dt>limit</dt><dd>the maximum number of results to return</dd>
766d874 @rnewson support multiple q parameters in one call.
authored
379 <dt>q</dt><dd>the query to run (e.g, subject:hello). If not specified, the default field is searched. Multiple q parameters are permitted, the resulting JSON will be an array of responses.</dd>
f9c61e3 @rnewson format README
authored
380 <dt>skip</dt><dd>the number of results to skip</dd>
645a17e @rnewson remove single quotes fromexample.
authored
381 <dt>sort</dt><dd>the comma-separated fields to sort on. Prefix with / for ascending order and \ for descending order (ascending is the default if not specified). Type-specific sorting is also available by appending the type between angle brackets (e.g, sort=amount<float>). Supported types are 'float', 'double', 'int', 'long' and 'date'.</dd>
637279a @rnewson fix grammar in readme.
authored
382 <dt>stale=ok</dt><dd>If you set the <i>stale</i> option to <i>ok</i>, couchdb-lucene may not perform any refreshing on the index. Searches may be faster as Lucene caches important data (especially for sorting). A query without stale=ok will use the latest data committed to the index.</dd>
ad9096f @rnewson tweak README.md
authored
383 </dl>
b207965 @rnewson improve README readability.
authored
384
385 <i>All parameters except 'q' are optional.</i>
386
ec94e21 @rnewson updated README.md
authored
387 <h2>Special Fields</h2>
388
389 <dl>
087dcec @rnewson update documentation.
authored
390 <dt>_id</dt><dd>The _id of the document.</dd>
46a3a37 @rnewson include all DC attributes, if present.
authored
391 </dl>
392
393 <h2>Dublin Core</h2>
394
395 All Dublin Core attributes are indexed and stored if detected in the attachment. Descriptions of the fields come from the Tika javadocs.
396
397 <dl>
6e99faa @rnewson dc. to _dc.
authored
398 <dt>_dc.contributor</dt><dd> An entity responsible for making contributions to the content of the resource.</dd>
399 <dt>_dc.coverage</dt><dd>The extent or scope of the content of the resource.</dd>
400 <dt>_dc.creator</dt><dd>An entity primarily responsible for making the content of the resource.</dd>
401 <dt>_dc.date</dt><dd>A date associated with an event in the life cycle of the resource.</dd>
402 <dt>_dc.description</dt><dd>An account of the content of the resource.</dd>
403 <dt>_dc.format</dt><dd>Typically, Format may include the media-type or dimensions of the resource.</dd>
404 <dt>_dc.identifier</dt><dd>Recommended best practice is to identify the resource by means of a string or number conforming to a formal identification system.</dd>
405 <dt>_dc.language</dt><dd>A language of the intellectual content of the resource.</dd>
406 <dt>_dc.modified</dt><dd>Date on which the resource was changed.</dd>
407 <dt>_dc.publisher</dt><dd>An entity responsible for making the resource available.</dd>
408 <dt>_dc.relation</dt><dd>A reference to a related resource.</dd>
409 <dt>_dc.rights</dt><dd>Information about rights held in and over the resource.</dd>
410 <dt>_dc.source</dt><dd>A reference to a resource from which the present resource is derived.</dd>
411 <dt>_dc.subject</dt><dd>The topic of the content of the resource.</dd>
412 <dt>_dc.title</dt><dd>A name given to the resource.</dd>
413 <dt>_dc.type</dt><dd>The nature or genre of the content of the resource.</dd>
ec94e21 @rnewson updated README.md
authored
414 </dl>
415
b207965 @rnewson improve README readability.
authored
416 <h2>Examples</h2>
417
418 <pre>
6b73dc6 @rnewson commit to _design/foo in paths, use regexp to be sure.
authored
419 http://localhost:5984/dbname/_fti/_design/foo/view_name?q=field_name:value
420 http://localhost:5984/dbname/_fti/_design/foo/view_name?q=field_name:value&sort=other_field
421 http://localhost:5984/dbname/_fti/_design/foo/view_name?debug=true&sort=billing_size&q=body:document AND customer:[A TO C]
b207965 @rnewson improve README readability.
authored
422 </pre>
423
424 <h2>Search Results Format</h2>
425
0fcf578 @rnewson update docs.
authored
426 The search result contains a number of fields at the top level, in addition to your search results.
427
428 <dl>
429 <dt>etag</dt><dd>An opaque token that reflects the current version of the index. This value is also returned in an ETag header to facilitate HTTP caching.</dd>
430 <dt>fetch_duration</dt><dd>The number of milliseconds spent retrieving the documents.</dd>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
431 <dt>limit</dt><dd>The maximum number of results that can appear.</dd>
432 <dt>q</dt><dd>The query that was executed.</dd>
24591d9 @rnewson docs
authored
433 <dt>rows</dt><dd>The search results array, described below.</dd>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
434 <dt>search_duration</dt><dd>The number of milliseconds spent performing the search.</dd>
435 <dt>skip</dt><dd>The number of initial matches that was skipped.</dd>
436 <dt>total_rows</dt><dd>The total number of matches for this query.</dd>
0fcf578 @rnewson update docs.
authored
437 </dl>
438
24591d9 @rnewson docs
authored
439 <h2>The search results array</h2>
440
441 The search results arrays consists of zero, one or more objects with the following fields;
0fcf578 @rnewson update docs.
authored
442
443 <dl>
f420bf7 @rnewson support different Analyzer's at index and query time.
authored
444 <dt>doc</dt><dd>The original document from couch, if requested with include_docs=true</dd>
445 <dt>fields</dt><dd>All the fields that were stored with this match</dd>
0fcf578 @rnewson update docs.
authored
446 <dt>id</dt><dd>The unique identifier for this match.</dd>
447 <dt>score</dt><dd>The normalized score (0.0-1.0, inclusive) for this match</dd>
448 </dl>
449
fd16315 @rnewson update README.md
authored
450 Here's an example of a JSON response without sorting;
b207965 @rnewson improve README readability.
authored
451
118d28e @rnewson JSON example output.
authored
452 <pre>
453 {
c6356fd @rnewson update README.md and TODO to reflect progress.
authored
454 "q": "+content:enron",
fd16315 @rnewson update README.md
authored
455 "skip": 0,
456 "limit": 2,
457 "total_rows": 176852,
458 "search_duration": 518,
459 "fetch_duration": 4,
460 "rows": [
461 {
0fcf578 @rnewson update docs.
authored
462 "id": "hain-m-all_documents-257.",
fd16315 @rnewson update README.md
authored
463 "score": 1.601625680923462
464 },
465 {
0fcf578 @rnewson update docs.
authored
466 "id": "hain-m-notes_inbox-257.",
fd16315 @rnewson update README.md
authored
467 "score": 1.601625680923462
468 }
118d28e @rnewson JSON example output.
authored
469 ]
470 }
471 </pre>
472
fd16315 @rnewson update README.md
authored
473 And the same with sorting;
474
118d28e @rnewson JSON example output.
authored
475 <pre>
476 {
0fcf578 @rnewson update docs.
authored
477 "q": "+content:enron",
fd16315 @rnewson update README.md
authored
478 "skip": 0,
479 "limit": 3,
480 "total_rows": 176852,
481 "search_duration": 660,
482 "fetch_duration": 4,
483 "sort_order": [
484 {
485 "field": "source",
486 "reverse": false,
487 "type": "string"
488 },
489 {
490 "reverse": false,
491 "type": "doc"
492 }
118d28e @rnewson JSON example output.
authored
493 ],
fd16315 @rnewson update README.md
authored
494 "rows": [
495 {
0fcf578 @rnewson update docs.
authored
496 "id": "shankman-j-inbox-105.",
fd16315 @rnewson update README.md
authored
497 "score": 0.6131107211112976,
498 "sort_order": [
499 "enron",
500 6
501 ]
502 },
503 {
0fcf578 @rnewson update docs.
authored
504 "id": "shankman-j-inbox-8.",
fd16315 @rnewson update README.md
authored
505 "score": 0.7492915391921997,
506 "sort_order": [
507 "enron",
508 7
509 ]
510 },
511 {
0fcf578 @rnewson update docs.
authored
512 "id": "shankman-j-inbox-30.",
fd16315 @rnewson update README.md
authored
513 "score": 0.507369875907898,
514 "sort_order": [
515 "enron",
516 8
517 ]
518 }
118d28e @rnewson JSON example output.
authored
519 ]
520 }
521 </pre>
522
a4aa4e1 @rnewson document Content-Type response negotiation
authored
523 <h3>Content-Type of response</h3>
524
d2e1e9e @rnewson add notes about typing.
authored
525 The Content-Type of the response is negotiated via the Accept request header like CouchDB itself. If the Accept header includes "application/json" then that is also the Content-Type of the response. If not, "text/plain;charset=utf-8" is used.
a4aa4e1 @rnewson document Content-Type response negotiation
authored
526
139a78c @rnewson add info retrieval.
authored
527 <h1>Fetching information about the index</h1>
528
0cf4941 @rnewson correct info urls.
authored
529 Calling couchdb-lucene without arguments returns a JSON object with information about the index.
139a78c @rnewson add info retrieval.
authored
530
531 <pre>
6b73dc6 @rnewson commit to _design/foo in paths, use regexp to be sure.
authored
532 http://127.0.0.1:5984/&lt;db>/_fti/_design/foo/&lt;index
139a78c @rnewson add info retrieval.
authored
533 </pre>
534
535 returns;
536
537 <pre>
f6ac048 @rnewson line breaks
authored
538 {"current":true,"disk_size":110674,"doc_count":397,"doc_del_count":0,
539 "fields":["default","number"],"last_modified":"1263066382000",
540 "optimized":true,"ref_count":2}
139a78c @rnewson add info retrieval.
authored
541 </pre>
8203af6 @rnewson support _optimize and _expunge calls.
authored
542
543 <h1>Index Maintenance</h1>
544
545 For optimal query speed you can optimize your indexes. This causes the index to be rewritten into a single segment.
546
547 <pre>
6b73dc6 @rnewson commit to _design/foo in paths, use regexp to be sure.
authored
548 curl -X POST http://localhost:5984/&lt;db>/_fti/_design/foo/&lt;index>/_optimize
8203af6 @rnewson support _optimize and _expunge calls.
authored
549 </pre>
550
551 If you just want to expunge pending deletes, then call;
552
553 <pre>
6b73dc6 @rnewson commit to _design/foo in paths, use regexp to be sure.
authored
554 curl -X POST http://localhost:5984/&lt;db>/_fti/_design/foo/&lt;index>/_expunge
8203af6 @rnewson support _optimize and _expunge calls.
authored
555 </pre>
6e66766 @rnewson most of index cleanup work
authored
556
557 If you recreate databases or frequently change your fulltext functions, you will probably have old indexes lying around on disk. To remove all of them, call;
558
559 <pre>
560 curl -X POST http://localhost:5984/&lt;db>/_fti/_cleanup
561 </pre>
Something went wrong with that request. Please try again.