Search in sources :

Example 1 with SearchType

use of io.searchbox.params.SearchType in project xwiki-platform by xwiki.

the class DefaultDataManager method searchInstalls.

@Override
public JsonObject searchInstalls(String indexType, String fullQuery, Map<String, Object> parameters) throws Exception {
    Search.Builder searchBuilder = new Search.Builder(fullQuery).addIndex(JestClientManager.INDEX).addType(indexType);
    // Add parameters and handle specifically the Search Type.
    if (parameters.containsKey(Parameters.SEARCH_TYPE)) {
        SearchType searchType = this.converterManager.convert(SearchType.class, parameters.get(Parameters.SEARCH_TYPE));
        searchBuilder.setSearchType(searchType);
    }
    for (Map.Entry<String, Object> parameterEntry : parameters.entrySet()) {
        if (!parameterEntry.getKey().equals(Parameters.SEARCH_TYPE)) {
            searchBuilder.setParameter(parameterEntry.getKey(), parameterEntry.getValue());
        }
    }
    return executeActionQuery(searchBuilder.build(), fullQuery).getJsonObject();
}
Also used : Search(io.searchbox.core.Search) JsonObject(com.google.gson.JsonObject) SearchType(io.searchbox.params.SearchType) Map(java.util.Map)

Aggregations

JsonObject (com.google.gson.JsonObject)1 Search (io.searchbox.core.Search)1 SearchType (io.searchbox.params.SearchType)1 Map (java.util.Map)1