public void addSettings(XContentBuilder builder) throws IOException{
if(clazz.getAnnotation(ElasticSearchable.class).analysis() == null)
return;
ElasticSearchAnalysis analysis = clazz.getAnnotation(ElasticSearchable.class).analysis();
if((analysis.analyzers() == null || analysis.analyzers().length < 1) &&
(analysis.filters() == null || analysis.filters().length < 1))
return;
builder.startObject("analysis");
if(analysis.analyzers() != null && analysis.analyzers().length > 0){
builder.startObject("analyzer");
for (ElasticSearchAnalyzer analyzer : analysis.analyzers()) {
builder.startObject(analyzer.name());
if(analyzer.tokenizer() != null)
builder.field("tokenizer", analyzer.tokenizer());
if(analyzer.filtersNames() != null && analyzer.filtersNames().length > 0)
builder.field("filter", analyzer.filtersNames());
builder.endObject();
}
builder.endObject();
}
if(analysis.filters() != null && analysis.filters().length > 0){
builder.startObject("filter");
for (ElasticSearchFilter filter : analysis.filters()) {
builder.startObject(filter.name());
builder.field("type", filter.typeName());