Class XMLResponse
- java.lang.Object
-
- com.lucidworks.apollo.solr.response.AbstractResponse
-
- com.lucidworks.apollo.solr.response.QueryableResponse
-
- com.lucidworks.apollo.solr.response.XMLResponse
-
- All Implemented Interfaces:
WriteableResponse
public class XMLResponse extends QueryableResponse
-
-
Field Summary
-
Fields inherited from class com.lucidworks.apollo.solr.response.AbstractResponse
FUSION_NODE
-
Fields inherited from interface com.lucidworks.apollo.solr.response.WriteableResponse
DEFAULT_CHARSET
-
-
Constructor Summary
Constructors Constructor Description XMLResponse()
XMLResponse(org.w3c.dom.Document document)
-
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)
static XMLResponse
create(java.io.InputStream is)
static XMLResponse
create(java.lang.String xml)
static XMLResponse
create(java.lang.String xml, 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 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 docsjava.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 expresionjava.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 valuesjava.util.List<java.lang.String>
getGroupValues(java.lang.String groupField)
If group=true, return an ordered list of group valuesjava.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 maxScorejava.util.Optional<MediaType>
getMediaType()
java.util.Optional<java.lang.Long>
getNumFound()
Return Solr numFoundjava.util.Optional<java.lang.Long>
getQTime()
Return Solr QTimejava.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 handlerjava.util.Optional<java.lang.Long>
getStart()
java.util.Optional<java.lang.Long>
getTotalTime()
Return Fusion Query Pipeline timeorg.w3c.dom.Document
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.htmlvoid
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 emptyvoid
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 objectvoid
updateHighlighting(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> highlighting)
Update highlighting in underlying response objectboolean
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 com.lucidworks.apollo.solr.response.QueryableResponse
iterate, matches, query
-
Methods inherited from class com.lucidworks.apollo.solr.response.AbstractResponse
getDocIds, getDocuments, getDocumentsForGroupValue, getDocumentsForGroupValue, toByteArray, toString, updateDocuments, updateDocumentsForGroupValue, updateDocumentsForGroupValue
-
-
-
-
Method Detail
-
create
public static XMLResponse create(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
- Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
-
create
public static XMLResponse create(java.lang.String xml, java.nio.charset.Charset charset) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
- Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
-
create
public static XMLResponse create(java.io.InputStream is) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
- Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
-
appendString
public void appendString(java.lang.String name, java.lang.String value)
- Specified by:
appendString
in classAbstractResponse
-
appendStringList
public void appendStringList(java.lang.String name, java.util.List<java.lang.String> values)
- Specified by:
appendStringList
in classAbstractResponse
-
appendMultiMap
public void appendMultiMap(java.lang.String name, MultivaluedMap<java.lang.String,java.lang.String> params)
- Specified by:
appendMultiMap
in classAbstractResponse
-
write
public void write(java.io.OutputStream os) throws java.io.IOException
- Throws:
java.io.IOException
-
getUnderlyingObject
public org.w3c.dom.Document getUnderlyingObject()
- Specified by:
getUnderlyingObject
in classAbstractResponse
-
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()
-
getQTime
public java.util.Optional<java.lang.Long> getQTime()
Description copied from class:AbstractResponse
Return Solr QTime- Specified by:
getQTime
in classAbstractResponse
- Returns:
-
getTotalTime
public java.util.Optional<java.lang.Long> getTotalTime()
Description copied from class:AbstractResponse
Return Fusion Query Pipeline time- Specified by:
getTotalTime
in classAbstractResponse
- 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 classAbstractResponse
- Returns:
- true if update was successful
-
getNumFound
public java.util.Optional<java.lang.Long> getNumFound()
Description copied from class:AbstractResponse
Return Solr numFound- Specified by:
getNumFound
in classAbstractResponse
- Returns:
-
setNumFound
public void setNumFound(java.lang.Long numFound)
- Specified by:
setNumFound
in classAbstractResponse
-
getMaxScore
public java.util.Optional<java.lang.Double> getMaxScore()
Description copied from class:AbstractResponse
Return Solr maxScore- Specified by:
getMaxScore
in classAbstractResponse
- Returns:
-
getStart
public java.util.Optional<java.lang.Long> getStart()
- Specified by:
getStart
in classAbstractResponse
-
getCursorMark
public java.util.Optional<java.lang.String> getCursorMark()
- Specified by:
getCursorMark
in classAbstractResponse
-
setStart
public void setStart(java.lang.Long start)
- Specified by:
setStart
in classAbstractResponse
-
getResponseHeaderParams
public java.util.Map<java.lang.String,java.lang.Object> getResponseHeaderParams()
Description copied from class:AbstractResponse
Get params in responseHeader Makes defensive copies, detached from underlying response object. CallAbstractResponse.updateResponseHeaderParams(Map)
()} to commit the changes to the actual underlying response object.- Specified by:
getResponseHeaderParams
in classAbstractResponse
- Returns:
- responseHeader params
-
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 classAbstractResponse
- 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 classAbstractResponse
- 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 classAbstractResponse
- 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 classAbstractResponse
- 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 classAbstractResponse
-
getDocumentFieldValuesForCollapseExpandGroupValue
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getDocumentFieldValuesForCollapseExpandGroupValue(java.lang.String groupField, java.lang.String groupValue)
Description copied from class:AbstractResponse
Return documents of a specific group value under both "response/doc" and "expanded" sections in response Makes defensive copies, detached from underlying response object. CallAbstractResponse.updateDocumentFieldValuesForCollapseExpandGroupValue(String, String, List)
to persist the changes to the actual underlying response object.- Specified by:
getDocumentFieldValuesForCollapseExpandGroupValue
in classAbstractResponse
- Returns:
-
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 classAbstractResponse
-
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 classAbstractResponse
-
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 classAbstractResponse
-
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 classAbstractResponse
-
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 classAbstractResponse
-
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 classAbstractResponse
- Parameters:
groupField
- group fieldgroupValues
- 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. CallAbstractResponse.updateHighlighting(Map)
to commit the changes to the actual underlying response object.- Specified by:
getHighlighting
in classAbstractResponse
- 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 classAbstractResponse
-
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. CallAbstractResponse.updateFacets(Map)
to commit the changes to the actual underlying response object.- Specified by:
getFacets
in classAbstractResponse
- Returns:
-
getJsonFacets
public java.util.Map<java.lang.String,java.lang.Object> getJsonFacets()
- Specified by:
getJsonFacets
in classAbstractResponse
-
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 classAbstractResponse
-
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 classAbstractResponse
- Returns:
- spellcheck results or empty map
-
getDocIds
public java.util.List<java.lang.String> getDocIds(java.lang.String docIdField)
- Specified by:
getDocIds
in classAbstractResponse
-
-