comparison lucene/src/luan/modules/lucene/Web_search.luan @ 287:4d53e9fc1bd9

change lucene search to take lucene objects git-svn-id: https://luan-java.googlecode.com/svn/trunk@288 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 04 Dec 2014 09:27:20 +0000
parents 91be4027b2a8
children 5652cdea25f5
comparison
equal deleted inserted replaced
286:91be4027b2a8 287:4d53e9fc1bd9
25 </head> 25 </head>
26 <body> 26 <body>
27 <h1>Lucene Query</h1> 27 <h1>Lucene Query</h1>
28 <form name="form0" method="post"> 28 <form name="form0" method="post">
29 <p> 29 <p>
30 <span class="label">Query:</span> <input name="query" size="60" /> 30 <span class="label">Query:</span> <input name="query" size="60" value="Query.all_docs" />
31 <div class="tip"><span class="label"></span> Query examples: { type = 'user' }</div> 31 <div class="tip"><span class="label"></span> Query examples: Query.term{ type = 'user' }</div>
32 </p> 32 </p>
33 <p><span class="label">Max Rows:</span> <input name="rows" value="20" maxlength="5" onkeypress="return event.charCode >= 48 && event.charCode <= 57" style="width:3em"/></p> 33 <p><span class="label">Max Rows:</span> <input name="rows" value="20" maxlength="5" onkeypress="return event.charCode >= 48 && event.charCode <= 57" style="width:3em"/></p>
34 <p><span class="label">Sort:</span> <input name="sort" size="60" /></p> 34 <p>
35 <span class="label">Sort:</span> <input name="sort" size="60" />
36 <div class="tip"><span class="label"></span> Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
37 </p>
35 <p><input type="submit" class="btn"/></p> 38 <p><input type="submit" class="btn"/></p>
36 </form> 39 </form>
37 <script>document.form0.query.focus();</script> 40 <script>document.form0.query.focus();</script>
38 </body> 41 </body>
39 </html> 42 </html>
46 <head> 49 <head>
47 <style><% basic_style() %></style> 50 <style><% basic_style() %></style>
48 </head> 51 </head>
49 <body> 52 <body>
50 <h1>Lucene Query Results</h1> 53 <h1>Lucene Query Results</h1>
51 <p><span class="label">Query:</span> <b><%=repr(query)%></b></p> 54 <p><span class="label">Query:</span> <b><%=query%></b></p>
52 <p><span class="label">Sort:</span> <b><%=repr(sort)%></b></p> 55 <p><span class="label">Sort:</span> <b><%=sort%></b></p>
53 <table class="results"> 56 <table class="results">
54 <tr> 57 <tr>
55 <th></th> 58 <th></th>
56 <% for _, header in ipairs(headers) do %> 59 <% for _, header in ipairs(headers) do %>
57 <th><%=header%></th> 60 <th><%=header%></th>
90 local query_string = Http.request.parameters.query 93 local query_string = Http.request.parameters.query
91 if query_string == nil then 94 if query_string == nil then
92 form() 95 form()
93 return 96 return
94 end 97 end
95 local query = load(query_string,"<query>",{},true)() 98 local query = load(query_string,"<query>",{Query=index.Query},true)()
96 local rows = to_number(Http.request.parameters.rows) 99 local rows = to_number(Http.request.parameters.rows)
97 local sort = load(Http.request.parameters.sort,"<sort>",{},true)() 100 local sort = load(Http.request.parameters.sort,"<sort>",{Query=index.Query},true)()
98 index.Searcher( function(searcher) 101 index.Searcher( function(searcher)
99 local results, length, total_hits = searcher.search(query,rows,sort) 102 local results, length, total_hits = searcher.search(query,rows,sort)
100 local headers = {} 103 local headers = {}
101 local table = {} 104 local table = {}
102 for doc in results do 105 for doc in results do