My goal is to add tweet to a certain index in elasticsearch. And also have a method able to get all saved tweets of a certain index.
JSON of a tweet exemple:
{
"took": 356,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 45739,
"max_score": 1,
"hits": [
{
"_index": "super",
"_type": "tweet",
"_id": "AV3CvfikX9cr2kPs41mp",
"_score": 1,
"_source": {
"extended_entities": {
"media": [
{
"display_url": "pic.twitter.com/bBH0mIfqaZ",
"indices": [
80,
103
],
"sizes": {
"small": {
"w": 626,
"h": 350,
"resize": "fit"
},
"large": {
"w": 626,
"h": 350,
"resize": "fit"
},
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 626,
"h": 350,
"resize": "fit"
}
},
"id_str": "894963129897111555",
"expanded_url": "https://twitter.com/EcuadorWillana/status/894963132338249728/photo/1",
"media_url_https": "https://pbs.twimg.com/media/DGuMOZSW0AMY0s2.jpg",
"id": 894963129897111600,
"type": "photo",
"media_url": "http://pbs.twimg.com/media/DGuMOZSW0AMY0s2.jpg",
"url": "https://t.co/bBH0mIfqaZ"
}
]
},
"in_reply_to_status_id_str": null,
"in_reply_to_status_id": null,
"created_at": "Tue Aug 08 16:46:53 +0000 2017",
"in_reply_to_user_id_str": null,
"source": "<a href=\"http://ecuadorwillana.com\" rel=\"nofollow\">EcuadorWillana</a>",
"retweet_count": 0,
"retweeted": false,
"geo": null,
"filter_level": "low",
"in_reply_to_screen_name": null,
"is_quote_status": false,
"id_str": "894963132338249728",
"in_reply_to_user_id": null,
"@version": "1",
"favorite_count": 0,
"id": 894963132338249700,
"text": "#RealMadrid y #United disputan hoy #SupercopaDeEuropa - https://t.co/LmsRUby0ww https://t.co/bBH0mIfqaZ",
"place": null,
"lang": "es",
"favorited": false,
"possibly_sensitive": false,
"coordinates": null,
"truncated": false,
....
}
}
},
If you use the above code I will get all the fields of a tweet and what I want is to access a specific "key" which is the "text" getting its value.
1- How can I get a field specific to something like Response?
2- I am considering that it is possible to use the query match_all, I can get all the tweets of a given index and get the value of the key "text" of each one.
I spoke in JSON because I want to create a JSON object with this structure
EntityUtils.toString(response5.getEntity())
so that it is easier to access the specific key.
Can I explain myself better?
I'm very sorry, my English is bad and I'm new to this "world" too.