Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add notes about typing.

  • Loading branch information...
commit d2e1e9ea049b1edeab65bc393d15aeebed584822 1 parent 93e1da2
@rnewson authored
View
23 README.md
@@ -94,19 +94,25 @@ The following indexing options can be defaulted;
<td>the field name to index under</td>
<td>user-defined</td>
<td>default</td>
- </tr>
+ </tr>
+ <tr>
+ <th>type</th>
+ <td>the type of the field</td>
+ <td>date, double, float, integer, long, string</td>
+ <td>string</td>
+ </tr>
<tr>
<th>store</th>
<td>whether the data is stored. The value will be returned in the search result.</td>
<td>yes, no</td>
<td>no</td>
- </tr>
+ </tr>
<tr>
<th>index</th>
<td>whether (and how) the data is indexed</td>
<td>analyzed, analyzed_no_norms, no, not_analyzed, not_analyzed_no_norms</td>
<td>analyzed</td>
- </tr>
+ </tr>
</table>
<h3>The Analyzer Option</h3>
@@ -142,12 +148,17 @@ var doc = new Document();
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.
-The data is usually interpreted as a String but couchdb-lucene provides special handling if a Javascript Date object is passed. Specifically, the date is indexed as a numeric value, which allows correct sorting, and stored (if requested) in ISO 8601 format (with a timezone marker).
+If the value is a Date object, then the type of the field is treated as 'date', regardless of the type setting.
<pre>
// Add with all the defaults.
doc.add("value");
+// Add a numeric field.
+doc.add(35, {"type":"integer"});
+
+// Add a date field (object must be a Date object
+
// Add a subject field.
doc.add("this is the subject line.", {"field":"subject"});
@@ -191,7 +202,7 @@ function(doc) {
ret.attachment("attachment", i);
}
}
-
+
return ret;
}
</pre>
@@ -432,7 +443,7 @@ And the same with sorting;
<h3>Content-Type of response</h3>
-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.
+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.
<h1>Fetching information about the index</h1>
View
2  src/main/java/com/github/rnewson/couchdb/lucene/RhinoDocument.java
@@ -111,7 +111,7 @@ public static void jsFunction_add(final Context cx, final Scriptable thisObj, fi
}
final Object obj = Conversion.convert(args[0]);
-
+ System.err.println(obj.getClass());
if (obj instanceof Date) {
// Special indexed form.
doc.add(new Field(field, Long.toString(((Date) obj).getTime()), Field.Store.NO,
Please sign in to comment.
Something went wrong with that request. Please try again.