Class RawResponse

  • All Implemented Interfaces:
    WriteableResponse, java.io.Closeable, java.lang.AutoCloseable

    public class RawResponse
    extends AbstractResponse
    implements java.io.Closeable
    This represents a response that we do not know the contents of. It is a type that we do not know how to parse.
    • Constructor Summary

      Constructors 
      Constructor Description
      RawResponse​(java.io.InputStream rawResponse, java.lang.String contentType, java.lang.String charset)  
      RawResponse​(java.io.InputStream rawResponse, java.lang.String contentType, java.lang.String charset, boolean failOnUnimplementedMethods)  
    • 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 appendString​(java.lang.String name, java.lang.String value)  
      void appendStringList​(java.lang.String name, java.util.List<java.lang.String> values)  
      void close()  
      static RawResponse create​(java.io.InputStream rawResponse, java.lang.String contentType, java.util.Optional<java.nio.charset.Charset> charset)  
      static RawResponse create​(java.io.InputStream rawResponse, java.util.Optional<MediaType> contentType, java.util.Optional<java.nio.charset.Charset> charset)  
      static RawResponse create​(java.lang.String stringResponse, java.util.Optional<MediaType> contentType, java.util.Optional<java.nio.charset.Charset> charset)  
      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 id)  
      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.io.InputStream getRawResponse()  
      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.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>> updatedDocuments)
      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>> updatedDocuments)  
      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

      • RawResponse

        public RawResponse​(java.io.InputStream rawResponse,
                           java.lang.String contentType,
                           java.lang.String charset)
      • RawResponse

        public RawResponse​(java.io.InputStream rawResponse,
                           java.lang.String contentType,
                           java.lang.String charset,
                           boolean failOnUnimplementedMethods)
    • Method Detail

      • write

        public void write​(java.io.OutputStream os)
                   throws java.io.IOException
        Specified by:
        write in interface WriteableResponse
        Throws:
        java.io.IOException
      • create

        public static RawResponse create​(java.lang.String stringResponse,
                                         java.util.Optional<MediaType> contentType,
                                         java.util.Optional<java.nio.charset.Charset> charset)
      • create

        public static RawResponse create​(java.io.InputStream rawResponse,
                                         java.util.Optional<MediaType> contentType,
                                         java.util.Optional<java.nio.charset.Charset> charset)
      • create

        public static RawResponse create​(java.io.InputStream rawResponse,
                                         java.lang.String contentType,
                                         java.util.Optional<java.nio.charset.Charset> charset)
      • getRawResponse

        public java.io.InputStream getRawResponse()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        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
      • 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
      • updateDocumentFieldValuesForGroupValue

        public void updateDocumentFieldValuesForGroupValue​(java.lang.String groupField,
                                                           java.lang.String groupValue,
                                                           java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> updatedDocuments)
        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>> updatedDocuments)
        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
      • 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
      • 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 id)
        Specified by:
        getDocIds in class AbstractResponse