|
a/src/rcldb/searchdata.cpp |
|
b/src/rcldb/searchdata.cpp |
|
... |
|
... |
126 |
// If this structure is an AND list, must use AND_NOT for excl clauses.
|
126 |
// If this structure is an AND list, must use AND_NOT for excl clauses.
|
127 |
// Else this is an OR list, and there can't be excl clauses (checked by
|
127 |
// Else this is an OR list, and there can't be excl clauses (checked by
|
128 |
// addClause())
|
128 |
// addClause())
|
129 |
Xapian::Query::op op;
|
129 |
Xapian::Query::op op;
|
130 |
if (tp == SCLT_AND) {
|
130 |
if (tp == SCLT_AND) {
|
131 |
if ((*it)->m_tp == SCLT_EXCL) {
|
131 |
if ((*it)->m_tp == SCLT_EXCL || (*it)->getexclude()) {
|
132 |
op = Xapian::Query::OP_AND_NOT;
|
132 |
op = Xapian::Query::OP_AND_NOT;
|
133 |
} else {
|
133 |
} else {
|
134 |
op = Xapian::Query::OP_AND;
|
134 |
op = Xapian::Query::OP_AND;
|
135 |
}
|
135 |
}
|
136 |
} else {
|
136 |
} else {
|
|
... |
|
... |
272 |
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
|
272 |
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
|
273 |
}
|
273 |
}
|
274 |
xq = xq.empty() ? tq : Xapian::Query(Xapian::Query::OP_AND_NOT, xq, tq);
|
274 |
xq = xq.empty() ? tq : Xapian::Query(Xapian::Query::OP_AND_NOT, xq, tq);
|
275 |
}
|
275 |
}
|
276 |
|
276 |
|
277 |
// Add the directory filtering clauses. Each is a phrase of terms
|
|
|
278 |
// prefixed with the pathelt prefix XP
|
|
|
279 |
for (vector<DirSpec>::const_iterator dit = m_dirspecs.begin();
|
|
|
280 |
dit != m_dirspecs.end(); dit++) {
|
|
|
281 |
vector<string> vpath;
|
|
|
282 |
stringToTokens(dit->dir, vpath, "/");
|
|
|
283 |
vector<string> pvpath;
|
|
|
284 |
if (dit->dir[0] == '/')
|
|
|
285 |
pvpath.push_back(wrap_prefix(pathelt_prefix));
|
|
|
286 |
for (vector<string>::const_iterator pit = vpath.begin();
|
|
|
287 |
pit != vpath.end(); pit++){
|
|
|
288 |
pvpath.push_back(wrap_prefix(pathelt_prefix) + *pit);
|
|
|
289 |
}
|
|
|
290 |
Xapian::Query::op tdop;
|
|
|
291 |
if (dit->weight == 1.0) {
|
|
|
292 |
tdop = dit->exclude ?
|
|
|
293 |
Xapian::Query::OP_AND_NOT : Xapian::Query::OP_FILTER;
|
|
|
294 |
} else {
|
|
|
295 |
tdop = dit->exclude ?
|
|
|
296 |
Xapian::Query::OP_AND_NOT : Xapian::Query::OP_AND_MAYBE;
|
|
|
297 |
}
|
|
|
298 |
Xapian::Query tdq = Xapian::Query(Xapian::Query::OP_PHRASE,
|
|
|
299 |
pvpath.begin(), pvpath.end());
|
|
|
300 |
if (dit->weight != 1.0)
|
|
|
301 |
tdq = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT,
|
|
|
302 |
tdq, dit->weight);
|
|
|
303 |
|
|
|
304 |
xq = Xapian::Query(tdop, xq, tdq);
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
*((Xapian::Query *)d) = xq;
|
277 |
*((Xapian::Query *)d) = xq;
|
308 |
return true;
|
278 |
return true;
|
309 |
}
|
279 |
}
|
310 |
|
280 |
|
311 |
// This is called by the GUI simple search if the option is set: add
|
281 |
// This is called by the GUI simple search if the option is set: add
|
|
... |
|
... |
416 |
}
|
386 |
}
|
417 |
|
387 |
|
418 |
// Add clause to current list. OR lists cant have EXCL clauses.
|
388 |
// Add clause to current list. OR lists cant have EXCL clauses.
|
419 |
bool SearchData::addClause(SearchDataClause* cl)
|
389 |
bool SearchData::addClause(SearchDataClause* cl)
|
420 |
{
|
390 |
{
|
421 |
if (m_tp == SCLT_OR && (cl->m_tp == SCLT_EXCL)) {
|
391 |
if (m_tp == SCLT_OR && (cl->m_tp == SCLT_EXCL || cl->getexclude())) {
|
422 |
LOGERR(("SearchData::addClause: cant add EXCL to OR list\n"));
|
392 |
LOGERR(("SearchData::addClause: cant add EXCL to OR list\n"));
|
423 |
m_reason = "No Negative (AND_NOT) clauses allowed in OR queries";
|
393 |
m_reason = "No Negative (AND_NOT) clauses allowed in OR queries";
|
424 |
return false;
|
394 |
return false;
|
425 |
}
|
395 |
}
|
426 |
cl->setParent(this);
|
396 |
cl->setParent(this);
|
|
... |
|
... |
436 |
m_tp = SCLT_AND;
|
406 |
m_tp = SCLT_AND;
|
437 |
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++)
|
407 |
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++)
|
438 |
delete *it;
|
408 |
delete *it;
|
439 |
m_query.clear();
|
409 |
m_query.clear();
|
440 |
m_filetypes.clear();
|
410 |
m_filetypes.clear();
|
441 |
m_dirspecs.clear();
|
|
|
442 |
m_description.erase();
|
411 |
m_description.erase();
|
443 |
m_reason.erase();
|
412 |
m_reason.erase();
|
444 |
m_haveDates = false;
|
413 |
m_haveDates = false;
|
445 |
m_minSize = size_t(-1);
|
414 |
m_minSize = size_t(-1);
|
446 |
m_maxSize = size_t(-1);
|
415 |
m_maxSize = size_t(-1);
|
|
... |
|
... |
1167 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
1136 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
1168 |
}
|
1137 |
}
|
1169 |
return true;
|
1138 |
return true;
|
1170 |
}
|
1139 |
}
|
1171 |
|
1140 |
|
|
|
1141 |
// Translate a dir: path filtering clause. See comments in .h
|
|
|
1142 |
bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
|
|
|
1143 |
{
|
|
|
1144 |
LOGDEB(("SearchDataClausePath::toNativeQuery: [%s]\n", m_text.c_str()));
|
|
|
1145 |
Xapian::Query *qp = (Xapian::Query *)p;
|
|
|
1146 |
*qp = Xapian::Query();
|
|
|
1147 |
|
|
|
1148 |
if (m_text.empty()) {
|
|
|
1149 |
LOGERR(("SearchDataClausePath: empty path??\n"));
|
|
|
1150 |
return false;
|
|
|
1151 |
}
|
|
|
1152 |
vector<string> vpath;
|
|
|
1153 |
stringToTokens(m_text, vpath, "/");
|
|
|
1154 |
vector<string> pvpath;
|
|
|
1155 |
if (m_text[0] == '/')
|
|
|
1156 |
pvpath.push_back(wrap_prefix(pathelt_prefix));
|
|
|
1157 |
for (vector<string>::const_iterator pit = vpath.begin();
|
|
|
1158 |
pit != vpath.end(); pit++){
|
|
|
1159 |
pvpath.push_back(wrap_prefix(pathelt_prefix) + *pit);
|
|
|
1160 |
}
|
|
|
1161 |
*qp = Xapian::Query(Xapian::Query::OP_PHRASE,
|
|
|
1162 |
pvpath.begin(), pvpath.end());
|
|
|
1163 |
|
|
|
1164 |
if (m_weight != 1.0) {
|
|
|
1165 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
|
|
1166 |
}
|
|
|
1167 |
return true;
|
|
|
1168 |
}
|
|
|
1169 |
|
1172 |
// Translate NEAR or PHRASE clause.
|
1170 |
// Translate NEAR or PHRASE clause.
|
1173 |
bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
|
1171 |
bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
|
1174 |
{
|
1172 |
{
|
1175 |
LOGDEB(("SearchDataClauseDist::toNativeQuery\n"));
|
1173 |
LOGDEB(("SearchDataClauseDist::toNativeQuery\n"));
|
1176 |
|
1174 |
|