Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add termvector to the possible options for Field.

  • Loading branch information...
commit b00fb7f70ec3b6799f4d904e28d9449f9936ea0b 1 parent 8fb2c1c
Santiago M. Mola authored committed
View
6 README.md
@@ -143,6 +143,12 @@ The following indexing options can be defaulted;
<td>analyzed</td>
</tr>
<tr>
+ <th>termvector</th>
+ <td>whether and how a field should have term vectors</td>
+ <td>no, with_offsets, with_positions, with_positions_offsets, yes</td>
+ <td>no</td>
+ </tr>
+ <tr>
<th>boost</th>
<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>
<td>floating-point value</td>
View
2  src/main/java/com/github/rnewson/couchdb/lucene/couchdb/FieldType.java
@@ -139,7 +139,7 @@ private static NumericField field(final String name, final int precisionStep, fi
}
private static Field field(final String name, final Object value, final ViewSettings settings) {
- return boost(new Field(name, value.toString(), settings.getStore(), settings.getIndex()), settings);
+ return boost(new Field(name, value.toString(), settings.getStore(), settings.getIndex(), settings.getTermVector()), settings);
}
private static <T extends AbstractField> T boost(final T field, final ViewSettings settings) {
View
16 src/main/java/com/github/rnewson/couchdb/lucene/couchdb/ViewSettings.java
@@ -4,6 +4,7 @@
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.Field.TermVector;
import org.mozilla.javascript.NativeObject;
import com.github.rnewson.couchdb.lucene.util.Constants;
@@ -27,7 +28,7 @@
public final class ViewSettings {
public static ViewSettings getDefaultSettings() {
- return new ViewSettings(Constants.DEFAULT_FIELD, "analyzed", "no", "string", "1.0", null);
+ return new ViewSettings(Constants.DEFAULT_FIELD, "analyzed", "no", "string", "1.0", "no", null);
}
private final Index index;
@@ -35,13 +36,14 @@ public static ViewSettings getDefaultSettings() {
private final String field;
private final FieldType type;
private final float boost;
+ private final TermVector termvector;
public ViewSettings(final JSONObject json) {
this(json, getDefaultSettings());
}
public ViewSettings(final JSONObject json, final ViewSettings defaults) {
- this(json.optString("field", null), json.optString("index", null), json.optString("store", null), json.optString("type", null), json.optString("boost", null), defaults);
+ this(json.optString("field", null), json.optString("index", null), json.optString("store", null), json.optString("type", null), json.optString("boost", null), json.optString("termvector", null), defaults);
}
public ViewSettings(final NativeObject obj) {
@@ -49,15 +51,16 @@ public ViewSettings(final NativeObject obj) {
}
public ViewSettings(final NativeObject obj, final ViewSettings defaults) {
- this(get(obj, "field"), get(obj, "index"), get(obj, "store"), get(obj, "type"), get(obj, "boost"), defaults);
+ this(get(obj, "field"), get(obj, "index"), get(obj, "store"), get(obj, "type"), get(obj, "boost"), get(obj, "termvector"), defaults);
}
- private ViewSettings(final String field, final String index, final String store, final String type, final String boost, final ViewSettings defaults) {
+ private ViewSettings(final String field, final String index, final String store, final String type, final String boost, final String termvector, final ViewSettings defaults) {
this.field = field != null ? field : defaults.getField();
this.index = index != null ? Index.valueOf(index.toUpperCase()) : defaults.getIndex();
this.store = store != null ? Store.valueOf(store.toUpperCase()) : defaults.getStore();
this.type = type != null ? FieldType.valueOf(type.toUpperCase()) : defaults.getFieldType();
this.boost = boost != null ? Float.valueOf(boost) : defaults.getBoost();
+ this.termvector = termvector != null? TermVector.valueOf(termvector.toUpperCase()) : defaults.getTermVector();
}
public float getBoost() {
@@ -80,6 +83,11 @@ public FieldType getFieldType() {
return type;
}
+ public TermVector getTermVector()
+ {
+ return termvector;
+ }
+
private static String get(final NativeObject obj, final String key) {
return obj == null ? null : obj.has(key, null) ? obj.get(key, null).toString() : null;
}
Please sign in to comment.
Something went wrong with that request. Please try again.