|
a/src/rcldb/searchdata.cpp |
|
b/src/rcldb/searchdata.cpp |
|
... |
|
... |
276 |
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
|
276 |
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
|
277 |
}
|
277 |
}
|
278 |
xq = xq.empty() ? tq : Xapian::Query(Xapian::Query::OP_AND_NOT, xq, tq);
|
278 |
xq = xq.empty() ? tq : Xapian::Query(Xapian::Query::OP_AND_NOT, xq, tq);
|
279 |
}
|
279 |
}
|
280 |
|
280 |
|
281 |
// Add the directory filtering clause
|
281 |
// Add the directory filtering clause. This is a phrase of terms
|
|
|
282 |
// prefixed with the pathelt prefix XP
|
282 |
if (!m_topdir.empty()) {
|
283 |
if (!m_topdir.empty()) {
|
283 |
vector<string> vpath;
|
284 |
vector<string> vpath;
|
284 |
stringToTokens(m_topdir, vpath, "/");
|
285 |
stringToTokens(m_topdir, vpath, "/");
|
285 |
vector<string> pvpath;
|
286 |
vector<string> pvpath;
|
286 |
pvpath.push_back(pathelt_prefix);
|
287 |
pvpath.push_back(pathelt_prefix);
|
287 |
for (vector<string>::const_iterator it = vpath.begin();
|
288 |
for (vector<string>::const_iterator it = vpath.begin();
|
288 |
it != vpath.end(); it++){
|
289 |
it != vpath.end(); it++){
|
289 |
pvpath.push_back(pathelt_prefix + *it);
|
290 |
pvpath.push_back(pathelt_prefix + *it);
|
290 |
}
|
291 |
}
|
291 |
xq = Xapian::Query(m_topdirexcl ?
|
292 |
Xapian::Query::op tdop;
|
|
|
293 |
if (m_topdirweight == 1.0) {
|
|
|
294 |
tdop = m_topdirexcl ?
|
292 |
Xapian::Query::OP_AND_NOT:Xapian::Query::OP_FILTER,
|
295 |
Xapian::Query::OP_AND_NOT : Xapian::Query::OP_FILTER;
|
|
|
296 |
} else {
|
|
|
297 |
tdop = m_topdirexcl ?
|
|
|
298 |
Xapian::Query::OP_AND_NOT : Xapian::Query::OP_AND_MAYBE;
|
|
|
299 |
}
|
293 |
xq, Xapian::Query(Xapian::Query::OP_PHRASE,
|
300 |
Xapian::Query tdq = Xapian::Query(Xapian::Query::OP_PHRASE,
|
294 |
pvpath.begin(), pvpath.end()));
|
301 |
pvpath.begin(), pvpath.end());
|
|
|
302 |
if (m_topdirweight != 1.0)
|
|
|
303 |
tdq = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT,
|
|
|
304 |
tdq, m_topdirweight);
|
|
|
305 |
|
|
|
306 |
xq = Xapian::Query(tdop, xq, tdq);
|
295 |
}
|
307 |
}
|
296 |
|
308 |
|
297 |
*((Xapian::Query *)d) = xq;
|
309 |
*((Xapian::Query *)d) = xq;
|
298 |
return true;
|
310 |
return true;
|
299 |
}
|
311 |
}
|
|
... |
|
... |
845 |
bool doBoostUserTerm =
|
857 |
bool doBoostUserTerm =
|
846 |
(m_parentSearch && !m_parentSearch->haveWildCards()) ||
|
858 |
(m_parentSearch && !m_parentSearch->haveWildCards()) ||
|
847 |
(m_parentSearch == 0 && !m_haveWildCards);
|
859 |
(m_parentSearch == 0 && !m_haveWildCards);
|
848 |
|
860 |
|
849 |
StringToXapianQ tr(db, m_field, l_stemlang, doBoostUserTerm);
|
861 |
StringToXapianQ tr(db, m_field, l_stemlang, doBoostUserTerm);
|
850 |
if (!tr.processUserString(m_text, m_reason, pqueries,
|
862 |
if (!tr.processUserString(m_text, m_reason, pqueries, db.getStopList()))
|
851 |
db.getStopList()))
|
|
|
852 |
return false;
|
863 |
return false;
|
853 |
if (pqueries.empty()) {
|
864 |
if (pqueries.empty()) {
|
854 |
LOGERR(("SearchDataClauseSimple: resolved to null query\n"));
|
865 |
LOGERR(("SearchDataClauseSimple: resolved to null query\n"));
|
855 |
return true;
|
866 |
return true;
|
856 |
}
|
867 |
}
|
857 |
tr.getTerms(m_terms, m_groups);
|
868 |
tr.getTerms(m_terms, m_groups);
|
858 |
tr.getUTerms(m_uterms);
|
869 |
tr.getUTerms(m_uterms);
|
859 |
//listVector("SearchDataClauseSimple: Uterms: ", m_uterms);
|
870 |
//listVector("SearchDataClauseSimple: Uterms: ", m_uterms);
|
860 |
*qp = Xapian::Query(op, pqueries.begin(), pqueries.end());
|
871 |
*qp = Xapian::Query(op, pqueries.begin(), pqueries.end());
|
|
|
872 |
if (m_weight != 1.0) {
|
|
|
873 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
|
|
874 |
}
|
861 |
return true;
|
875 |
return true;
|
862 |
}
|
876 |
}
|
863 |
|
877 |
|
864 |
// Translate a FILENAME search clause. This mostly (or always) comes
|
878 |
// Translate a FILENAME search clause. This mostly (or always) comes
|
865 |
// from a "filename" search from the gui or recollq. A query language
|
879 |
// from a "filename" search from the gui or recollq. A query language
|
|
... |
|
... |
885 |
db.filenameWildExp(*it, more);
|
899 |
db.filenameWildExp(*it, more);
|
886 |
Xapian::Query tq = Xapian::Query(Xapian::Query::OP_OR, more.begin(),
|
900 |
Xapian::Query tq = Xapian::Query(Xapian::Query::OP_OR, more.begin(),
|
887 |
more.end());
|
901 |
more.end());
|
888 |
*qp = qp->empty() ? tq : Xapian::Query(Xapian::Query::OP_AND, *qp, tq);
|
902 |
*qp = qp->empty() ? tq : Xapian::Query(Xapian::Query::OP_AND, *qp, tq);
|
889 |
}
|
903 |
}
|
|
|
904 |
if (m_weight != 1.0) {
|
|
|
905 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
|
|
906 |
}
|
890 |
return true;
|
907 |
return true;
|
891 |
}
|
908 |
}
|
892 |
|
909 |
|
893 |
// Translate NEAR or PHRASE clause.
|
910 |
// Translate NEAR or PHRASE clause.
|
894 |
bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p,
|
911 |
bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p,
|
|
... |
|
... |
930 |
return true;
|
947 |
return true;
|
931 |
}
|
948 |
}
|
932 |
tr.getTerms(m_terms, m_groups);
|
949 |
tr.getTerms(m_terms, m_groups);
|
933 |
tr.getUTerms(m_uterms);
|
950 |
tr.getUTerms(m_uterms);
|
934 |
*qp = *pqueries.begin();
|
951 |
*qp = *pqueries.begin();
|
|
|
952 |
if (m_weight != 1.0) {
|
|
|
953 |
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);
|
|
|
954 |
}
|
935 |
return true;
|
955 |
return true;
|
936 |
}
|
956 |
}
|
937 |
|
957 |
|
938 |
// Translate subquery
|
958 |
// Translate subquery
|
939 |
bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p, const string&)
|
959 |
bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p, const string&)
|