@Override @SuppressWarnings("unchecked") public Map<String, SolrJSONFacet> resolveJSONFacetResponse(QueryResponse response) { Map<String, SolrJSONFacet> jsonFacetMap = new HashMap<>(); NamedList facetResponse = (NamedList) response.getResponse().get("facets"); if (facetResponse != null) { Iterator<Map.Entry<String, Object>> facetIterator = facetResponse.iterator(); while (facetIterator.hasNext()) { Map.Entry<String, Object> entry = facetIterator.next(); if (NamedList.class.isAssignableFrom(entry.getValue().getClass())) { jsonFacetMap.put(entry.getKey(), resolveJSONFacet((NamedList) entry.getValue())); } } } return jsonFacetMap; }
List<String> collectionNames = listResponse.get("collections") == null ? collectionNames = new ArrayList<>() : (List<String>) listResponse.get("collections"); collectionNames = listResponse.get("collections") == null ? collectionNames = new ArrayList<>() : (List<String>) listResponse.get("collections");
private String getFieldNameOfUniqueKey() { final SolrQuery solrQuery = new SolrQuery(); try { solrQuery.setRequestHandler("/schema/uniquekey"); final QueryRequest req = new QueryRequest(solrQuery); if (isBasicAuthEnabled()) { req.setBasicAuthCredentials(getUsername(), getPassword()); } return(req.process(getSolrClient()).getResponse().get("uniqueKey").toString()); } catch (SolrServerException | IOException e) { getLogger().error("Solr query to retrieve uniqueKey-field failed due to {}", new Object[]{solrQuery.toString(), e}, e); throw new ProcessException(e); } }
@SuppressWarnings("unchecked") public List<String> listCollections() throws IOException, SolrServerException { NamedList<Object> response = request(getListCollectionsRequest(), null); return (List<String>) response.get(SolrConstants.RESPONSE_COLLECTIONS); }
/** * Build a group response. * @param groupRequest The original group request. * @param response The search response. * @return A group response. */ protected GroupResponse buildGroupResponse( GroupRequest groupRequest, QueryResponse response) { String groupNames = groupRequest.getGroups().stream().map(Group::getField).collect( Collectors.joining(",")); List<PivotField> pivotFields = response.getFacetPivot().get(groupNames); GroupResponse groupResponse = new GroupResponse(); groupResponse.setGroupedBy(groupRequest.getGroups().get(0).getField()); groupResponse.setGroupResults(getGroupResults(groupRequest, 0, pivotFields)); return groupResponse; }
@Override @SuppressWarnings("unchecked") public void setResponse(NamedList<Object> response) { super.setResponse(response); NamedList<Object> fieldResponse = (NamedList<Object>) response.get("field"); field.putAll(extractAttributeMap(fieldResponse)); }
@Override @SuppressWarnings("unchecked") public void setResponse(NamedList<Object> response) { super.setResponse(response); NamedList<Object> fieldTypeNamedList = (NamedList<Object>) response.get("fieldType"); fieldType = createFieldTypeRepresentation(fieldTypeNamedList); }
public Date getStartTime( String core ) { NamedList<Object> v = getCoreStatus( core ); if( v == null ) { return null; } return (Date) v.get( "startTime" ); }
@SuppressWarnings("unchecked") public NamedList<String> getErrorMessages() { return (NamedList<String>) getResponse().get( "failure" ); }
public int getStatus() { NamedList header = getResponseHeader(); if (header != null) { return (Integer) header.get("status"); } else { return 0; } }
@SuppressWarnings("unchecked") public NamedList<String> getErrorMessages() { return (NamedList<String>) getResponse().get( "exceptions" ); }
@Override @SuppressWarnings("unchecked") public void setResponse(NamedList<Object> response) { super.setResponse(response); NamedList<Object> dynamicFieldResponse = (NamedList<Object>) response.get("dynamicField"); dynamicField.putAll(extractAttributeMap(dynamicFieldResponse)); }
public Long getUptime( String core ) { NamedList<Object> v = getCoreStatus( core ); if( v == null ) { return null; } return (Long) v.get( "uptime" ); } }
private Analysis buildAnalysis(NamedList<NamedList<Object>> value) { Analysis analysis = new Analysis(); NamedList<Object> queryNL = value.get("query"); List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL); analysis.setQueryPhases(phases); NamedList<Object> indexNL = value.get("index"); phases = buildPhases(indexNL); analysis.setIndexPhases(phases); return analysis; }
private void getTuples(NamedList response, String field, Metric[] metrics) { Tuple tuple = new Tuple(new HashMap()); NamedList facets = (NamedList)response.get("facets"); fillTuples(tuples, tuple, facets, field, metrics); }
@SuppressWarnings("unchecked") private static FieldTypeRepresentation createFieldTypeRepresentation(NamedList<Object> fieldTypeNamedList) { FieldTypeRepresentation fieldTypeRepresentation = new FieldTypeRepresentation(); fillFieldTypeDefinition(fieldTypeRepresentation, fieldTypeNamedList); List<String> fields = (List<String>) fieldTypeNamedList.get("fields"); if (fields != null) fieldTypeRepresentation.setFields(fields); List<String> dynamicFields = (List<String>) fieldTypeNamedList.get("dynamicFields"); if (dynamicFields != null) fieldTypeRepresentation.setDynamicFields(dynamicFields); return fieldTypeRepresentation; }
public Long getExpirationTime() { try { return (Long)getResponse().get("long"); } catch (ClassCastException e) { throw new SolrException (SolrException.ErrorCode.SERVER_ERROR, "parsing error", e); } } }
private static Set<String> fetchLiveNodes(SolrClient client) throws Exception { ModifiableSolrParams params = new ModifiableSolrParams(); params.set("action", "CLUSTERSTATUS"); QueryRequest request = new QueryRequest(params); request.setPath("/admin/collections"); NamedList cluster = (SimpleOrderedMap) client.request(request).get("cluster"); Set<String> liveNodes = new HashSet((List<String>)(cluster.get("live_nodes"))); return liveNodes; }
/** * Returns a SolrRequest to get a list of collections in the cluster */ public static java.util.List<String> listCollections(SolrClient client) throws IOException, SolrServerException { CollectionAdminResponse resp = new List().process(client); return (java.util.List<String>) resp.getResponse().get("collections"); }