Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lintest/myrulib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-10-19 23:38:01 +0400
committerKandrashin Denis <mail@lintest.ru>2012-10-19 23:38:01 +0400
commit367dd21a106267ba55944984bc002aca814b4d32 (patch)
tree8f84513a56eb5bf371ec6e886d1f2e00ec56d9e9 /sources
parent489fa3e15fccf42d1656c393c1725aa54dde6d54 (diff)
Store <annotation> in FTS table
Diffstat (limited to 'sources')
-rw-r--r--sources/MyRuLib/FbDatabase.cpp39
-rw-r--r--sources/MyRuLib/FbDatabase.h2
-rw-r--r--sources/MyRuLib/FbMasterTypes.cpp2
3 files changed, 22 insertions, 21 deletions
diff --git a/sources/MyRuLib/FbDatabase.cpp b/sources/MyRuLib/FbDatabase.cpp
index b31dddfa..4754cad9 100644
--- a/sources/MyRuLib/FbDatabase.cpp
+++ b/sources/MyRuLib/FbDatabase.cpp
@@ -696,32 +696,33 @@ void FbMainDatabase::DoUpgrade(int version)
}
}
-void FbMainDatabase::CreateTableFTS(const wxString & name, const wxString & table, const wxString & field)
-{
- ExecuteUpdate(wxString::Format(wxT("DROP TABLE IF EXISTS fts_%s"), name.c_str()));
- wxString sql = wxString::Format(wxT("CREATE VIRTUAL TABLE fts_%s USING fts3"), name.c_str());
- #ifdef SQLITE_ENABLE_ICU
- sql << wxT("(tokenize=icu ru_RU)");
- #else
- sql << wxT("(tokenize=porter)");
- #endif
- ExecuteUpdate(sql);
-
- if (name == wxT("book")) {
- ExecuteUpdate(fbT("ALTER TABLE fts_book ADD dscr TEXT"));
- sql = wxString::Format(wxT("INSERT INTO fts_%s(docid,content,dscr)SELECT DISTINCT id,LOW(%s),LOW(description)FROM %s"), name.c_str(), field.c_str(), table.c_str());
- } else {
- sql = wxString::Format(wxT("INSERT INTO fts_%s(docid,content)SELECT DISTINCT id,LOW(%s)FROM %s"), name.c_str(), field.c_str(), table.c_str());
- }
- ExecuteUpdate(sql);
+void FbMainDatabase::CreateTableFTS(const wxString & name, const wxString & table, const wxString & source, const wxString & target)
+{
+#ifdef SQLITE_ENABLE_ICU
+ wxString token = wxT("icu ru_RU");
+#else
+ wxString token = wxT("porter)");
+#endif
+ ExecuteUpdate(wxString::Format(
+ wxT("DROP TABLE IF EXISTS fts_%s"),
+ name.c_str())
+ );
+ ExecuteUpdate(wxString::Format(
+ wxT("CREATE VIRTUAL TABLE fts_%s USING fts3(content%s,tokenize=%s)"),
+ name.c_str(), target.c_str(), token.c_str()
+ ));
+ ExecuteUpdate(wxString::Format(
+ wxT("INSERT INTO fts_%s(docid,content%s)SELECT DISTINCT id,LOW(%s)FROM %s"),
+ name.c_str(), target.c_str(), source.c_str(), table.c_str()
+ ));
}
void FbMainDatabase::CreateFullText(bool force, FbThread * thread)
{
if ( !force && TableExists(wxT("fts_book_content")) ) return;
wxSQLite3Transaction trans(this, WXSQLITE_TRANSACTION_IMMEDIATE);
+ CreateTableFTS(wxT("book"), wxT("books"), wxT("title),LOW(description"), wxT(",dscr"));
CreateTableFTS(wxT("auth"), wxT("authors"), wxT("full_name"));
- CreateTableFTS(wxT("book"), wxT("books"), wxT("title"));
CreateTableFTS(wxT("seqn"), wxT("sequences"), wxT("value"));
ExecuteUpdate(fbT("UPDATE books SET deleted=NULL WHERE deleted=0"));
ExecuteUpdate(fbT("UPDATE authors SET letter=LTTR(full_name) WHERE id"));
diff --git a/sources/MyRuLib/FbDatabase.h b/sources/MyRuLib/FbDatabase.h
index da941b37..444e4980 100644
--- a/sources/MyRuLib/FbDatabase.h
+++ b/sources/MyRuLib/FbDatabase.h
@@ -185,7 +185,7 @@ class FbMainDatabase: public FbMasterDatabase
virtual wxString GetMaster() { return wxT("params"); };
private:
void CreateDatabase();
- void CreateTableFTS(const wxString & name, const wxString & table, const wxString & field);
+ void CreateTableFTS(const wxString & name, const wxString & table, const wxString & source, const wxString & target = wxEmptyString);
};
#endif // __FBDATABASE_H__
diff --git a/sources/MyRuLib/FbMasterTypes.cpp b/sources/MyRuLib/FbMasterTypes.cpp
index 8ea3e111..bac8496a 100644
--- a/sources/MyRuLib/FbMasterTypes.cpp
+++ b/sources/MyRuLib/FbMasterTypes.cpp
@@ -283,7 +283,7 @@ IMPLEMENT_CLASS(FbMasterFindInfo, FbMasterInfoBase)
wxString FbMasterFindInfo::GetWhere(wxSQLite3Database &database) const
{
if (m_full) {
- wxString sql = wxT("books.id IN (SELECT docid FROM fts_book WHERE fts_book MATCH ?)");
+ wxString sql = wxT("books.id IN (SELECT docid FROM fts_book WHERE fts_book.content MATCH ?)");
if (m_auth) sql << wxT("AND books.id_author IN (SELECT docid FROM fts_auth WHERE fts_auth MATCH ?)");
return sql;
} else {