使用跟踪器在文件 (PDF) 内容中启用搜索

使用跟踪器在文件 (PDF) 内容中启用搜索

据我所知,gnome 搜索,可能还有 nautilus 搜索,都是由 tracker 驱动或至少扩展的。我在 18.04 中安装了 tracker 来收集我在 Ubuntu 17.10 中使用的文件搜索功能的内容。然后我能够在 gnome-settings 中添加我的文件夹,它们确实正在被扫描。但它似乎只使用名称等元数据,而不是文件内容:

~> tracker daemon -w
Ressourcen-Aktualisierungen der Datenbank werden nun überwacht
Alle Eigenschafte »nie:plainTextContent« werden ausgelassen

Drücken Sie Strg+C zum Anhalten

第二行表示属性“nie:plainTextContent”被跳过。我想我想要的是启用这个,对吧?我尝试找到一种方法,但在网上搜索时只找到了过时的信息,我无法自己找到如何启用此属性。

问题是,索引时似乎只跳过 nie:plainTextContent。手动提取提供所需的属性:

~> tracker extract ~/watched_folder/file.pdf 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .

<file:///home/user/watched_folder/file.pdf> nfo:pageCount 51 ;
  nie:title "Lecture_File" ;
  a nfo:PaginatedTextDocument ;
  nie:plainTextContent "long text from the pdf" # this is what I want to search in!

问题

您知道如何为 Gnome 概览搜索和/或 nautilus 搜索启用文件内容搜索吗?nautilus 搜索和 gnome shell 搜索(在“活动”菜单中输入)都是由跟踪器驱动的吗?

答案1

看来这是 Nautilus 的一个错误。请参阅此问题及其答案:

https://gitlab.gnome.org/GNOME/nautilus/issues/624

我明白为什么这种情况不会发生在 nautilus 代码中。它的 shell 搜索提供程序确实隐式地诉诸“简单”模式,在该模式下仅匹配文件名。(https://gitlab.gnome.org/GNOME/nautilus/issues/624#note_311228

答案2

Gnome Shell 搜索依靠 nautilus 搜索来检索文件。如果没有安装跟踪器,搜索仅限于文件名搜索。如果安装了跟踪器,则可以搜索文件的内容。

在 Ubuntu 17.10 和 18.04 中,未安装 Tracker。在 Ubuntu 17.10 和早期的 Ubuntu 18.04 中,文件名搜索不会从主文件夹中的子文件夹中检索文件。目前,此功能运行良好。

我怀疑在安装了 Tracker 的情况下文件内容搜索能否正常工作。原则上,它应该可以正常工作。我建议您尝试一下它的效果如何。

相关内容