简体   繁体   English

如何在弹性搜索中索引数据

[英]How To index data in elastic search

I am newbie in information retrieval domain. 我是信息检索领域的新手。 My task is to index large raw data in txt format into elasticsearch. 我的任务是将txt格式的大型原始数据索引到elasticsearch中。 I already crawled my data and stored it onto disk. 我已经抓取了我的数据并将其存储到磁盘上。
Now I installed elasticsearch(0.19.9 , I am using windows xp. I set the java_home variable and ran the elasticsearch.bat). 现在我安装了elasticsearch(0.19.9,我使用的是windows xp。我设置了java_home变量并运行了elasticsearch.bat)。 After installing elasticsearch I tested it hitting http:/localhost:9200 on browser and got response. 在安装了elasticsearch之后,我测试了它在浏览器上点击http:/localhost:9200并得到了响应。 Now if I try to create index by using help on elasticsearch website 现在,如果我尝试使用elasticsearch网站上的帮助创建索引

curl -XPUT http:/localhost:9200/elasticsearch/tweet/1 -d '{
  "post_date": "2009-11-15T14:12:12",
  "message": "Zug Zug",
  "tag": "warcraft"
}'

I get an error, IndexMissingException[elasticsearch] . 我收到一个错误, IndexMissingException[elasticsearch] So I am not able to create index. 所以我无法创建索引。 I am hitting browser directly, instead of using curl. 我直接点击浏览器,而不是使用curl。

The -d option is a curl option used to send the json document as body request. -d选项是一个curl选项,用于将json文档作为正文请求发送。 Furthermore, elasticsearch exposes nice REST APIs, which means that you are supposed to use the available http methods depending on the operation you want to do. 此外,elasticsearch公开了很好的REST API,这意味着你应该根据你想要的操作使用可用的http方法。 Creating an index through the Index API requires the use of the PUT http method. 通过Index API创建索引需要使用PUT http方法。 You really need to use a REST http client in order to index data in elasticsearch. 您确实需要使用REST http客户端来索引elasticsearch中的数据。

After that you can query it directly from the browser if you really want to. 之后,如果您真的想,可以直接从浏览器中查询。 You can do it either through the URIRequest or using the provided Query DSL and passing query using the body parameter instead of passing it within the request body. 您可以通过URIRequest或使用提供的Query DSL并使用body参数传递查询,而不是在请求正文中传递它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM