From 5106b033ebfb248b9274eca1f4176cdb2e3d312b Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Tue, 23 Aug 2016 20:49:01 +0100 Subject: [PATCH] Clarify text vs string and set default field type to text --- README.md | 6 +++++- .../github/rnewson/couchdb/lucene/couchdb/ViewSettings.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86b612a2..a8798061 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ The following indexing options can be defaulted; type the type of the field date, double, float, int, long, string, text - string + text store @@ -176,6 +176,10 @@ The following indexing options can be defaulted; +

String vs Text

+ +There are two supported types that sound equivalent, string and text, but they are very different. A text field will be tokenized into words and is usually what you expect from a full-text index. A string field is not tokenized, only exact matching will work. The advantage to string fields is that they have a meaningful sort order. +

The Analyzer Option

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; diff --git a/src/main/java/com/github/rnewson/couchdb/lucene/couchdb/ViewSettings.java b/src/main/java/com/github/rnewson/couchdb/lucene/couchdb/ViewSettings.java index e36ffdc7..3b134a6e 100644 --- a/src/main/java/com/github/rnewson/couchdb/lucene/couchdb/ViewSettings.java +++ b/src/main/java/com/github/rnewson/couchdb/lucene/couchdb/ViewSettings.java @@ -24,7 +24,7 @@ public final class ViewSettings { public static ViewSettings getDefaultSettings() { - return new ViewSettings(Constants.DEFAULT_FIELD, "no", "string", "1.0", null); + return new ViewSettings(Constants.DEFAULT_FIELD, "no", "text", "1.0", null); } private final Store store;