mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-13 12:54:14 +00:00
Full-text search: Do not fail rest of search if one result has invalid json
This commit is contained in:
parent
269a3c3f65
commit
7dd01b6e23
@ -64,20 +64,22 @@ class Xosearch_fulltext_svc implements Gfo_invk {
|
|||||||
int page_id = page_rdr.Read_int("page_id");
|
int page_id = page_rdr.Read_int("page_id");
|
||||||
int text_db_id = page_rdr.Read_int("page_text_db_id");
|
int text_db_id = page_rdr.Read_int("page_text_db_id");
|
||||||
byte[] text_mcase = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(text_db_id).Tbl__text().Select(page_id);
|
byte[] text_mcase = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(text_db_id).Tbl__text().Select(page_id);
|
||||||
|
int ns_id = page_rdr.Read_int("page_namespace");
|
||||||
|
byte[] ttl_bry = page_rdr.Read_bry_by_str("page_title");
|
||||||
|
Xoa_ttl ttl = wiki.Ttl_parse(ns_id, ttl_bry);
|
||||||
|
|
||||||
cbk_eval.found = false;
|
// do eval
|
||||||
|
cbk_eval.Init(ttl.Full_db());
|
||||||
finder.Match(text_mcase, 0, text_mcase.length, cbk_eval);
|
finder.Match(text_mcase, 0, text_mcase.length, cbk_eval);
|
||||||
searched++;
|
searched++;
|
||||||
if (cbk_eval.found) {
|
if (cbk_eval.found) {
|
||||||
int ns_id = page_rdr.Read_int("page_namespace");
|
|
||||||
byte[] ttl_bry = page_rdr.Read_bry_by_str("page_title");
|
|
||||||
Xoa_ttl ttl = wiki.Ttl_parse(ns_id, ttl_bry);
|
|
||||||
++found;
|
++found;
|
||||||
|
|
||||||
Notify_pages_found_and_searched(wiki_domain, found, searched);
|
Notify_pages_found_and_searched(wiki_domain, found, searched);
|
||||||
|
|
||||||
|
// do highlight
|
||||||
if (found <= max_pages_per_wiki) {
|
if (found <= max_pages_per_wiki) {
|
||||||
cbk_highlight.Init(wiki, page_id, max_snips_per_page);
|
cbk_highlight.Init(wiki, page_id, ttl.Full_db(), max_snips_per_page);
|
||||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.search_fulltext.results__page__add__recv", gplx.core.gfobjs.Gfobj_nde.New()
|
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.search_fulltext.results__page__add__recv", gplx.core.gfobjs.Gfobj_nde.New()
|
||||||
.Add_bry("wiki", wiki_domain)
|
.Add_bry("wiki", wiki_domain)
|
||||||
.Add_int("page_id", page_id)
|
.Add_int("page_id", page_id)
|
||||||
|
@ -16,6 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
package gplx.xowa.addons.wikis.searchs.fulltexts.finders; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
package gplx.xowa.addons.wikis.searchs.fulltexts.finders; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||||
import gplx.xowa.guis.cbks.*;
|
import gplx.xowa.guis.cbks.*;
|
||||||
public interface Xosearch_finder_cbk {
|
public interface Xosearch_finder_cbk {
|
||||||
|
byte[] Page_ttl();
|
||||||
void Process_item_found(byte[] src, int hook_bgn, int hook_end, int word_bgn, int word_end, Xosearch_word_node term);
|
void Process_item_found(byte[] src, int hook_bgn, int hook_end, int word_bgn, int word_end, Xosearch_word_node term);
|
||||||
void Process_page_done(byte[] src, Xosearch_word_node tree_root);
|
void Process_page_done(byte[] src, Xosearch_word_node tree_root);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
package gplx.xowa.addons.wikis.searchs.fulltexts.finders; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
package gplx.xowa.addons.wikis.searchs.fulltexts.finders; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||||
public class Xosearch_finder_cbk__eval implements Xosearch_finder_cbk {
|
public class Xosearch_finder_cbk__eval implements Xosearch_finder_cbk {
|
||||||
public boolean found;
|
public boolean found;
|
||||||
|
public byte[] Page_ttl() {return page_ttl;} private byte[] page_ttl;
|
||||||
|
public void Init(byte[] page_ttl) {
|
||||||
|
this.found = false;
|
||||||
|
this.page_ttl = page_ttl;
|
||||||
|
}
|
||||||
public void Process_item_found(byte[] src, int hook_bgn, int hook_end, int word_bgn, int word_end, Xosearch_word_node term) {
|
public void Process_item_found(byte[] src, int hook_bgn, int hook_end, int word_bgn, int word_end, Xosearch_word_node term) {
|
||||||
term.found = true;
|
term.found = true;
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,11 @@ public class Xosearch_finder_cbk__highlight implements Xosearch_finder_cbk {
|
|||||||
this.app = app;
|
this.app = app;
|
||||||
this.cbk_trg = cbk_trg;
|
this.cbk_trg = cbk_trg;
|
||||||
}
|
}
|
||||||
public void Init(Xow_wiki wiki, int page_id, int max_snips_per_page) {
|
public byte[] Page_ttl() {return page_ttl;} private byte[] page_ttl;
|
||||||
|
public void Init(Xow_wiki wiki, int page_id, byte[] page_ttl, int max_snips_per_page) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
this.page_id = page_id;
|
this.page_id = page_id;
|
||||||
|
this.page_ttl= page_ttl;
|
||||||
this.max_snips_per_page = max_snips_per_page;
|
this.max_snips_per_page = max_snips_per_page;
|
||||||
found = 0;
|
found = 0;
|
||||||
}
|
}
|
||||||
|
@ -56,18 +56,23 @@ public class Xosearch_finder_mgr {
|
|||||||
int hook_bgn = cur;
|
int hook_bgn = cur;
|
||||||
int hook_end = cur + hook.word_hook.length;
|
int hook_end = cur + hook.word_hook.length;
|
||||||
|
|
||||||
// get word_bounds
|
try {
|
||||||
lang.Get_word_bounds(word_bounds, trv, src, src_end, hook_bgn, hook_end);
|
// get word_bounds
|
||||||
int word_bgn = word_bounds.word_bgn;
|
lang.Get_word_bounds(word_bounds, trv, src, src_end, hook_bgn, hook_end);
|
||||||
int word_end = word_bounds.word_end;
|
int word_bgn = word_bounds.word_bgn;
|
||||||
|
int word_end = word_bounds.word_end;
|
||||||
|
|
||||||
// check if current word matches criteria-word
|
// check if current word matches criteria-word
|
||||||
if (hook.Match_word(lang, src, hook_bgn, hook_end, word_bgn, word_end)) {
|
if (hook.Match_word(lang, src, hook_bgn, hook_end, word_bgn, word_end)) {
|
||||||
cbk.Process_item_found(src, hook_bgn, hook_end, word_bgn, word_end, hook);
|
cbk.Process_item_found(src, hook_bgn, hook_end, word_bgn, word_end, hook);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update position to word_end
|
||||||
|
cur = word_end;
|
||||||
|
} catch (Exception e) {
|
||||||
|
cur = hook_end;
|
||||||
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "fatal error in match; page=~{0} hook=~{1} src=~{2}", cbk.Page_ttl(), hook.word_orig, Err_.Message_gplx_log(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update position to word_end
|
|
||||||
cur = word_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark page done
|
// mark page done
|
||||||
|
Loading…
Reference in New Issue
Block a user