wherehows frontend change to adapt ES 5.5
*/
package dao;
+import java.util.*;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -190,6 +193,8 @@ public class SearchDAO extends AbstractMySQLOpenSourceDAO
{
// use elastic search completion suggester, ES will validate the input and limit
List<String> completionSuggestionList = new ArrayList<String>();
+ Set<String> completionSuggestionSet = new HashSet<String>();
+
JsonNode responseNode = null;
ObjectNode keywordNode = null;
@@ -199,7 +204,7 @@ public class SearchDAO extends AbstractMySQLOpenSourceDAO
Logger.error("Elastic search completion suggester error. Error message :" + e.getMessage());
}
- Logger.info("The completion suggester query sent to Elastic Search is: " + keywordNode.toString());
+ Logger.info("The completion suggester query sent to Elastic Search was: " + keywordNode.toString());
Promise<WSResponse> responsePromise =
WS.url(Play.application().configuration().getString(elasticSearchTypeURLKey)).post(keywordNode);
@@ -215,8 +220,6 @@ public class SearchDAO extends AbstractMySQLOpenSourceDAO
return completionSuggestionList;
}
- Logger.info("Response suggestNode is " + suggestNode.toString());
-
JsonNode whSuggestNode = suggestNode.get("wh-suggest");
if (whSuggestNode == null || !whSuggestNode.isArray()) {
Logger.error("Elastic search completion suggester response does not contain wh-suggest node");
@@ -250,10 +253,12 @@ public class SearchDAO extends AbstractMySQLOpenSourceDAO
continue;
}
String oneSuggestion = textNode.get("text").asText();
- completionSuggestionList.add(oneSuggestion);
+ completionSuggestionSet.add(oneSuggestion);
}
}
+ completionSuggestionList.addAll(completionSuggestionSet);
+ Logger.info("Returned suggestion list is: " + completionSuggestionList);
return completionSuggestionList;
}
@@ -397,7 +402,7 @@ public class SearchDAO extends AbstractMySQLOpenSourceDAO
}
if (filterNode != null) {
- queryNode.put("filter", filterNode);
+ queryNode.put("post_filter", filterNode);
}
Logger.info(
