figureFullMap() {
return tree() //
- .put("query", queryAndFilters) //
- .put("from", ifPositive(query.getStart())) //
- .put("highlight", highlighter)
- .put("size", ifPositive(query.getRows())) //
- .put("sort", sortFields) //
- .put("_source", returnFields) //
- .put("aggregations", facets) //
- .asMap();
+ .put("track_total_hits", true)
+ .put("query", queryAndFilters) //
+ .put("from", ifPositive(query.getStart())) //
+ .put("highlight", highlighter)
+ .put("size", ifPositive(query.getRows())) //
+ .put("sort", sortFields) //
+ .put("_source", returnFields) //
+ .put("aggs", facets) //
+ .asMap();
}
public String asString() throws SearchEngineException {
@@ -140,25 +205,25 @@ public QueryStringMap(String queryString) {
/**
* This is a kluge, but perhaps it will work for now.
- *
+ *
* Apparently Solr is willing to put up with query strings that contain
* special characters in odd places, but Elasticsearch is not.
- *
+ *
* So, a query string of "classgroup:http://this/that" must be escaped
* as "classgroup:http\:\/\/this\/that". Notice that the first colon
* delimits the field name, and so must not be escaped.
- *
+ *
* But what if no field is specified? Then all colons must be escaped.
* How would we distinguish that?
- *
+ *
* And what if the query is more complex, and more than one field is
* specified? What if other special characters are included?
- *
+ *
* This could be a real problem.
*/
private String escape(String queryString) {
return queryString.replace(":", "\\:").replace("/", "\\/")
- .replaceFirst("\\\\:", ":");
+ .replaceFirst("\\\\:", ":");
}
private Map makeInnerMap(String queryString) {
diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/elasticsearch/ResponseParser.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/elasticsearch/ResponseParser.java
index 7ac521065a..731c47eb9d 100644
--- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/elasticsearch/ResponseParser.java
+++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/elasticsearch/ResponseParser.java
@@ -5,15 +5,13 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchFacetField;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchFacetField.Count;
@@ -23,6 +21,8 @@
import edu.cornell.mannlib.vitro.webapp.searchengine.base.BaseSearchFacetField.BaseCount;
import edu.cornell.mannlib.vitro.webapp.searchengine.base.BaseSearchResponse;
import edu.cornell.mannlib.vitro.webapp.searchengine.base.BaseSearchResultDocument;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Elastic search sends a JSON response to a query. parse it to a
@@ -41,29 +41,29 @@ class ResponseParser {
@SuppressWarnings("unchecked")
public ResponseParser(String responseString) throws SearchEngineException {
try {
- this.responseMap = new ObjectMapper().readValue(responseString,
- HashMap.class);
+ this.responseMap = new ObjectMapper().readValue(responseString, new TypeReference