How to create index with a keyword field through Java API

I am creating my index using following command:
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName).addMapping(documentType, XContentFactory.jsonBuilder().startObject().startObject(documentType).startObject("properties").startObject("completion_suggest").field("type", "completion").endObject().endObject().endObject().endObject());

I have a field named category on which I want to do aggregation. ElasticSearch tells me that it is text type so I should enable field data on this field or create keyword field on this.
Can somebody let me know how can it be done through above Java code?


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.