I haven't found any example of how to set up an ES index with term vectors and to retrieve them later programmatically in Java by document ID.
The JSON variant is described here is working: https://www.elastic.co/guide/en/elasticsearch/reference/2.2/docs-termvectors.html
Can anyone give a Java "translation" for this?
Currently, I create the index like so:
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.execute().actionGet();
And add a document like this:
XContentBuilder sourceBuilder;
sourceBuilder = XContentFactory.jsonBuilder().startObject()
.field("text", text)
.field("type", "testType");
IndexRequest request = new IndexRequest(indexName, esContentType).source(sourceBuilder);
client.index(request);
This is how I can fetch a document again:
GetResponse response = client.prepareGet(indexName, esContentType, id).execute().actionGet();