How to use Elasticsearch to make files in a directory searchable?

限于喜欢 提交于 2019-12-23 03:06:44

问题


I am very new to search engines and Elasticsearch, so please bear with me and apologies if this question sounds vague. I have a large directory with lots of .csv and .hdr files, and I want to be able to search text within these files. I've done the tutorials and read some of the documentation but I'm still struggling to understand the concept of indexing. It seems like all the tutorials show you how to index one document at a time, but this will take a long time as I have lots of files. Is there an easier way to make elasticsearch index all the documents in this directory and be able to search for what I want?


回答1:


Elasticsearch can only search on documents it has indexed. Indexed means Elasticsearch has consumed a document one by one and stored it internally.

Normay internal structure matters and you shold understand what you're doing to get best performance.

So you need a way to get your files into elastic search, i'm affarad there is no "one click way" to this...

You need

  1. Runing cluster
  2. Designed index on for the documents
  3. Get document from filesyste to Elasticsearch

Your question is focused on 3).

For this, search for script examples or tools that can crawl your directory and provision Elasticsearch with documents.

5 seconds of usding google brought me to

  • https://github.com/dadoonet/fscrawler
  • https://gist.github.com/stevehanson/7462063
  • Theoretically i could be done with Logstash (https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html), but i would give fscrawler a try.


来源:https://stackoverflow.com/questions/48065342/how-to-use-elasticsearch-to-make-files-in-a-directory-searchable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!