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.
When you say "certain index", do you mean that tweets will go to different indices?
But anyway, I think I understood with your example.
If you want to extract only one field from the _source, you can use stored_fields Fields | Elasticsearch Reference [5.5] | Elastic.
Otherwise, you can read the full JSon response as a Map (see for example https://github.com/dadoonet/fscrawler/blob/master/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/JsonUtil.java#L60), then read inside this map to find the hits.hits[0]._source.text field. Something similar to https://github.com/dadoonet/fscrawler/blob/master/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClient.java#L337-L350.
- If you want to extract all the existing documents, you can't use classic
_searchfor that. But Scroll API: Scroll | Elasticsearch Reference [5.5] | Elastic
But first, try to solve your first problem.
Not a problem. I'm not english native either so I probably need more examples to understand.
and I’m new to this “world” too
Welcome to the real world, Neo. ![]()
