changeset 1412:4ba0377afa3e

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 02 Oct 2019 12:25:06 -0600
parents 8dec6b62a5e4
children 514b7a62fe27
files src/luan/modules/lucene/Web_search.luan
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
diff -r 8dec6b62a5e4 -r 4ba0377afa3e src/luan/modules/lucene/Web_search.luan
--- a/src/luan/modules/lucene/Web_search.luan	Mon Sep 30 19:20:05 2019 -0600
+++ b/src/luan/modules/lucene/Web_search.luan	Wed Oct 02 12:25:06 2019 -0600
@@ -191,6 +191,7 @@
 	<body>
 		<h2>Lucene Edit</h2>
 		<form action="?" method=post>
+			<input hidden name=id value="<%=id%>">
 			<div><textarea name="doc" rows="20" cols="90" autofocus><%=html_encode(doc)%></textarea></div>
 			<div><input type="submit" value="Update"></div>
 		</form>
@@ -202,10 +203,15 @@
 
 local function update(index)
 	local doc = Http.request.parameters.doc
-	local completer = index.completer or error()
 	doc = eval( doc, "lucene", Number )
-	doc = completer(doc)
-	index.save(doc)
+	if doc == nil then
+		local id = Http.request.parameters.id
+		index.delete("id:"..id)
+	else
+		local completer = index.completer or error()
+		doc = completer(doc)
+		index.save(doc)
+	end
 %>
 <!doctype html>
 <html>
@@ -231,10 +237,10 @@
 		local query = Http.request.parameters.query
 		if Http.request.parameters.query ~= nil then
 			result(index)
+		elseif Http.request.parameters.doc ~= nil then
+			update(index)
 		elseif Http.request.parameters.id ~= nil then
 			edit(index)
-		elseif Http.request.parameters.doc ~= nil then
-			update(index)
 		else
 			form()
 		end