Skip to content
Snippets Groups Projects
Commit 9f3065e4 authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

enable term aggregation for nested text attributes

parent 31322fc0
No related branches found
No related tags found
1 merge request!192enable term aggregation for nested text attributes
Pipeline #60892 failed
...@@ -106,13 +106,15 @@ public class TypeMapper { ...@@ -106,13 +106,15 @@ public class TypeMapper {
return Records.Type.builder().type(getArrayMemberType(indexerType.toString())).build(); return Records.Type.builder().type(getArrayMemberType(indexerType.toString())).build();
} }
if(isMap(indexerType)){ if (isMap(indexerType)) {
Map<String,Object> type = (Map<String, Object>) indexerType; Map<String, Object> type = (Map<String, Object>) indexerType;
Map<String, Object> propertiesMap = (Map<String, Object>) type.get(Constants.PROPERTIES); Map<String, Object> propertiesMap = (Map<String, Object>) type.get(Constants.PROPERTIES);
for (Map.Entry<String,Object> entry : propertiesMap.entrySet()){ for (Map.Entry<String, Object> entry : propertiesMap.entrySet()) {
if(isMap(entry.getValue())){ if (isMap(entry.getValue())) {
entry.setValue(getDataAttributeIndexerMapping(entry.getValue())); entry.setValue(getDataAttributeIndexerMapping(entry.getValue()));
}else { } else if(ElasticType.TEXT.getValue().equalsIgnoreCase(String.valueOf(entry.getValue()))) {
entry.setValue(getTextIndexerMapping());
} else {
entry.setValue(Records.Type.builder().type(entry.getValue().toString()).build()); entry.setValue(Records.Type.builder().type(entry.getValue().toString()).build());
} }
} }
......
...@@ -300,7 +300,7 @@ public class ElasticUtils { ...@@ -300,7 +300,7 @@ public class ElasticUtils {
SearchRequest searchRequest = new SearchRequest(index); SearchRequest searchRequest = new SearchRequest(index);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(nestedQuery(path,boolQuery().must(matchQuery(firstNestedField,firstNestedValue)).must(matchQuery(secondNestedField,secondNestedValue)), ScoreMode.Avg)); searchSourceBuilder.query(nestedQuery(path,boolQuery().must(matchQuery(firstNestedField,firstNestedValue)).must(termQuery(secondNestedField + ".keyword",secondNestedValue)), ScoreMode.Avg));
searchRequest.source(searchSourceBuilder); searchRequest.source(searchSourceBuilder);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment