1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Full-text search: Fix caching; also, continue searching until finding desired number of results

This commit is contained in:
gnosygnu 2017-03-22 21:10:20 -04:00
parent ab1b9f7509
commit c3eca52574
5 changed files with 11 additions and 6 deletions

View File

@ -62,7 +62,7 @@ public class Xofulltext_finder_cbk__highlight implements Xofulltext_finder_cbk {
// send notification
byte[] line_html = tmp_bfr.To_bry_and_clear();
ui.Send_line_add(show_all_matches, qry_id, wiki.Domain_bry(), page_id, found, line_html);
ui.Send_line_add(true, show_all_matches, qry_id, wiki.Domain_bry(), page_id, found, line_html);
found++;
}
private static final byte[] Angle_bgn_escaped = Bry_.new_a7("<");

View File

@ -74,7 +74,7 @@ class Xofulltext_highlighter_mgr implements Gfo_invk {
int page_id = item.page_id;
Gflucene_highlighter_item[] lines = highlighter_mgr.Exec(searcher_data, item);
for (Gflucene_highlighter_item line : lines) {
ui.Send_line_add(searcher_args.show_all_matches, searcher_args.qry_id, wiki.Domain_bry(), page_id, line.num, Bry_.new_u8(line.text));
ui.Send_line_add(true, searcher_args.show_all_matches, searcher_args.qry_id, wiki.Domain_bry(), page_id, line.num, Bry_.new_u8(line.text));
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@ -47,9 +47,13 @@ public class Xofulltext_searcher__lucene implements Xofulltext_searcher {
int needed_end = wiki_args.bgn + wiki_args.len;
int needed_len = needed_end - needed_bgn;
int found = 0;
int threshold = 0;
Gflucene_searcher_qry searcher_data = new Gflucene_searcher_qry(String_.new_u8(args.search_text), 100);
while (found < needed_len) {
if (args.Canceled()) return;
threshold += wiki_args.len;
searcher_data.match_max = threshold;
searcher.Exec(temp_list, searcher_data);
int temp_list_len = temp_list.Len();

View File

@ -50,8 +50,9 @@ public class Xofulltext_searcher_ui {
);
cache_mgr.Add_page(page.Query_id(), page.Wiki_domain(), page.Page_id(), page.Page_ttl());
}
public void Send_line_add(boolean show_all_matches, int qry_id, byte[] wiki_domain, int page_id, int line_sort_order, byte[] line_html) {
cache_mgr.Add_line(qry_id, wiki_domain, page_id, line_sort_order, line_html);
public void Send_line_add(boolean add_to_cache, boolean show_all_matches, int qry_id, byte[] wiki_domain, int page_id, int line_sort_order, byte[] line_html) {
if (add_to_cache)
cache_mgr.Add_line(qry_id, wiki_domain, page_id, line_sort_order, line_html);
line_sort_order += List_adp_.Base1; // NOTE: increment after cache_mgr
if (line_sort_order == 1 || show_all_matches) {

View File

@ -129,7 +129,7 @@ class Xofulltext_searcher_svc implements Gfo_invk {
int lines_len = page.Lines().Len();
for (int j = 0; j < lines_len; j++) {
Xofulltext_cache_line line = (Xofulltext_cache_line)page.Lines().Get_at(j);
ui.Send_line_add(args.show_all_matches, qry_id, wiki.Domain_bry(), page.Page_id(), line.Line_seq(), line.Line_html());
ui.Send_line_add(false, args.show_all_matches, qry_id, wiki.Domain_bry(), page.Page_id(), line.Line_seq(), line.Line_html());
}
}
return true;
@ -144,7 +144,7 @@ class Xofulltext_searcher_svc implements Gfo_invk {
Xofulltext_cache_line[] lines = cache_mgr.Get_lines_rest(qry_id, wiki_bry, page_id);
for (Xofulltext_cache_line line : lines) {
searcher_ui.Send_line_add(true, qry_id, wiki_bry, page_id, line.Line_seq(), line.Line_html());
searcher_ui.Send_line_add(false, true, qry_id, wiki_bry, page_id, line.Line_seq(), line.Line_html());
}
}
private Xofulltext_searcher Get_searcher(Xow_wiki wiki) {