Class JSONResponse

    • Constructor Summary

      Constructors 
      Constructor Description
      JSONResponse()  
      JSONResponse​(java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object> tree)  
      JSONResponse​(java.util.Map<java.lang.String,​java.lang.Object> tree)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendMultiMap​(java.lang.String name, MultivaluedMap<java.lang.String,​java.lang.String> params)  
      void appendObject​(java.lang.String name, java.lang.Object value)  
      void appendString​(java.lang.String name, java.lang.String value)  
      void appendStringList​(java.lang.String name, java.util.List<java.lang.String> values)  
      static JSONResponse create​(java.io.InputStream is)  
      static JSONResponse create​(java.lang.String json)  
      java.util.Optional<java.lang.String> getContentCharset()  
      java.util.Optional<java.lang.String> getContentType()  
      java.util.Optional<java.lang.String> getCursorMark()  
      java.util.List<java.lang.String> getDocIds​(java.lang.String docIdField)  
      java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getDocumentFieldValuesForCollapseExpandGroupValue​(java.lang.String groupField, java.lang.String groupValue)
      Return documents of a specific group value under both "response/doc" and "expanded" sections in response Makes defensive copies, detached from underlying response object.
      java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getDocumentFieldValuesForGroupValue​(java.lang.String groupField, java.lang.String groupValue)  
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getExpandedResults()
      Returns all collapse expanded results as a map of collapse field name to grouping data that includes list of docs
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getFacets()
      Return facet info as nested objects: {facet type -> field name -> facet count entries} NOTE: The actual Java type of facet count entries may differ between implementations.
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getGroupedResults()
      Returns all grouped results as a map of string grouped expression (a field name or a query) to grouping data that includes list of groups For comparison getGroups(String groupField) returns a list of groups for a particular grouping expresion
      java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getGroups​(java.lang.String groupField)
      Return groups in the response with all accompanying document data Each list entry contains information about the groupValue and the Solr doclist (which includes the docs as well as numFound and rows info).
      java.util.List<java.lang.String> getGroupValues()
      If group=true, return an ordered list of group values
      java.util.List<java.lang.String> getGroupValues​(java.lang.String groupField)
      If group=true, return an ordered list of group values
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getHighlighting()
      Return highlighting info as nested objects: {Doc ID -> Field name -> Snippets} Makes defensive copies, detached from underlying response object.
      java.util.Map<java.lang.String,​java.lang.Object> getJsonFacets()  
      java.util.Optional<java.lang.Double> getMaxScore()
      Return Solr maxScore
      java.util.Optional<MediaType> getMediaType()  
      java.util.Optional<java.lang.Long> getNumFound()
      Return Solr numFound
      java.util.Optional<java.lang.Long> getQTime()
      Return Solr QTime
      java.util.Map<java.lang.String,​java.lang.Object> getResponseHeaderParams()
      Get params in responseHeader Makes defensive copies, detached from underlying response object.
      java.util.Map<java.lang.String,​java.lang.Object> getSpellcheck()
      Returns response of Solr spellcheck handler
      java.util.Optional<java.lang.Long> getStart()  
      java.util.Optional<java.lang.Long> getTotalTime()
      Return Fusion Query Pipeline time
      java.util.Map<java.lang.String,​java.lang.Object> getUnderlyingObject()  
      boolean isGrouped()
      Checks to see if response is grouped (group=true Solr parameter) See https://lucene.apache.org/solr/guide/7_4/result-grouping.html
      void reorderGroupValues​(java.lang.String groupField, java.util.List<java.lang.String> groupValues)
      Reorder group values in the response.
      void setNumFound​(java.lang.Long numFound)  
      void setStart​(java.lang.Long start)  
      boolean setTotalTime​(java.lang.Long time)
      Set Fusion Query Pipeline time if and only if the responseHeader object already exists.
      void updateDocumentFieldValuesForCollapseExpandGroupValue​(java.lang.String groupField, java.lang.String groupValue, java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> updatedDocs)
      Update documents (corresponding to groupValue) in underlying response object The list of updatedDocuments should include all documents under the groupValue as this method updates both "response/doc" and "expanded" sections in response The list of updatedDocuments cannot be empty
      void updateDocumentFieldValuesForGroupValue​(java.lang.String groupField, java.lang.String groupValue, java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> updatedDocs)  
      void updateFacets​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> facets)
      Update facets in underlying response object
      void updateHighlighting​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> highlighting)
      Update highlighting in underlying response object
      boolean updateResponseHeaderParams​(java.util.Map<java.lang.String,​java.lang.Object> responseHeaderParams)
      Update responseHeader params if and only if responseHeader already exists.
      void write​(java.io.OutputStream os)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JSONResponse

        public JSONResponse()
      • JSONResponse

        public JSONResponse​(java.util.Map<java.lang.String,​java.lang.Object> tree)
      • JSONResponse

        public JSONResponse​(java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object> tree)
    • Method Detail

      • create

        public static JSONResponse create​(java.lang.String json)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • create

        public static JSONResponse create​(java.io.InputStream is)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • appendString

        public void appendString​(java.lang.String name,
                                 java.lang.String value)
        Specified by:
        appendString in class AbstractResponse
      • appendStringList

        public void appendStringList​(java.lang.String name,
                                     java.util.List<java.lang.String> values)
        Specified by:
        appendStringList in class AbstractResponse
      • appendObject

        public void appendObject​(java.lang.String name,
                                 java.lang.Object value)
      • write

        public void write​(java.io.OutputStream os)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getContentType

        public java.util.Optional<java.lang.String> getContentType()
      • getContentCharset

        public java.util.Optional<java.lang.String> getContentCharset()
      • getMediaType

        public java.util.Optional<MediaType> getMediaType()
      • getTotalTime

        public java.util.Optional<java.lang.Long> getTotalTime()
        Description copied from class: AbstractResponse
        Return Fusion Query Pipeline time
        Specified by:
        getTotalTime in class AbstractResponse
        Returns:
      • setTotalTime

        public boolean setTotalTime​(java.lang.Long time)
        Description copied from class: AbstractResponse
        Set Fusion Query Pipeline time if and only if the responseHeader object already exists.
        Specified by:
        setTotalTime in class AbstractResponse
        Returns:
        true if update was successful
      • updateResponseHeaderParams

        public boolean updateResponseHeaderParams​(java.util.Map<java.lang.String,​java.lang.Object> responseHeaderParams)
        Description copied from class: AbstractResponse
        Update responseHeader params if and only if responseHeader already exists.
        Specified by:
        updateResponseHeaderParams in class AbstractResponse
        Returns:
        true if update was successful
      • isGrouped

        public boolean isGrouped()
        Description copied from class: AbstractResponse
        Checks to see if response is grouped (group=true Solr parameter) See https://lucene.apache.org/solr/guide/7_4/result-grouping.html
        Specified by:
        isGrouped in class AbstractResponse
        Returns:
      • getGroupValues

        public java.util.List<java.lang.String> getGroupValues()
        Description copied from class: AbstractResponse
        If group=true, return an ordered list of group values
        Specified by:
        getGroupValues in class AbstractResponse
        Returns:
      • getGroupValues

        public java.util.List<java.lang.String> getGroupValues​(java.lang.String groupField)
        Description copied from class: AbstractResponse
        If group=true, return an ordered list of group values
        Specified by:
        getGroupValues in class AbstractResponse
        Returns:
      • getDocumentFieldValuesForGroupValue

        public java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getDocumentFieldValuesForGroupValue​(java.lang.String groupField,
                                                                                                                          java.lang.String groupValue)
        Specified by:
        getDocumentFieldValuesForGroupValue in class AbstractResponse
      • getExpandedResults

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getExpandedResults()
        Description copied from class: AbstractResponse
        Returns all collapse expanded results as a map of collapse field name to grouping data that includes list of docs
        Specified by:
        getExpandedResults in class AbstractResponse
      • updateDocumentFieldValuesForGroupValue

        public void updateDocumentFieldValuesForGroupValue​(java.lang.String groupField,
                                                           java.lang.String groupValue,
                                                           java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> updatedDocs)
        Specified by:
        updateDocumentFieldValuesForGroupValue in class AbstractResponse
      • updateDocumentFieldValuesForCollapseExpandGroupValue

        public void updateDocumentFieldValuesForCollapseExpandGroupValue​(java.lang.String groupField,
                                                                         java.lang.String groupValue,
                                                                         java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> updatedDocs)
        Description copied from class: AbstractResponse
        Update documents (corresponding to groupValue) in underlying response object The list of updatedDocuments should include all documents under the groupValue as this method updates both "response/doc" and "expanded" sections in response The list of updatedDocuments cannot be empty
        Specified by:
        updateDocumentFieldValuesForCollapseExpandGroupValue in class AbstractResponse
      • getGroupedResults

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getGroupedResults()
        Description copied from class: AbstractResponse
        Returns all grouped results as a map of string grouped expression (a field name or a query) to grouping data that includes list of groups For comparison getGroups(String groupField) returns a list of groups for a particular grouping expresion
        Specified by:
        getGroupedResults in class AbstractResponse
      • getGroups

        public java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getGroups​(java.lang.String groupField)
        Description copied from class: AbstractResponse
        Return groups in the response with all accompanying document data Each list entry contains information about the groupValue and the Solr doclist (which includes the docs as well as numFound and rows info).
        Specified by:
        getGroups in class AbstractResponse
      • reorderGroupValues

        public void reorderGroupValues​(java.lang.String groupField,
                                       java.util.List<java.lang.String> groupValues)
        Description copied from class: AbstractResponse
        Reorder group values in the response.
        Specified by:
        reorderGroupValues in class AbstractResponse
        Parameters:
        groupField - group field
        groupValues - a list of all group values in the desired order
      • getHighlighting

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getHighlighting()
        Description copied from class: AbstractResponse
        Return highlighting info as nested objects: {Doc ID -> Field name -> Snippets} Makes defensive copies, detached from underlying response object. Call AbstractResponse.updateHighlighting(Map) to commit the changes to the actual underlying response object.
        Specified by:
        getHighlighting in class AbstractResponse
        Returns:
      • updateHighlighting

        public void updateHighlighting​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> highlighting)
        Description copied from class: AbstractResponse
        Update highlighting in underlying response object
        Specified by:
        updateHighlighting in class AbstractResponse
      • getFacets

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getFacets()
        Description copied from class: AbstractResponse
        Return facet info as nested objects: {facet type -> field name -> facet count entries} NOTE: The actual Java type of facet count entries may differ between implementations. This is not ideal, but it would take a lot of work to support all the different variations of Solr responses that exist. At the time of this writing: - XMLResponse returns a LinkedHashMap - JSONResponse will return a List. The Java type of the list's contents will depend on what json.nl parameter was used in the Solr request. See https://lucene.apache.org/solr/guide/7_4/response-writers.html for complete list. We use Jackson to translate JSON -> Java types. Makes defensive copies, detached from underlying response object. Call AbstractResponse.updateFacets(Map) to commit the changes to the actual underlying response object.
        Specified by:
        getFacets in class AbstractResponse
        Returns:
      • getJsonFacets

        public java.util.Map<java.lang.String,​java.lang.Object> getJsonFacets()
        Specified by:
        getJsonFacets in class AbstractResponse
      • updateFacets

        public void updateFacets​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> facets)
        Description copied from class: AbstractResponse
        Update facets in underlying response object
        Specified by:
        updateFacets in class AbstractResponse
      • getSpellcheck

        public java.util.Map<java.lang.String,​java.lang.Object> getSpellcheck()
        Description copied from class: AbstractResponse
        Returns response of Solr spellcheck handler
        Specified by:
        getSpellcheck in class AbstractResponse
        Returns:
        spellcheck results or empty map
      • getDocIds

        public java.util.List<java.lang.String> getDocIds​(java.lang.String docIdField)
        Specified by:
        getDocIds in class AbstractResponse