0

我们在我们的一个网站上使用 indexed_search 作为搜索解决方案。最近,我在.pdf维护的网站上遇到了索引搜索和文档的问题。

索引搜索将对文档进行索引,但只会将它们“链接”到默认语言。因此,如果您选择不同的语言浏览网站,这些文档将永远不会出现在任何搜索结果中。

有可能解决这个问题吗?如果是这样,怎么做?

4

1 回答 1

0

当使用索引搜索来索引您网站上的文档(如.pdf文件)时,只有在用户选择了默认语言时才能找到它们。要使索引搜索在找到文件的页面的语言下正确索引这些文件,您必须调整class.indexer.php.

在方法submitFilePage()中,找到数组$fields并将其添加sys_language_id到其中,如下所示:

$fields = array(
    'phash' => $hash['phash'],
    'phash_grouping' => $hash['phash_grouping'],
    'cHashParams' => serialize($subinfo),
    'contentHash' => $content_md5h,
    'data_filename' => $file,
    'item_type' => $storeItemType,
    'item_title' => trim($contentParts['title']) ? $contentParts['title'] : basename($file),
    'item_description' => $this->bodyDescription($contentParts),
    'item_mtime' => $mtime,
    'item_size' => $size,
    'item_crdate' => $ctime,
    'tstamp' => $GLOBALS['EXEC_TIME'],
    'crdate' => $GLOBALS['EXEC_TIME'],
    'gr_list' => $this->conf['gr_list'],
    'externalUrl' => $fileParts['scheme'] ? 1 : 0,
    'recordUid' => intval($this->conf['recordUid']),
    'freeIndexUid' => intval($this->conf['freeIndexUid']),
    'freeIndexSetId' => intval($this->conf['freeIndexSetId']),
    'sys_language_uid' => $this->conf['sys_language_uid']
);

在方法setExtHashes()中,找到数组$hArray并将其添加sys_lang到其中,如下所示:

$hArray = array(
    'file' => $file,
    'sys_lang' => (integer)$this->conf['sys_language_uid']
);

警告

此方法仅在您不使用爬虫调用外部文件索引时才有效。这由useCrawlerForExternalFiles索引搜索的设置控制。

禁用此设置!您还应该启用disableFrontendIndexing,否则这可能会导致页面加载时间过长(因为页面上的链接文档可能会在用户请求页面时被索引)。

于 2013-01-17T19:17:46.987 回答