changeset 1749:d1e7564a9ce5

improve query parser
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 09 Jan 2023 22:06:06 -0700
parents c7d79ba1c476
children c7b3c327248a
files src/goodjava/lucene/queryparser/GoodQueryParser.java src/luan/modules/lucene/Lucene.luan src/luan/modules/lucene/LuceneIndex.java
diffstat 3 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/goodjava/lucene/queryparser/GoodQueryParser.java	Thu Dec 29 12:46:36 2022 -0700
+++ b/src/goodjava/lucene/queryparser/GoodQueryParser.java	Mon Jan 09 22:06:06 2023 -0700
@@ -47,8 +47,8 @@
 	}
 
 
-	private static final String NOT_IN_RANGE = " \t\r\n\":[]{}^+()";
-	private static final String NOT_IN_TERM = NOT_IN_RANGE + "-";
+	private static final String NOT_IN_RANGE = " \t\r\n\":[]{}^()";
+	private static final String NOT_IN_TERM = NOT_IN_RANGE;
 	private static final String NOT_IN_FIELD = NOT_IN_TERM + ",";
 	private final FieldParser fieldParser;
 	private final Parser parser;
--- a/src/luan/modules/lucene/Lucene.luan	Thu Dec 29 12:46:36 2022 -0700
+++ b/src/luan/modules/lucene/Lucene.luan	Mon Jan 09 22:06:06 2023 -0700
@@ -54,6 +54,7 @@
 	english = LuceneIndex.ENGLISH_FIELD_PARSER
 	string = LuceneIndex.STRING_FIELD_PARSER
 	lowercase = LuceneIndex.LOWERCASE_FIELD_PARSER
+	simple = LuceneIndex.SIMPLE_FIELD_PARSER
 	integer = NumberFieldParser.INT
 	long = NumberFieldParser.LONG
 	double = NumberFieldParser.DOUBLE
@@ -116,6 +117,8 @@
 
 	index.check = java_index.check
 
+	index.explain_query = java_index.explain_query
+
 	function index.not_in_transaction() end
 
 	function index.check_in_transaction()
--- 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();
+	}
+
 }