let rclconfig take care of field name lowercasing

This commit is contained in:
dockes 2008-10-07 06:44:23 +00:00
parent 0a04919f5a
commit b932263533
6 changed files with 2391 additions and 3207 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.60 2008-10-03 08:19:19 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.61 2008-10-07 06:44:23 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -517,12 +517,14 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
}
// Return term indexing prefix for field name (ie: "filename" -> "XSFN")
// The input must be a canonical field name (alias translation done already)
bool RclConfig::getFieldPrefix(const string& fld, string &pfx)
bool RclConfig::getFieldPrefix(const string& _fld, string &pfx)
{
string fld = fieldCanon(_fld);
map<string,string>::const_iterator pit = m_fldtopfx.find(fld);
if (pit != m_fldtopfx.end()) {
pfx = pit->second;
LOGDEB1(("RclConfig::getFieldPrefix: [%s]->[%s]\n",
_fld.c_str(), pfx.c_str()));
return true;
} else {
LOGDEB1(("RclConfig::readFieldsConfig: no prefix for field [%s]\n",
@ -570,11 +572,16 @@ bool RclConfig::getFieldSpecialisationPrefixes(const string& fld,
return true;
}
string RclConfig::fieldCanon(const string& fld)
string RclConfig::fieldCanon(const string& f)
{
string fld = stringtolower(f);
map<string, string>::const_iterator it = m_aliastocanon.find(fld);
if (it != m_aliastocanon.end())
if (it != m_aliastocanon.end()) {
LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n",
f.c_str(), it->second.c_str()));
return it->second;
}
LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", f.c_str(), fld.c_str()));
return fld;
}

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.16 2008-09-29 11:33:55 dockes Exp $ (C) 2007 J.F.Dockes";
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.17 2008-10-07 06:44:23 dockes Exp $ (C) 2007 J.F.Dockes";
#endif
@ -291,7 +291,7 @@ Doc_getattr(recoll_DocObject *self, char *name)
LOGDEB(("meta[%s] -> [%s]\n", it->first.c_str(), it->second.c_str()));
}
#endif
string key = rclconfig->fieldCanon(stringtolower(string(name)));
string key = rclconfig->fieldCanon(string(name));
// Handle special cases, then try retrieving key value from meta
// array
@ -391,7 +391,7 @@ Doc_setattr(recoll_DocObject *self, char *name, PyObject *value)
}
char* uvalue = PyString_AsString(putf8);
string key = rclconfig->fieldCanon(stringtolower(string(name)));
string key = rclconfig->fieldCanon(string(name));
LOGDEB0(("Doc_setattr: [%s] (%s) -> [%s]\n", key.c_str(), name, uvalue));
// We set the value in the meta array in all cases. Good idea ? or do it

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.147 2008-09-30 12:38:29 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.148 2008-10-07 06:44:23 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -709,7 +709,7 @@ bool Db::isopen()
// reason (old config not updated ?). We use it only if the config
// translation fails. Also we add in there fields which should be
// indexed with no prefix (ie: abstract)
bool Db::fieldToPrefix(const string& fldname, string &pfx)
bool Db::fieldToPrefix(const string& fld, string &pfx)
{
// This is the default table. We prefer the data from rclconfig if
// available
@ -733,9 +733,6 @@ bool Db::fieldToPrefix(const string& fldname, string &pfx)
fldToPrefs["tags"] = "K";
}
string fld(fldname);
stringtolower(fld);
RclConfig *config = RclConfig::getMainConfig();
if (config && config->getFieldPrefix(fld, pfx))
return true;
@ -1051,7 +1048,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi,
const set<string>& stored = config->getStoredFields();
for (set<string>::const_iterator it = stored.begin();
it != stored.end(); it++) {
string nm = stringtolower(config->fieldCanon(*it));
string nm = config->fieldCanon(*it);
if (!doc.meta[*it].empty()) {
string value =
neutchars(truncate_to_word(doc.meta[*it], 150), nc);

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.9 2008-09-29 11:33:55 dockes Exp $ (C) 2008 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.10 2008-10-07 06:44:23 dockes Exp $ (C) 2008 J.F.Dockes";
#endif
#include <stdlib.h>
@ -114,7 +114,7 @@ Db *Query::whatDb()
void Query::setSortBy(const string& fld, bool ascending) {
RclConfig *cfg = RclConfig::getMainConfig();
m_sortField = cfg->fieldCanon(stringtolower(fld));
m_sortField = cfg->fieldCanon(fld);
m_sortAscending = ascending;
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
m_sortAscending ? "ascending" : "descending"));

View File

@ -1,4 +1,4 @@
# @(#$Id: fields,v 1.3 2008-09-16 08:18:30 dockes Exp $ (C) 2007 J.F.Dockes
# @(#$Id: fields,v 1.4 2008-10-07 06:44:23 dockes Exp $ (C) 2007 J.F.Dockes
# Field names configuration. This defines how one may search ie for
# author:Hemingway
# Important:
@ -34,7 +34,7 @@ recipient = XTO
# to be listed here)
#
# Some fields are stored by default, don't add them here, else they will be
# stored twice: title, keywords, abstract, filename, mimetype, url
# stored twice: caption, keywords, abstract, filename, mimetype, url
# "author" used to be stored by default, now set here as optional
# Only canonical names should be used here, not aliases.
[stored]
@ -54,7 +54,7 @@ stored = author
[aliases]
abstract = summary dc:summary description xesam:description
author = creator dc:creator xesam:author xesam:creator
title = title dc:title subject
caption = title title dc:title subject
# catg = dc:type contentCategory
dbytes = size xesam:size
dmtime = date dc:date dc:datemodified datemodified contentmodified \