简体   繁体   English

如何在Elasticsearch中索引Twitter数据?

[英]How to index twitter data in elasticsearch?

I have fetched some data from twitter using streaming api. 我已经使用流式API从Twitter上获取了一些数据。 The file has json lines corresponding to the data. 该文件具有与数据相对应的json行。 I would like to index this data in elasticsearch so that it could be searched easily. 我想在elasticsearch中为该数据建立索引,以便可以轻松地对其进行搜索。

I used following command to for index 我使用以下命令进行索引

cat file.json | jq -c '.[] | {"index": {"_index": "bookmarks", "_type": "bookmark", "_id": .id}}, .' | curl -XPOST localhost:9200/_bulk --data-binary @-

but it results in following error. 但它导致以下错误。

jq: error (at <stdin>:127687): Cannot index string with string "id"

Instead of doing all that manually, you can simply use the Logstash Twitter Input. 无需手动完成所有操作,您只需使用Logstash Twitter Input。

I wrote a blog post about it. 我写了一篇关于它的博客文章

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

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