Add new kind of aliases for field names, to be used only at query time
This commit is contained in:
@@ -879,6 +879,21 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||
}
|
||||
}
|
||||
|
||||
// Query aliases map
|
||||
tps = m_fields->getNames("queryaliases");
|
||||
for (vector<string>::const_iterator it = tps.begin();
|
||||
it != tps.end(); it++){
|
||||
string canonic = stringtolower(*it); // canonic name
|
||||
string aliases;
|
||||
m_fields->get(canonic, aliases, "queryaliases");
|
||||
vector<string> l;
|
||||
stringToStrings(aliases, l);
|
||||
for (vector<string>::const_iterator ait = l.begin();
|
||||
ait != l.end(); ait++) {
|
||||
m_aliastoqcanon[stringtolower(*ait)] = canonic;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (map<string, FieldTraits>::const_iterator it = m_fldtotraits.begin();
|
||||
it != m_fldtotraits.end(); it++) {
|
||||
@@ -910,10 +925,10 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
|
||||
}
|
||||
|
||||
// Return specifics for field name:
|
||||
bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp)
|
||||
const
|
||||
bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp,
|
||||
bool isquery) const
|
||||
{
|
||||
string fld = fieldCanon(_fld);
|
||||
string fld = isquery ? fieldQCanon(_fld) : fieldCanon(_fld);
|
||||
map<string, FieldTraits>::const_iterator pit = m_fldtotraits.find(fld);
|
||||
if (pit != m_fldtotraits.end()) {
|
||||
*ftpp = &pit->second;
|
||||
@@ -952,6 +967,18 @@ string RclConfig::fieldCanon(const string& f) const
|
||||
return fld;
|
||||
}
|
||||
|
||||
string RclConfig::fieldQCanon(const string& f) const
|
||||
{
|
||||
string fld = stringtolower(f);
|
||||
map<string, string>::const_iterator it = m_aliastoqcanon.find(fld);
|
||||
if (it != m_aliastoqcanon.end()) {
|
||||
LOGDEB1(("RclConfig::fieldQCanon: [%s] -> [%s]\n",
|
||||
f.c_str(), it->second.c_str()));
|
||||
return it->second;
|
||||
}
|
||||
return fieldCanon(f);
|
||||
}
|
||||
|
||||
vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
|
||||
const
|
||||
{
|
||||
@@ -1423,6 +1450,7 @@ void RclConfig::initFrom(const RclConfig& r)
|
||||
m_ptrans = new ConfSimple(*(r.m_ptrans));
|
||||
m_fldtotraits = r.m_fldtotraits;
|
||||
m_aliastocanon = r.m_aliastocanon;
|
||||
m_aliastoqcanon = r.m_aliastoqcanon;
|
||||
m_storedFields = r.m_storedFields;
|
||||
m_xattrtofld = r.m_xattrtofld;
|
||||
if (r.m_stopsuffixes)
|
||||
|
||||
@@ -241,8 +241,10 @@ class RclConfig {
|
||||
/** mimeconf: get query lang frag for named filter */
|
||||
bool getGuiFilter(const string& filtername, string& frag) const;
|
||||
|
||||
/** fields: get field prefix from field name */
|
||||
bool getFieldTraits(const string& fldname, const FieldTraits **) const;
|
||||
/** fields: get field prefix from field name. Use additional query
|
||||
aliases if isquery is set */
|
||||
bool getFieldTraits(const string& fldname, const FieldTraits **,
|
||||
bool isquery = false) const;
|
||||
|
||||
const set<string>& getStoredFields() const {return m_storedFields;}
|
||||
|
||||
@@ -251,6 +253,9 @@ class RclConfig {
|
||||
/** Get canonic name for possible alias */
|
||||
string fieldCanon(const string& fld) const;
|
||||
|
||||
/** Get canonic name for possible alias, including query-only aliases */
|
||||
string fieldQCanon(const string& fld) const;
|
||||
|
||||
/** Get xattr name to field names translations */
|
||||
const map<string, string>& getXattrToField() const {return m_xattrtofld;}
|
||||
|
||||
@@ -323,6 +328,7 @@ class RclConfig {
|
||||
ConfSimple *m_ptrans; // Paths translations
|
||||
map<string, FieldTraits> m_fldtotraits; // Field to field params
|
||||
map<string, string> m_aliastocanon;
|
||||
map<string, string> m_aliastoqcanon;
|
||||
set<string> m_storedFields;
|
||||
map<string, string> m_xattrtofld;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user