try out modification to use container file name for display, but not search, purposes when the subdocument file name is not set

This commit is contained in:
Jean-Francois Dockes 2014-07-16 17:05:26 +02:00
parent 3d3f917f59
commit 088f1f9a9f
5 changed files with 37 additions and 5 deletions

View File

@ -1 +1 @@
1.20.0
1.20.0p1

View File

@ -724,9 +724,13 @@ FsIndexer::processonefile(RclConfig *config,
if (doc.url.empty())
doc.url = cstr_fileu + fn;
const string *fnp = 0;
if (doc.ipath.empty() &&
(!doc.peekmeta(Rcl::Doc::keyfn, &fnp) || fnp->empty()))
doc.meta[Rcl::Doc::keyfn] = utf8fn;
if (doc.ipath.empty()) {
if (!doc.peekmeta(Rcl::Doc::keyfn, &fnp) || fnp->empty())
doc.meta[Rcl::Doc::keyfn] = utf8fn;
} else {
// subdoc: set container file name
doc.meta[Rcl::Doc::keytcfn] = utf8fn;
}
char cbuf[100];
sprintf(cbuf, "%lld", (long long)stp->st_size);

View File

@ -1539,6 +1539,21 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
}
}
// At this point, if the document "filename" field was empty,
// try to store the "container file name" value. This is done
// after indexing because we don't want search matches on
// this, but the filename is often useful for display
// purposes.
const string *fnp = 0;
if (!doc.peekmeta(Rcl::Doc::keyfn, &fnp) || fnp->empty()) {
if (doc.peekmeta(Rcl::Doc::keytcfn, &fnp) && !fnp->empty()) {
string value =
neutchars(truncate_to_word(*fnp,
m_idxMetaStoredLen), cstr_nc);
RECORD_APPEND(record, Rcl::Doc::keyfn, value);
}
}
// If empty pages (multiple break at same pos) were recorded, save
// them (this is because we have no way to record them in the
// Xapian list

View File

@ -30,6 +30,7 @@ namespace Rcl {
const string Doc::keyds("dbytes");
const string Doc::keyfmt("fmtime");
const string Doc::keyfn("filename");
const string Doc::keytcfn("topcontainerfn");
const string Doc::keyfs("fbytes");
const string Doc::keyipt("ipath");
const string Doc::keykw("keywords");

View File

@ -246,7 +246,19 @@ class Doc {
// childurl. This is set when working with the parent of the result, to hold
// the child of interest url, typically to highlight a directory entry
static const string keychildurl;
static const string keyfn; // file name
// file name. This is set for filesystem-level containers or
// documents, and not inherited by subdocuments (which can get a
// keyfn anyway from, e.g, an attachment filename value). Subdocs
// used to inherit the file name, but this was undesirable (you
// usually don't want to see all subdocs when searching for the
// file name). Instead the container file name is now set in the
// document record but not indexed (see next entry).
static const string keyfn;
// Container file name. This is set for all subdocuments of a
// given top level container. It is not indexed by default but
// stored in the document record keyfn field if this is still
// empty when we create it, for display purposes.
static const string keytcfn;
static const string keyipt; // ipath
static const string keytp; // mime type
static const string keyfmt; // file mtime