Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/Web_search.luan @ 515:1b2e4c7dab85
fix lucene sort and improve Web_search
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 26 May 2015 02:05:22 -0600 |
parents | 7bc63886d4f2 |
children | 5fed3de0aac7 |
line wrap: on
line diff
--- a/lucene/src/luan/modules/lucene/Web_search.luan Mon May 25 22:19:18 2015 -0600 +++ b/lucene/src/luan/modules/lucene/Web_search.luan Tue May 26 02:05:22 2015 -0600 @@ -3,6 +3,7 @@ local pairs = Luan.pairs local ipairs = Luan.ipairs local range = Luan.range +local to_string = Luan.to_string local Io = require "luan:Io" local Http = require "luan:http/Http" local String = require "luan:String" @@ -25,8 +26,8 @@ <label>Query:</label> </div> <div colspan=10> - <input name="query" size="80" value="Query.all_docs" autofocus /> - <div textcolor="#888">Query examples: <i>Query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div> + <input name="query" size="80" value="query.all_docs" autofocus /> + <div textcolor="#888">Query examples: <i>query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div> </div> </div> <div row margin-top="1em"> @@ -43,7 +44,7 @@ </div> <div colspan=10> <input name="sort" size="60" /> - <div textcolor="#888">Sort examples: Query.sort{{ field = 'id', type='int' }}</div> + <div textcolor="#888">Sort examples: sort{{ field = 'id', type='int' }}</div> </div> </div> <div row margin-top="1em"> @@ -74,7 +75,7 @@ <label>Query:</label> </div> <div colspan=10> - <b><%=query%></b></p> + <b><%=Html.encode(to_string(query))%></b></p> </div> </div> <div row> @@ -82,7 +83,7 @@ <label>Sort:</label> </div> <div colspan=10> - <b><%=sort%></b></p> + <b><%=Html.encode(to_string(sort))%></b></p> </div> </div> <table border condensed margin-top="1.5em"> @@ -129,9 +130,9 @@ form() return end - local query = load(query_string,"<query>",{Query=index.query},true)() + local query = load(query_string,"<query>",{query=index.query},true)() local rows = Http.request.parameter.rows.to_number() - local sort = load(Http.request.parameter.sort,"<sort>",{Query=index.query},true)() + local sort = load(Http.request.parameter.sort,"<sort>",{sort=index.query.sort},true)() index.Searcher( function(searcher) local results, length, total_hits = searcher.search(query,rows,sort) local headers = {}