Mercurial Hosting > luan
changeset 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 | 7d1afc73f835 |
children | 5752df8a67b5 |
files | lucene/src/luan/modules/lucene/Lucene.luan lucene/src/luan/modules/lucene/Web_search.luan |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
diff -r 7d1afc73f835 -r 1b2e4c7dab85 lucene/src/luan/modules/lucene/Lucene.luan --- a/lucene/src/luan/modules/lucene/Lucene.luan Mon May 25 22:19:18 2015 -0600 +++ b/lucene/src/luan/modules/lucene/Lucene.luan Tue May 26 02:05:22 2015 -0600 @@ -120,9 +120,10 @@ for _, f in ipairs(fields) do f.field or error "missing sort field" f.type or error "missing sort type" + local field = index.map_field_name(f.field) local type = SortField.Type.valueOf( f.type.upper() ) local reverse = f.reverse or false - a[#a+1] = SortField.new(f.field,type,reverse) + a[#a+1] = SortField.new(field,type,reverse) end return Sort.new(Table.unpack(a)) end
diff -r 7d1afc73f835 -r 1b2e4c7dab85 lucene/src/luan/modules/lucene/Web_search.luan --- 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 = {}