Package io.goobi.viewer.solr
Class SolrSearchIndex
java.lang.Object
io.goobi.viewer.solr.SolrSearchIndex
SolrSearchIndex class.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSolrSearchIndex
(org.apache.solr.client.solrj.SolrClient client) Constructor for SolrSearchIndex. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks whether the server's configured URL matches that in the config file.Retrieves the repository name for the record with the given PI and persists it in a map.generateFilteredTagCloud
(String fieldName, String querySuffix) Returns a list of Tags created from the terms for the given field name.getAllFieldNames.getAllSortFieldNames.getDisplayUserGeneratedContentsForPage
(String pi, int page) Deprecated.getDisplayUserGeneratedContentsForPage.org.apache.solr.common.SolrDocumentList
Returns all SolrDocuments matching the given query.org.apache.solr.common.SolrDocument
getDocumentByIddoc
(String iddoc) getDocumentByIddoc.org.apache.solr.common.SolrDocument
getDocumentByPI.org.apache.solr.common.SolrDocument
getDocumentByPIAndLogId
(String pi, String divId) getFilename
(String pi, int order) Catches the filename of the page with the given order under the given ip.getFilename
(String pi, String basename) Catches the filename of the page with the given basename under the given ip.org.apache.solr.common.SolrDocument
getFirstDoc
(String query, List<String> fieldList) Retrieves the first document found by the given query.org.apache.solr.common.SolrDocument
getFirstDoc
(String query, List<String> fieldList, List<StringPair> sortFields) Retrieves the first document found by the given query.long
getHitCount
(String query) Returns the number of hits for the given query without actually returning any documents.long
getHitCount
(String query, List<String> filterQueries) Returns the number of hits for the given query and filter queries without actually returning any documents.getIddocByLogid
(String pi, String logId) Returns the IDDOC of the logical document to which the given LOGID belongs.getIddocFromIdentifier
(String identifier) Returns the value of the IDDOC field for the document with the given PI (or 0 if none found).getIdentifierFromIddoc
(String iddoc) getIdentifierFromIddoc.getImageOwnerIddoc
(String pi, int pageNo) Returns the IDDOC of the logical document to which the given page belongs.getLabelValuesForFacetField
(String field, String labelField, Set<String> values) static org.apache.solr.client.solrj.SolrClient
getPage
(StructElement struct, int order) getPage.getPage.boolean
void
boolean
org.apache.solr.common.SolrDocumentList
Diese Methode führt eine Suche im Lucene durch.org.apache.solr.client.solrj.response.QueryResponse
search
(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, String facetSort, List<String> fieldList, List<String> filterQueries, Map<String, String> params) Main Solr search method.org.apache.solr.client.solrj.response.QueryResponse
search
(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, String facetSort, List<String> fieldList, List<String> filterQueries, Map<String, String> params, org.apache.solr.client.solrj.SolrRequest.METHOD queryMethod) org.apache.solr.client.solrj.response.QueryResponse
search
(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, List<String> fieldList) search.org.apache.solr.client.solrj.response.QueryResponse
search
(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, List<String> fieldList, List<String> filterQueries, Map<String, String> params) search.org.apache.solr.common.SolrDocumentList
search.org.apache.solr.common.SolrDocumentList
org.apache.solr.client.solrj.response.QueryResponse
searchFacetsAndStatistics
(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, boolean getFieldStatistics) Returns facets for the given facet field list.org.apache.solr.client.solrj.response.QueryResponse
searchFacetsAndStatistics
(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, String facetPrefix, Map<String, String> params, boolean getFieldStatistics) Returns facets for the given facet field list.org.apache.solr.client.solrj.response.QueryResponse
searchFacetsAndStatistics
(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, Map<String, String> params, boolean getFieldStatistics) Returns facets for the given facet field list.org.apache.solr.client.solrj.response.QueryResponse
testQuery.void
updateDataRepositoryNames
(String pi, String dataRepositoryName)
-
Field Details
-
MAX_HITS
public static final int MAX_HITSConstantMAX_HITS=1000000
.- See Also:
-
-
Constructor Details
-
SolrSearchIndex
public SolrSearchIndex(org.apache.solr.client.solrj.SolrClient client) Constructor for SolrSearchIndex.
- Parameters:
client
- aSolrClient
object.
-
-
Method Details
-
checkReloadNeeded
public void checkReloadNeeded()Checks whether the server's configured URL matches that in the config file. If not, a new server instance is created. -
getNewSolrClient
public static org.apache.solr.client.solrj.SolrClient getNewSolrClient()- Returns:
- New
SolrClient
-
isSolrIndexOnline
public boolean isSolrIndexOnline()- Returns:
- true if test query executes without errors; false otherwise
-
testQuery
public org.apache.solr.client.solrj.response.QueryResponse testQuery(String query) throws org.apache.solr.client.solrj.SolrServerException, IOException testQuery.
- Parameters:
query
- aString
object.- Returns:
- a
QueryResponse
object. - Throws:
org.apache.solr.client.solrj.SolrServerException
- if any.IOException
-
search
public org.apache.solr.client.solrj.response.QueryResponse search(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, String facetSort, List<String> fieldList, List<String> filterQueries, Map<String, String> params) throws PresentationException, IndexUnreachableExceptionMain Solr search method.- Parameters:
query
-String
first
-Integer
rows
-Integer
sortFields
- Optional field/order pairs for sortingfacetFields
- aList
object.facetSort
- aString
object.fieldList
- If not null, only the fields in the list will be returned.filterQueries
- aList
object.params
- Additional query parameters.- Returns:
QueryResponse
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
search
public org.apache.solr.client.solrj.response.QueryResponse search(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, String facetSort, List<String> fieldList, List<String> filterQueries, Map<String, String> params, org.apache.solr.client.solrj.SolrRequest.METHOD queryMethod) throws PresentationException, IndexUnreachableException -
search
public org.apache.solr.client.solrj.response.QueryResponse search(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, List<String> fieldList, List<String> filterQueries, Map<String, String> params) throws PresentationException, IndexUnreachableExceptionsearch.
- Parameters:
query
-String
first
-Integer
rows
-Integer
sortFields
- Optional field/order pairs for sortingfacetFields
- aList
object.fieldList
- If not null, only the fields in the list will be returned.filterQueries
- aList
object.params
- aMap
object.- Returns:
QueryResponse
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
search
public org.apache.solr.client.solrj.response.QueryResponse search(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, List<String> fieldList) throws PresentationException, IndexUnreachableException search.
- Parameters:
query
-String
first
-Integer
rows
-Integer
sortFields
- Optional field/order pairs for sortingfacetFields
- aList
object.fieldList
- If not null, only the fields in the list will be returned.- Returns:
QueryResponse
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
search
public org.apache.solr.common.SolrDocumentList search(String query, int rows, List<StringPair> sortFields, List<String> fieldList) throws PresentationException, IndexUnreachableException search.
- Parameters:
query
- aString
object.rows
- a int.sortFields
- Optional field/order pairs for sortingfieldList
- If not null, only the fields in the list will be returned.- Returns:
- a
SolrDocumentList
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
search
public org.apache.solr.common.SolrDocumentList search(String query, List<String> fieldList) throws PresentationException, IndexUnreachableException - Parameters:
query
- aString
object.fieldList
- aList
object.- Returns:
SolrDocumentList
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
search
public org.apache.solr.common.SolrDocumentList search(String query) throws PresentationException, IndexUnreachableException Diese Methode führt eine Suche im Lucene durch.- Parameters:
query
- aString
object.- Returns:
SolrDocumentList
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getFirstDoc
public org.apache.solr.common.SolrDocument getFirstDoc(String query, List<String> fieldList) throws PresentationException, IndexUnreachableException Retrieves the first document found by the given query.- Parameters:
query
- aString
object.fieldList
- aList
object.- Returns:
- The first hit returned by the query
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getFirstDoc
public org.apache.solr.common.SolrDocument getFirstDoc(String query, List<String> fieldList, List<StringPair> sortFields) throws PresentationException, IndexUnreachableException Retrieves the first document found by the given query.- Parameters:
query
- The query to searchfieldList
- The fields retrievedsortFields
- Sorting - the first volume according to this sorting is returned- Returns:
- The first hit returned by the query
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDocs
public org.apache.solr.common.SolrDocumentList getDocs(String query, List<String> fieldList) throws PresentationException, IndexUnreachableException Returns all SolrDocuments matching the given query. If no documents were found, null is returned- Parameters:
query
- aString
object.fieldList
- aList
object.- Returns:
- a
SolrDocumentList
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDocumentByIddoc
public org.apache.solr.common.SolrDocument getDocumentByIddoc(String iddoc) throws IndexUnreachableException, PresentationException getDocumentByIddoc.
- Parameters:
iddoc
- aString
object.- Returns:
- a
SolrDocument
object. - Throws:
IndexUnreachableException
- if any.PresentationException
- if any.
-
getDocumentByPI
public org.apache.solr.common.SolrDocument getDocumentByPI(String pi) throws IndexUnreachableException, PresentationException getDocumentByPI.
- Parameters:
pi
- aString
object.- Returns:
- a
SolrDocument
object. - Throws:
IndexUnreachableException
- if any.PresentationException
- if any.
-
getDocumentByPIAndLogId
public org.apache.solr.common.SolrDocument getDocumentByPIAndLogId(String pi, String divId) throws IndexUnreachableException, PresentationException -
generateFilteredTagCloud
public List<Tag> generateFilteredTagCloud(String fieldName, String querySuffix) throws IndexUnreachableException Returns a list of Tags created from the terms for the given field name. This method uses the slower doc search instead of term search, but can be filtered with a query.- Parameters:
fieldName
- aString
object.querySuffix
- aString
object.- Returns:
- a
List
object. - Throws:
IndexUnreachableException
- if any.
-
getIddocFromIdentifier
public String getIddocFromIdentifier(String identifier) throws PresentationException, IndexUnreachableException Returns the value of the IDDOC field for the document with the given PI (or 0 if none found).- Parameters:
identifier
- aString
object.- Returns:
- String value; null if none found
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getIdentifierFromIddoc
public String getIdentifierFromIddoc(String iddoc) throws PresentationException, IndexUnreachableException getIdentifierFromIddoc.
- Parameters:
iddoc
- a long.- Returns:
- a
String
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getImageOwnerIddoc
public String getImageOwnerIddoc(String pi, int pageNo) throws IndexUnreachableException, PresentationException Returns the IDDOC of the logical document to which the given page belongs.- Parameters:
pi
- aString
object.pageNo
- a int.- Returns:
- String value; null if none found
- Throws:
IndexUnreachableException
- if any.PresentationException
- if any.
-
getIddocByLogid
public String getIddocByLogid(String pi, String logId) throws IndexUnreachableException, PresentationException Returns the IDDOC of the logical document to which the given LOGID belongs.- Parameters:
pi
- aString
object.logId
- aString
object.- Returns:
- String value; null if none found
- Throws:
IndexUnreachableException
- if any.PresentationException
- if any.
-
getHitCount
Returns the number of hits for the given query without actually returning any documents.- Parameters:
query
- aString
object.- Returns:
- a long.
- Throws:
IndexUnreachableException
- if any.PresentationException
- if any.
-
getHitCount
public long getHitCount(String query, List<String> filterQueries) throws IndexUnreachableException, PresentationException Returns the number of hits for the given query and filter queries without actually returning any documents.- Parameters:
query
-filterQueries
-- Returns:
- Number of hits for the given queries
- Throws:
IndexUnreachableException
PresentationException
-
findDataRepositoryName
public String findDataRepositoryName(String pi) throws PresentationException, IndexUnreachableException Retrieves the repository name for the record with the given PI and persists it in a map. This method is package private to discourage clients from constructing data file paths manually instead of using Helper methods.- Parameters:
pi
-- Returns:
- Data repository name for the record with the given identifier; null if not in a repository
- Throws:
PresentationException
IndexUnreachableException
-
updateDataRepositoryNames
- Parameters:
pi
-dataRepositoryName
-
-
searchFacetsAndStatistics
public org.apache.solr.client.solrj.response.QueryResponse searchFacetsAndStatistics(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, boolean getFieldStatistics) throws PresentationException, IndexUnreachableException Returns facets for the given facet field list. No actual docs are returned since they aren't necessary.- Parameters:
query
- The query to use.filterQueries
- Optional filter queriesfacetFields
- List of facet fields.facetMinCount
- a int.getFieldStatistics
- If true, field statistics will be generated for every facet field.- Returns:
- a
QueryResponse
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
searchFacetsAndStatistics
public org.apache.solr.client.solrj.response.QueryResponse searchFacetsAndStatistics(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, Map<String, String> params, boolean getFieldStatistics) throws PresentationException, IndexUnreachableExceptionReturns facets for the given facet field list. No actual docs are returned since they aren't necessary.- Parameters:
query
- The query to use.filterQueries
- Optional filter queriesfacetFields
- List of facet fields.facetMinCount
- a int.params
-getFieldStatistics
- If true, field statistics will be generated for every facet field.- Returns:
- a
QueryResponse
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
searchFacetsAndStatistics
public org.apache.solr.client.solrj.response.QueryResponse searchFacetsAndStatistics(String query, List<String> filterQueries, List<String> facetFields, int facetMinCount, String facetPrefix, Map<String, String> params, boolean getFieldStatistics) throws PresentationException, IndexUnreachableExceptionReturns facets for the given facet field list. No actual docs are returned since they aren't necessary.- Parameters:
query
- The query to use.filterQueries
- Optional filter queriesfacetFields
- List of facet fields.facetMinCount
- a int.facetPrefix
- The facet field value must start with these characters. Ignored if null or blankparams
-getFieldStatistics
- If true, field statistics will be generated for every facet field.- Returns:
- a
QueryResponse
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getAllFieldNames
getAllFieldNames.
- Returns:
- a
List
object. - Throws:
DAOException
org.apache.solr.client.solrj.SolrServerException
- if any.IOException
- if any.IndexUnreachableException
-
getAllBooleanFieldNames
- Throws:
IndexUnreachableException
-
loadSolrFields
- Throws:
org.apache.solr.client.solrj.SolrServerException
IOException
-
getAllSortFieldNames
public List<String> getAllSortFieldNames() throws org.apache.solr.client.solrj.SolrServerException, IOExceptiongetAllSortFieldNames.
- Returns:
- a list of all SOLR fields starting with "SORT_".
- Throws:
org.apache.solr.client.solrj.SolrServerException
- if any.IOException
- if any.
-
getAllGroupFieldNames
public List<String> getAllGroupFieldNames() throws org.apache.solr.client.solrj.SolrServerException, IOException- Returns:
- A list of all SOLR fields without the multivalues flag
- Throws:
org.apache.solr.client.solrj.SolrServerException
IOException
-
getDisplayUserGeneratedContentsForPage
@Deprecated(since="24.10") public List<DisplayUserGeneratedContent> getDisplayUserGeneratedContentsForPage(String pi, int page) throws PresentationException, IndexUnreachableException Deprecated.getDisplayUserGeneratedContentsForPage.
- Parameters:
pi
- aString
object.page
- a int.- Returns:
- contents for the given page
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDisplayUserGeneratedContentsForRecord
public List<DisplayUserGeneratedContent> getDisplayUserGeneratedContentsForRecord(String pi) throws PresentationException, IndexUnreachableException getDisplayUserGeneratedContentsForPage.
- Parameters:
pi
- aString
object.- Returns:
- contents for the given page
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getFilename
public Optional<String> getFilename(String pi, int order) throws PresentationException, IndexUnreachableException Catches the filename of the page with the given order under the given ip.- Parameters:
pi
- The topstruct piorder
- The page order (1-based- Returns:
- An optíonal containing the filename of the page with the given order under the given ip. Or an empty optional if no matching page was found.
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getFilename
public Optional<String> getFilename(String pi, String basename) throws PresentationException, IndexUnreachableException Catches the filename of the page with the given basename under the given ip. Used in case a filename is requested without the file extension- Parameters:
pi
- The topstruct pibasename
- The filename of the image without the extension (everything before the last dot)- Returns:
- An optíonal containing the filename of the page with the given order under the given ip. Or an empty optional if no matching page was found.
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getLabelValuesForFacetField
public Map<String,String> getLabelValuesForFacetField(String field, String labelField, Set<String> values) throws PresentationException, IndexUnreachableException - Parameters:
field
-labelField
-values
-- Returns:
- Map
- Throws:
PresentationException
IndexUnreachableException
-
getSolrServerUrl
- Returns:
- Base URL of the active Solr server
-
pingSolrIndex
public boolean pingSolrIndex()- Returns:
- true if ping successful; false otherwise
-
getHeatMap
public String getHeatMap(String solrField, String wktRegion, String query, String filterQuery, Integer gridLevel) throws IndexUnreachableException - Parameters:
solrField
-wktRegion
-query
-filterQuery
-gridLevel
-- Returns:
- String
- Throws:
IndexUnreachableException
-
getPage
public PhysicalElement getPage(String pi, int order) throws IndexUnreachableException, PresentationException, DAOException getPage.
- Parameters:
pi
- aString
object.order
- a int.- Returns:
- a
PhysicalElement
object. - Throws:
IndexUnreachableException
- if any.PresentationException
- if any.DAOException
- if any.
-
getPage
public PhysicalElement getPage(StructElement struct, int order) throws IndexUnreachableException, PresentationException, DAOException getPage.
- Parameters:
struct
-order
- a int.- Returns:
- a
PhysicalElement
object. - Throws:
IndexUnreachableException
- if any.PresentationException
- if any.DAOException
- if any.
-
getDataRepositoryNames
- Returns:
- the dataRepositoryNames
-