Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Added method IndexWriter.addDocument(Document, Analyzer).

Doug Cutting47dfbc2b6a15
diff --git a/CHANGES.txt b/CHANGES.txt
index b460ec5ef6e..855e45ac702 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,10 @@ $Id$
permitted to write files. This way folks can open and correctly
lock indexes which are read-only to them.
+ 3. IndexWriter: added a new method, addDocument(Document, Analyzer),
+ permitting one to easily use different analyzers for different
+ documents in the same index.
+
1.3 RC1
diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java
index 940a01e37a1..1ec098e0b88 100644
--- a/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/src/java/org/apache/lucene/index/IndexWriter.java
@@ -212,6 +212,16 @@ public class IndexWriter {
* discarded.
*/
public void addDocument(Document doc) throws IOException {
+ addDocument(doc, analyzer);
+ }
+
+ /**
+ * Adds a document to this index, using the provided analyzer instead of the
+ * value of {@link #getAnalyzer()}. If the document contains more than
+ * {@link #maxFieldLength} terms for a given field, the remainder are
+ * discarded.
+ */
+ public void addDocument(Document doc, Analyzer analyzer) throws IOException {
DocumentWriter dw =
new DocumentWriter(ramDirectory, analyzer, similarity, maxFieldLength);
String segmentName = newSegmentName();