|
a/src/rcldb/synfamily.cpp |
|
b/src/rcldb/synfamily.cpp |
|
... |
|
... |
31 |
|
31 |
|
32 |
using namespace std;
|
32 |
using namespace std;
|
33 |
|
33 |
|
34 |
namespace Rcl {
|
34 |
namespace Rcl {
|
35 |
|
35 |
|
|
|
36 |
bool XapWritableSynFamily::createMember(const string& membername)
|
|
|
37 |
{
|
|
|
38 |
string ermsg;
|
|
|
39 |
try {
|
|
|
40 |
m_wdb.add_synonym(memberskey(), membername);
|
|
|
41 |
} XCATCHERROR(ermsg);
|
|
|
42 |
if (!ermsg.empty()) {
|
|
|
43 |
LOGERR(("XapSynFamily::createMember: error: %s\n", ermsg.c_str()));
|
|
|
44 |
return false;
|
|
|
45 |
}
|
|
|
46 |
return true;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
bool XapWritableSynFamily::deleteMember(const string& membername)
|
|
|
50 |
{
|
|
|
51 |
string key = entryprefix(membername);
|
|
|
52 |
|
|
|
53 |
for (Xapian::TermIterator xit = m_wdb.synonym_keys_begin(key);
|
|
|
54 |
xit != m_wdb.synonym_keys_end(key); xit++) {
|
|
|
55 |
m_wdb.clear_synonyms(*xit);
|
|
|
56 |
}
|
|
|
57 |
m_wdb.remove_synonym(memberskey(), membername);
|
|
|
58 |
return true;
|
|
|
59 |
}
|
|
|
60 |
|
36 |
bool XapSynFamily::getMembers(vector<string>& members)
|
61 |
bool XapSynFamily::getMembers(vector<string>& members)
|
37 |
{
|
62 |
{
|
38 |
string key = memberskey();
|
63 |
string key = memberskey();
|
39 |
string ermsg;
|
64 |
string ermsg;
|
40 |
try {
|
65 |
try {
|
|
... |
|
... |
107 |
}
|
132 |
}
|
108 |
|
133 |
|
109 |
return true;
|
134 |
return true;
|
110 |
}
|
135 |
}
|
111 |
|
136 |
|
112 |
bool XapWritableSynFamily::deleteMember(const string& membername)
|
|
|
113 |
{
|
|
|
114 |
string key = entryprefix(membername);
|
|
|
115 |
|
|
|
116 |
for (Xapian::TermIterator xit = m_wdb.synonym_keys_begin(key);
|
|
|
117 |
xit != m_wdb.synonym_keys_end(key); xit++) {
|
|
|
118 |
m_wdb.clear_synonyms(*xit);
|
|
|
119 |
}
|
|
|
120 |
m_wdb.remove_synonym(memberskey(), membername);
|
|
|
121 |
return true;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
bool XapWritableSynFamily::createMember(const string& membername)
|
|
|
125 |
{
|
|
|
126 |
string ermsg;
|
|
|
127 |
try {
|
|
|
128 |
m_wdb.add_synonym(memberskey(), membername);
|
|
|
129 |
} XCATCHERROR(ermsg);
|
|
|
130 |
if (!ermsg.empty()) {
|
|
|
131 |
LOGERR(("XapSynFamily::createMember: error: %s\n", ermsg.c_str()));
|
|
|
132 |
return false;
|
|
|
133 |
}
|
|
|
134 |
return true;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
bool XapComputableSynFamMember::synExpand(const string& term,
|
137 |
bool XapComputableSynFamMember::synExpand(const string& term,
|
138 |
vector<string>& result,
|
138 |
vector<string>& result,
|
139 |
SynTermTrans *filtertrans)
|
139 |
SynTermTrans *filtertrans)
|
140 |
{
|
140 |
{
|
141 |
string root = (*m_trans)(term);
|
141 |
string root = (*m_trans)(term);
|
|
... |
|
... |
179 |
}
|
179 |
}
|
180 |
LOGDEB(("XapCompSynFamMbr::synExpand([%s]): term [%s] -> [%s]\n",
|
180 |
LOGDEB(("XapCompSynFamMbr::synExpand([%s]): term [%s] -> [%s]\n",
|
181 |
m_prefix.c_str(), term.c_str(), stringsToString(result).c_str()));
|
181 |
m_prefix.c_str(), term.c_str(), stringsToString(result).c_str()));
|
182 |
return true;
|
182 |
return true;
|
183 |
}
|
183 |
}
|
184 |
|
|
|
185 |
|
184 |
|
186 |
bool XapComputableSynFamMember::keyWildExpand(const string& inexp,
|
185 |
bool XapComputableSynFamMember::keyWildExpand(const string& inexp,
|
187 |
vector<string>& result,
|
186 |
vector<string>& result,
|
188 |
SynTermTrans *filtertrans)
|
187 |
SynTermTrans *filtertrans)
|
189 |
{
|
188 |
{
|
|
... |
|
... |
222 |
|
221 |
|
223 |
string ermsg;
|
222 |
string ermsg;
|
224 |
try {
|
223 |
try {
|
225 |
for (Xapian::TermIterator xit = m_family.getdb().synonym_keys_begin(is);
|
224 |
for (Xapian::TermIterator xit = m_family.getdb().synonym_keys_begin(is);
|
226 |
xit != m_family.getdb().synonym_keys_end(is); xit++) {
|
225 |
xit != m_family.getdb().synonym_keys_end(is); xit++) {
|
227 |
LOGDEB((" Checking1 [%s] against [%s]\n", (*xit).c_str(),
|
226 |
LOGDEB2((" Checking1 [%s] against [%s]\n", (*xit).c_str(),
|
228 |
matchin.c_str()));
|
227 |
matchin.c_str()));
|
229 |
if (fnmatch(matchin.c_str(), (*xit).c_str(), 0) == FNM_NOMATCH)
|
228 |
if (fnmatch(matchin.c_str(), (*xit).c_str(), 0) == FNM_NOMATCH)
|
230 |
continue;
|
229 |
continue;
|
231 |
|
230 |
|
232 |
// Push all the synonyms if they match the secondary filter
|
231 |
// Push all the synonyms if they match the secondary filter
|
233 |
for (Xapian::TermIterator xit1 =
|
232 |
for (Xapian::TermIterator xit1 =
|
234 |
m_family.getdb().synonyms_begin(*xit);
|
233 |
m_family.getdb().synonyms_begin(*xit);
|
235 |
xit1 != m_family.getdb().synonyms_end(*xit); xit1++) {
|
234 |
xit1 != m_family.getdb().synonyms_end(*xit); xit1++) {
|
236 |
string term = *xit1;
|
235 |
string term = *xit1;
|
237 |
if (filtertrans) {
|
236 |
if (filtertrans) {
|
238 |
string term1 = (*filtertrans)(term);
|
237 |
string term1 = (*filtertrans)(term);
|
239 |
LOGDEB((" Testing [%s] against [%s]\n",
|
238 |
LOGDEB2((" Testing [%s] against [%s]\n",
|
240 |
term1.c_str(), filter_exp.c_str()));
|
239 |
term1.c_str(), filter_exp.c_str()));
|
241 |
if (fnmatch(filter_exp.c_str(),
|
240 |
if (fnmatch(filter_exp.c_str(),
|
242 |
term1.c_str(), 0) == FNM_NOMATCH) {
|
241 |
term1.c_str(), 0) == FNM_NOMATCH) {
|
243 |
continue;
|
242 |
continue;
|
244 |
}
|
243 |
}
|
245 |
}
|
244 |
}
|