changeset 1573:c6b50b7b958c

lucene/Web_search improvement
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 12 Dec 2020 21:01:04 -0700
parents 45e42f403fb3
children f118ead273a1
files src/goodjava/lucene/queryparser/MultiFieldParser.java src/luan/modules/lucene/Web_search.luan
diffstat 2 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r 45e42f403fb3 -r c6b50b7b958c src/goodjava/lucene/queryparser/MultiFieldParser.java
--- a/src/goodjava/lucene/queryparser/MultiFieldParser.java	Thu Dec 10 20:23:45 2020 -0700
+++ b/src/goodjava/lucene/queryparser/MultiFieldParser.java	Sat Dec 12 21:01:04 2020 -0700
@@ -49,7 +49,7 @@
 				return fp.getQuery(qp,field,query);
 			if( allowUnspecifiedFields )
 				return defaultFieldParser.getQuery(qp,field,query);
-			throw qp.exception("unrecognized field '"+field+"'");
+			throw qp.exception("undefined query field '"+field+"'");
 		}
 	}
 
diff -r 45e42f403fb3 -r c6b50b7b958c src/luan/modules/lucene/Web_search.luan
--- a/src/luan/modules/lucene/Web_search.luan	Thu Dec 10 20:23:45 2020 -0700
+++ b/src/luan/modules/lucene/Web_search.luan	Sat Dec 12 21:01:04 2020 -0700
@@ -15,6 +15,8 @@
 local Number = require "luan:Number.luan"
 local Table = require "luan:Table.luan"
 local size = Table.size or error()
+local Logging = require "luan:logging/Logging.luan"
+local logger = Logging.logger "lucene/Web_search"
 
 
 local Web_search = {}
@@ -108,11 +110,38 @@
 	return n
 end
 
+local function failed(e)
+	logger.info(e)
+	--logger.info(stringify(e))
+	local msg = e.get_message()
+%>
+<!doctype html>
+<html>
+	<head>
+		<title>Lucene</title>
+		<style>
+<%			style() %>
+		</style>
+	</head>
+	<body>
+		<h2>Query Failed</h2>
+		<pre><%=msg%></pre>
+	</body>
+</html>
+<%
+end
+
 local function result(index)
 	local query = Http.request.parameters.query
 	local rows = string_to_number(Http.request.parameters.rows)
 	local sort = Http.request.parameters.sort
-	local results = index.search(query,1,rows,{sort=sort})
+	local results
+	try
+		results = index.search(query,1,rows,{sort=sort})
+	catch e
+		failed(e)
+		return
+	end
 	local headers = {}
 	local table = {}
 	for _, doc in ipairs(results) do