aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid 'arrdem' McKenzie <reid@factual.com>2015-08-13 10:46:16 -0700
committerReid 'arrdem' McKenzie <reid@factual.com>2015-08-13 10:46:16 -0700
commit3b7a7be9a2071d0b94e55d631c47fe7f400de5e0 (patch)
tree0ed4ca4f9cc31d496456e8171552db73bc779d69
parent0ddb02481080df10559ea6ebc85d29c79fa858ee (diff)
downloadclucy-3b7a7be9a2071d0b94e55d631c47fe7f400de5e0.tar.gz
clucy-3b7a7be9a2071d0b94e55d631c47fe7f400de5e0.tar.xz
clucy-3b7a7be9a2071d0b94e55d631c47fe7f400de5e0.zip
Explicitly enable creating the index
When writing the first time, the index will be created if it does not exist. Reading an index will not cause it to be created.
-rw-r--r--src/clucy/core.clj9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/clucy/core.clj b/src/clucy/core.clj
index 9cd9d46..5168282 100644
--- a/src/clucy/core.clj
+++ b/src/clucy/core.clj
@@ -4,7 +4,9 @@
(org.apache.lucene.analysis.standard StandardAnalyzer)
(org.apache.lucene.document Document Field Field$Index Field$Store)
(org.apache.lucene.index IndexWriter IndexReader Term
- IndexWriterConfig DirectoryReader FieldInfo)
+ IndexWriterConfig
+ IndexWriterConfig$OpenMode
+ DirectoryReader FieldInfo)
(org.apache.lucene.queryparser.classic QueryParser)
(org.apache.lucene.search BooleanClause BooleanClause$Occur
BooleanQuery IndexSearcher Query ScoreDoc
@@ -43,8 +45,9 @@
"Create an IndexWriter."
^IndexWriter
[index]
- (IndexWriter. index
- (IndexWriterConfig. *version* *analyzer*)))
+ (let [iwcfg (IndexWriterConfig. *version* *analyzer*)]
+ (.setOpenMode iwcfg IndexWriterConfig$OpenMode/CREATE_OR_APPEND)
+ (IndexWriter. index iwcfg)))
(defn- index-reader
"Create an IndexReader."