Hi All,
i am applying highlightedText on elasticsearch indexe through the java code, the highlighted text feature is working not working below is the mapping-
"dcl_raac_pcdb": {
"mappings": {
"dcl_raac_pcdbv1": {
"properties": {
"Application": {
"type": "string",
"index": "not_analyzed"
},
"Attributes": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {
"type": "string"
}
}
},
"BrandDesc": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"BrandId": {
"type": "string",
"index": "not_analyzed"
},
"Cat": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"CatDesc": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"CatId": {
"type": "string",
"index": "not_analyzed"
},
"CountryOfOrigin": {
"type": "string",
"index": "not_analyzed"
},
"Desc": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"LineCode": {
"type": "string",
"index": "not_analyzed"
},
"MarketingDesc": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"SubCatId": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"SubCatImageUrl": {
"type": "string"
},
"Term": {
"type": "string",
"index": "not_analyzed",
"fields": {
"raw": {
"type": "string"
}
}
},
"highlight": {
"properties": {
"fields": {
"properties": {
"BrandId": {
"type": "object"
}
}
}
}
},
"query": {
"properties": {
"bool": {
"properties": {
"must": {
"properties": {
"query_string": {
"properties": {
"query": {
"type": "string"
}
}
}
}
}
Java code
BoolQueryBuilder builder = boolQuery();
builder.must(QueryBuilders.queryStringQuery(term));
SearchRequestBuilder srb =ClientInstance.getInstance().getClient().prepareSearch().setIndices("dcl_raac_pcdb").setTypes("dcl_raac_pcdbv1").setQuery(builder).addHighlightedField("BrandId");
SearchResponse response = srb.execute().actionGet();
long total = response.getHits().getTotalHits();
{ Removed some properties (Fields) from the mapping due to space limitation)
I am using highlighted text field as "BrandId" or "LineCode" (tried with different fields), but am not getting Highlighted content in the response, its not working here (using elasticsearch 1.5.2)
Can anyone please guide me,
Thanks in advance.