avoid duplications in :fulltext
@@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,7 +36,7 @@ class ElasticDocument {
private static final Logger LOG = LoggerFactory.getLogger(ElasticDocument.class);
private final String path;
- private final List<String> fulltext;
+ private final Set<String> fulltext;
private final Set<String> suggest;
private final List<String> notNullProps;
private final List<String> nullProps;
@@ -44,8 +44,8 @@ class ElasticDocument {
ElasticDocument(String path) {
this.path = path;
- this.fulltext = new ArrayList<>();
- this.suggest = new HashSet<>();
+ this.fulltext = new LinkedHashSet<>();
+ this.suggest = new LinkedHashSet<>();
this.notNullProps = new ArrayList<>();
this.nullProps = new ArrayList<>();
this.properties = new HashMap<>();
@@ -98,11 +98,7 @@ class ElasticDocument {
builder.field(FieldNames.FULLTEXT, fulltext);
}
if (suggest.size() > 0) {
- builder.startArray(FieldNames.SUGGEST);
- for(String val: suggest) {
- builder.startObject().field("value", val).endObject();
- }
- builder.endArray();
+ builder.startObject(FieldNames.SUGGEST).field("suggestion", suggest).endObject();
}
if (notNullProps.size() > 0) {
builder.field(FieldNames.NOT_NULL_PROPS, notNullProps);
