changeset 1535:e73b72a510b4

Lucene reindex
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 02 Aug 2020 21:30:47 -0600
parents 3289674cc440
children 34ae786771b6
files src/luan/modules/lucene/Lucene.luan src/luan/modules/lucene/LuceneIndex.java
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/lucene/Lucene.luan	Sun Aug 02 21:21:35 2020 -0600
+++ b/src/luan/modules/lucene/Lucene.luan	Sun Aug 02 21:30:47 2020 -0600
@@ -59,6 +59,7 @@
 	index.search_in_transaction = java_index.search_in_transaction
 	index.delete_all = java_index.delete_all
 	index.delete = java_index.delete
+	index.reindex = java_index.reindex
 	--index.save = java_index.save
 	index.is_in_transaction = java_index.is_in_transaction
 	index.run_in_transaction = java_index.run_in_transaction
--- a/src/luan/modules/lucene/LuceneIndex.java	Sun Aug 02 21:21:35 2020 -0600
+++ b/src/luan/modules/lucene/LuceneIndex.java	Sun Aug 02 21:30:47 2020 -0600
@@ -259,6 +259,22 @@
 		}
 	}
 
+	public void reindex(String queryStr)
+		throws IOException, ParseException
+	{
+		Query query = GoodQueryParser.parseQuery(mfp,queryStr);
+
+		boolean commit = !writeLock.isHeldByCurrentThread();
+		writeLock.lock();
+		try {
+			writer.reindexDocuments("id",query);
+			if(commit) writer.commit();
+		} finally {
+			wrote();
+			writeLock.unlock();
+		}
+	}
+
 	public void save(LuanTable doc)
 		throws LuanException, IOException, SQLException
 	{