是否有任何可定制的CLI工具可以监视文件系统的更改,对数据库中的内容进行爬网并为文件系统编制索引?
我尝试过csearch
,grep
,ack
。但是它帮助我从文件系统中搜索,但是无法构建完整的解决方案。我需要一些功能
上个月,我不得不解决一个非常关键的问题,涉及从2900万个文件中搜寻,索引和搜索源代码。我尝试了grep
,ack
,csearch
。但是,csearch
似乎比其他人快。
但是管理该系统非常困难,并且性能尚未准备好公开发布该系统。但是后来我发现了fscrawler
。一个Java CLI工具,可帮助我对整个文件系统(2900万个文件)进行爬网并将文件元数据 + 内容索引到Elasticsearch中。为了找到最佳解决方案,我花了2个星期的时间才弄清楚。因此,值得与他人分享。
fscrawler
索引数据,解析数据,生成文件元数据并在Elasticsearch
中建立索引。为了获得清晰的画面,这里是您在爬网和索引文件系统之前可以调整的配置选项。
name: "job_name"
fs:
url: "/path/to/docs"
update_rate: "5m"
includes:
- "*.doc"
- "*.xls"
excludes:
- "resume.doc"
json_support: false
filename_as_id: true
add_filesize: true
remove_deleted: true
add_as_inner_object: false
store_source: true
index_content: true
indexed_chars: "10000.0"
attributes_support: false
raw_metadata: true
xml_support: false
index_folders: true
lang_detect: false
continue_on_error: false
pdf_ocr: true
ocr:
language: "eng"
path: "/path/to/tesseract/if/not/available/in/PATH"
data_path: "/path/to/tesseract/tessdata/if/needed"
server:
hostname: "localhost"
port: 22
username: "dadoonet"
password: "password"
protocol: "SSH"
pem_path: "/path/to/pemfile"
elasticsearch:
nodes:
# With Cloud ID
- cloud_id: "CLOUD_ID"
# With URL
- url: "http://127.0.0.1:9200"
index: "docs"
bulk_size: 1000
flush_interval: "5s"
byte_size: "10mb"
username: "elastic"
password: "password"
rest:
url: "https://127.0.0.1:8080/fscrawler"
现在,我想您对运行整个操作可以执行多少自定义操作有了一个想法。您可以从https://fscrawler.readthedocs.io/en/latest/index.html阅读文档,并且源代码托管在GitHub https://github.com/dadoonet/fscrawler