diff src/luan/modules/lucene/LuceneIndex.java @ 1749:d1e7564a9ce5

improve query parser
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 09 Jan 2023 22:06:06 -0700
parents 2958cf04d844
children 164c6ea53147
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java	Thu Dec 29 12:46:36 2022 -0700
+++ b/src/luan/modules/lucene/LuceneIndex.java	Mon Jan 09 22:06:06 2023 -0700
@@ -24,6 +24,7 @@
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.analysis.core.SimpleAnalyzer;
 import org.apache.lucene.analysis.en.EnglishAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -123,6 +124,7 @@
 	public static final StringFieldParser STRING_FIELD_PARSER = new StringFieldParser(new KeywordAnalyzer());
 	public static final StringFieldParser LOWERCASE_FIELD_PARSER = new StringFieldParser(new LowercaseAnalyzer(luceneVersion));
 	public static final StringFieldParser ENGLISH_FIELD_PARSER = new StringFieldParser(new EnglishAnalyzer(luceneVersion));
+	public static final StringFieldParser SIMPLE_FIELD_PARSER = new StringFieldParser(new SimpleAnalyzer(luceneVersion));
 	private static final SortField ID_SORT = new SortField("id",SortField.Type.LONG);
 	private static final SortField ID_DESC_SORT = new SortField("id",SortField.Type.LONG,true);
 
@@ -727,4 +729,8 @@
 		logger.info("end check");
 	}
 
+	public String explain_query(String queryStr) throws ParseException {
+		return GoodQueryParser.parseQuery(mfp,queryStr).toString();
+	}
+
 }