let rclconfig take care of field name lowercasing
This commit is contained in:
parent
0a04919f5a
commit
b932263533
5556
src/ChangeLog
5556
src/ChangeLog
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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")
|
// 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);
|
map<string,string>::const_iterator pit = m_fldtopfx.find(fld);
|
||||||
if (pit != m_fldtopfx.end()) {
|
if (pit != m_fldtopfx.end()) {
|
||||||
pfx = pit->second;
|
pfx = pit->second;
|
||||||
|
LOGDEB1(("RclConfig::getFieldPrefix: [%s]->[%s]\n",
|
||||||
|
_fld.c_str(), pfx.c_str()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LOGDEB1(("RclConfig::readFieldsConfig: no prefix for field [%s]\n",
|
LOGDEB1(("RclConfig::readFieldsConfig: no prefix for field [%s]\n",
|
||||||
@ -570,11 +572,16 @@ bool RclConfig::getFieldSpecialisationPrefixes(const string& fld,
|
|||||||
return true;
|
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);
|
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;
|
return it->second;
|
||||||
|
}
|
||||||
|
LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", f.c_str(), fld.c_str()));
|
||||||
return fld;
|
return fld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#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()));
|
LOGDEB(("meta[%s] -> [%s]\n", it->first.c_str(), it->second.c_str()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
string key = rclconfig->fieldCanon(stringtolower(string(name)));
|
string key = rclconfig->fieldCanon(string(name));
|
||||||
|
|
||||||
// Handle special cases, then try retrieving key value from meta
|
// Handle special cases, then try retrieving key value from meta
|
||||||
// array
|
// array
|
||||||
@ -391,7 +391,7 @@ Doc_setattr(recoll_DocObject *self, char *name, PyObject *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* uvalue = PyString_AsString(putf8);
|
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));
|
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
|
// We set the value in the meta array in all cases. Good idea ? or do it
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
// reason (old config not updated ?). We use it only if the config
|
||||||
// translation fails. Also we add in there fields which should be
|
// translation fails. Also we add in there fields which should be
|
||||||
// indexed with no prefix (ie: abstract)
|
// 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
|
// This is the default table. We prefer the data from rclconfig if
|
||||||
// available
|
// available
|
||||||
@ -733,9 +733,6 @@ bool Db::fieldToPrefix(const string& fldname, string &pfx)
|
|||||||
fldToPrefs["tags"] = "K";
|
fldToPrefs["tags"] = "K";
|
||||||
}
|
}
|
||||||
|
|
||||||
string fld(fldname);
|
|
||||||
stringtolower(fld);
|
|
||||||
|
|
||||||
RclConfig *config = RclConfig::getMainConfig();
|
RclConfig *config = RclConfig::getMainConfig();
|
||||||
if (config && config->getFieldPrefix(fld, pfx))
|
if (config && config->getFieldPrefix(fld, pfx))
|
||||||
return true;
|
return true;
|
||||||
@ -1051,7 +1048,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi,
|
|||||||
const set<string>& stored = config->getStoredFields();
|
const set<string>& stored = config->getStoredFields();
|
||||||
for (set<string>::const_iterator it = stored.begin();
|
for (set<string>::const_iterator it = stored.begin();
|
||||||
it != stored.end(); it++) {
|
it != stored.end(); it++) {
|
||||||
string nm = stringtolower(config->fieldCanon(*it));
|
string nm = config->fieldCanon(*it);
|
||||||
if (!doc.meta[*it].empty()) {
|
if (!doc.meta[*it].empty()) {
|
||||||
string value =
|
string value =
|
||||||
neutchars(truncate_to_word(doc.meta[*it], 150), nc);
|
neutchars(truncate_to_word(doc.meta[*it], 150), nc);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -114,7 +114,7 @@ Db *Query::whatDb()
|
|||||||
|
|
||||||
void Query::setSortBy(const string& fld, bool ascending) {
|
void Query::setSortBy(const string& fld, bool ascending) {
|
||||||
RclConfig *cfg = RclConfig::getMainConfig();
|
RclConfig *cfg = RclConfig::getMainConfig();
|
||||||
m_sortField = cfg->fieldCanon(stringtolower(fld));
|
m_sortField = cfg->fieldCanon(fld);
|
||||||
m_sortAscending = ascending;
|
m_sortAscending = ascending;
|
||||||
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
|
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
|
||||||
m_sortAscending ? "ascending" : "descending"));
|
m_sortAscending ? "ascending" : "descending"));
|
||||||
|
|||||||
@ -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
|
# Field names configuration. This defines how one may search ie for
|
||||||
# author:Hemingway
|
# author:Hemingway
|
||||||
# Important:
|
# Important:
|
||||||
@ -34,7 +34,7 @@ recipient = XTO
|
|||||||
# to be listed here)
|
# to be listed here)
|
||||||
#
|
#
|
||||||
# Some fields are stored by default, don't add them here, else they will be
|
# 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
|
# "author" used to be stored by default, now set here as optional
|
||||||
# Only canonical names should be used here, not aliases.
|
# Only canonical names should be used here, not aliases.
|
||||||
[stored]
|
[stored]
|
||||||
@ -54,7 +54,7 @@ stored = author
|
|||||||
[aliases]
|
[aliases]
|
||||||
abstract = summary dc:summary description xesam:description
|
abstract = summary dc:summary description xesam:description
|
||||||
author = creator dc:creator xesam:author xesam:creator
|
author = creator dc:creator xesam:author xesam:creator
|
||||||
title = title dc:title subject
|
caption = title title dc:title subject
|
||||||
# catg = dc:type contentCategory
|
# catg = dc:type contentCategory
|
||||||
dbytes = size xesam:size
|
dbytes = size xesam:size
|
||||||
dmtime = date dc:date dc:datemodified datemodified contentmodified \
|
dmtime = date dc:date dc:datemodified datemodified contentmodified \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user