|
a/src/rcldb/searchdata.cpp |
|
b/src/rcldb/searchdata.cpp |
|
... |
|
... |
58 |
{
|
58 |
{
|
59 |
m_haveDates = false;
|
59 |
m_haveDates = false;
|
60 |
m_maxSize = size_t(-1);
|
60 |
m_maxSize = size_t(-1);
|
61 |
m_minSize = size_t(-1);
|
61 |
m_minSize = size_t(-1);
|
62 |
m_haveWildCards = false;
|
62 |
m_haveWildCards = false;
|
63 |
m_softmaxexpand = -1;
|
|
|
64 |
m_autodiacsens = false;
|
63 |
m_autodiacsens = false;
|
65 |
m_autocasesens = true;
|
64 |
m_autocasesens = true;
|
66 |
m_maxexp = 10000;
|
65 |
m_maxexp = 10000;
|
67 |
m_maxcl = 100000;
|
66 |
m_maxcl = 100000;
|
|
|
67 |
m_softmaxexpand = -1;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
SearchData::~SearchData()
|
|
|
71 |
{
|
|
|
72 |
LOGDEB0(("SearchData::~SearchData\n"));
|
|
|
73 |
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++)
|
|
|
74 |
delete *it;
|
68 |
}
|
75 |
}
|
69 |
|
76 |
|
70 |
// Expand categories and mime type wild card exps Categories are
|
77 |
// Expand categories and mime type wild card exps Categories are
|
71 |
// expanded against the configuration, mimetypes against the index
|
78 |
// expanded against the configuration, mimetypes against the index
|
72 |
// (for wildcards).
|
79 |
// (for wildcards).
|
|
... |
|
... |
257 |
} else {
|
264 |
} else {
|
258 |
xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, sq);
|
265 |
xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, sq);
|
259 |
}
|
266 |
}
|
260 |
}
|
267 |
}
|
261 |
|
268 |
|
|
|
269 |
// Add the autophrase if any
|
|
|
270 |
if (m_autophrase.isNotNull()) {
|
|
|
271 |
Xapian::Query apq;
|
|
|
272 |
if (m_autophrase->toNativeQuery(db, &apq)) {
|
|
|
273 |
xq = xq.empty() ? apq :
|
|
|
274 |
Xapian::Query(Xapian::Query::OP_AND_MAYBE, xq, apq);
|
|
|
275 |
}
|
|
|
276 |
}
|
|
|
277 |
|
262 |
// Add the file type filtering clause if any
|
278 |
// Add the file type filtering clause if any
|
263 |
if (!m_filetypes.empty()) {
|
279 |
if (!m_filetypes.empty()) {
|
264 |
expandFileTypes(db, m_filetypes);
|
280 |
expandFileTypes(db, m_filetypes);
|
265 |
|
281 |
|
266 |
Xapian::Query tq;
|
282 |
Xapian::Query tq;
|
|
... |
|
... |
374 |
|
390 |
|
375 |
// Increase the slack: we want to be a little more laxist than for
|
391 |
// Increase the slack: we want to be a little more laxist than for
|
376 |
// an actual user-entered phrase
|
392 |
// an actual user-entered phrase
|
377 |
slack += 1 + nwords / 3;
|
393 |
slack += 1 + nwords / 3;
|
378 |
|
394 |
|
379 |
SearchDataClauseDist *nclp =
|
395 |
m_autophrase = RefCntr<SearchDataClauseDist>(
|
380 |
new SearchDataClauseDist(SCLT_PHRASE, swords, slack, field);
|
396 |
new SearchDataClauseDist(SCLT_PHRASE, swords, slack, field));
|
381 |
|
|
|
382 |
// If the toplevel conjunction is an OR, just OR the phrase, else
|
|
|
383 |
// deepen the tree.
|
|
|
384 |
if (m_tp == SCLT_OR) {
|
|
|
385 |
addClause(nclp);
|
|
|
386 |
} else {
|
|
|
387 |
// My type is AND. Change it to OR and insert two queries, one
|
|
|
388 |
// being the original query as a subquery, the other the
|
|
|
389 |
// phrase.
|
|
|
390 |
SearchData *sd = new SearchData(m_tp, m_stemlang);
|
|
|
391 |
sd->m_query = m_query;
|
|
|
392 |
sd->m_stemlang = m_stemlang;
|
|
|
393 |
m_tp = SCLT_OR;
|
|
|
394 |
m_query.clear();
|
|
|
395 |
SearchDataClauseSub *oq =
|
|
|
396 |
new SearchDataClauseSub(SCLT_OR, RefCntr<SearchData>(sd));
|
|
|
397 |
addClause(oq);
|
|
|
398 |
addClause(nclp);
|
|
|
399 |
}
|
|
|
400 |
return true;
|
397 |
return true;
|
401 |
}
|
398 |
}
|
402 |
|
399 |
|
403 |
// Add clause to current list. OR lists cant have EXCL clauses.
|
400 |
// Add clause to current list. OR lists cant have EXCL clauses.
|
404 |
bool SearchData::addClause(SearchDataClause* cl)
|
401 |
bool SearchData::addClause(SearchDataClause* cl)
|
|
... |
|
... |
410 |
}
|
407 |
}
|
411 |
cl->setParent(this);
|
408 |
cl->setParent(this);
|
412 |
m_haveWildCards = m_haveWildCards || cl->m_haveWildCards;
|
409 |
m_haveWildCards = m_haveWildCards || cl->m_haveWildCards;
|
413 |
m_query.push_back(cl);
|
410 |
m_query.push_back(cl);
|
414 |
return true;
|
411 |
return true;
|
415 |
}
|
|
|
416 |
|
|
|
417 |
// Make me all new
|
|
|
418 |
void SearchData::erase()
|
|
|
419 |
{
|
|
|
420 |
LOGDEB0(("SearchData::erase\n"));
|
|
|
421 |
m_tp = SCLT_AND;
|
|
|
422 |
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++)
|
|
|
423 |
delete *it;
|
|
|
424 |
m_query.clear();
|
|
|
425 |
m_filetypes.clear();
|
|
|
426 |
m_description.erase();
|
|
|
427 |
m_reason.erase();
|
|
|
428 |
m_haveDates = false;
|
|
|
429 |
m_minSize = size_t(-1);
|
|
|
430 |
m_maxSize = size_t(-1);
|
|
|
431 |
}
|
412 |
}
|
432 |
|
413 |
|
433 |
// Am I a file name only search ? This is to turn off term highlighting
|
414 |
// Am I a file name only search ? This is to turn off term highlighting
|
434 |
bool SearchData::fileNameOnly()
|
415 |
bool SearchData::fileNameOnly()
|
435 |
{
|
416 |
{
|