Add new kind of aliases for field names, to be used only at query time
This commit is contained in:
+3
-2
@@ -1033,9 +1033,10 @@ bool Db::isopen()
|
||||
}
|
||||
|
||||
// Try to translate field specification into field prefix.
|
||||
bool Db::fieldToTraits(const string& fld, const FieldTraits **ftpp)
|
||||
bool Db::fieldToTraits(const string& fld, const FieldTraits **ftpp,
|
||||
bool isquery)
|
||||
{
|
||||
if (m_config && m_config->getFieldTraits(fld, ftpp))
|
||||
if (m_config && m_config->getFieldTraits(fld, ftpp, isquery))
|
||||
return true;
|
||||
|
||||
*ftpp = 0;
|
||||
|
||||
+2
-1
@@ -223,7 +223,8 @@ class Db {
|
||||
/* Return configured stop words */
|
||||
const StopList& getStopList() const {return m_stops;}
|
||||
/* Field name to prefix translation (ie: author -> 'A') */
|
||||
bool fieldToTraits(const string& fldname, const FieldTraits **ftpp);
|
||||
bool fieldToTraits(const string& fldname, const FieldTraits **ftpp,
|
||||
bool isquery = false);
|
||||
|
||||
/* Update-related methods ******************************************/
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ void Query::setSortBy(const string& fld, bool ascending) {
|
||||
if (fld.empty()) {
|
||||
m_sortField.erase();
|
||||
} else {
|
||||
m_sortField = m_db->getConf()->fieldCanon(fld);
|
||||
m_sortField = m_db->getConf()->fieldQCanon(fld);
|
||||
m_sortAscending = ascending;
|
||||
}
|
||||
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
|
||||
|
||||
@@ -328,7 +328,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
|
||||
string prefix;
|
||||
if (!field.empty()) {
|
||||
const FieldTraits *ftp = 0;
|
||||
if (!fieldToTraits(field, &ftp) || ftp->pfx.empty()) {
|
||||
if (!fieldToTraits(field, &ftp, true) || ftp->pfx.empty()) {
|
||||
LOGDEB(("Db::termMatch: field is not indexed (no prefix): [%s]\n",
|
||||
field.c_str()));
|
||||
} else {
|
||||
|
||||
@@ -686,7 +686,7 @@ void SearchDataClauseSimple::processSimpleSpan(Rcl::Db &db, string& ermsg,
|
||||
|
||||
string prefix;
|
||||
const FieldTraits *ftp;
|
||||
if (!m_field.empty() && db.fieldToTraits(m_field, &ftp)) {
|
||||
if (!m_field.empty() && db.fieldToTraits(m_field, &ftp, true)) {
|
||||
prefix = wrap_prefix(ftp->pfx);
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
|
||||
|
||||
string prefix;
|
||||
const FieldTraits *ftp;
|
||||
if (!m_field.empty() && db.fieldToTraits(m_field, &ftp)) {
|
||||
if (!m_field.empty() && db.fieldToTraits(m_field, &ftp, true)) {
|
||||
prefix = wrap_prefix(ftp->pfx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user