Package io.goobi.viewer.solr
Class SolrSearchIndex
java.lang.Object
io.goobi.viewer.solr.SolrSearchIndex
SolrSearchIndex class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstantMAX_HITS=1000000.static final int -
Constructor Summary
ConstructorsConstructorDescriptionSolrSearchIndex(org.apache.solr.client.solrj.SolrClient client) Constructor for SolrSearchIndex. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks 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.SolrDocumentListReturns all SolrDocuments matching the given query.org.apache.solr.common.SolrDocumentgetDocumentByIddoc(String iddoc) getDocumentByIddoc.org.apache.solr.common.SolrDocumentgetDocumentByPI.org.apache.solr.common.SolrDocumentgetDocumentByPIAndLogId(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.SolrDocumentgetFirstDoc(String query, List<String> fieldList) Retrieves the first document found by the given query.org.apache.solr.common.SolrDocumentgetFirstDoc(String query, List<String> fieldList, List<StringPair> sortFields) Retrieves the first document found by the given query.longgetHitCount(String query) Returns the number of hits for the given query without actually returning any documents.longgetHitCount(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.SolrClientstatic org.apache.solr.client.solrj.SolrClientgetNewSolrClient(String solrUrl) getPage(StructElement struct, int order) getPage.getPage.booleanvoidbooleanorg.apache.solr.common.SolrDocumentListDiese Methode führt eine Suche im Lucene durch.org.apache.solr.client.solrj.response.QueryResponsesearch(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.QueryResponsesearch(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.QueryResponsesearch(String query, int first, int rows, List<StringPair> sortFields, List<String> facetFields, List<String> fieldList) search.org.apache.solr.client.solrj.response.QueryResponsesearch(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.SolrDocumentListsearch.org.apache.solr.common.SolrDocumentListorg.apache.solr.client.solrj.response.QueryResponsesearchFacetsAndStatistics(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.QueryResponsesearchFacetsAndStatistics(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.QueryResponsesearchFacetsAndStatistics(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.QueryResponsetestQuery.voidupdateDataRepositoryNames(String pi, String dataRepositoryName)
-
Field Details
-
MAX_HITS
public static final int MAX_HITSConstantMAX_HITS=1000000.- See Also:
-
MAX_HITS_EXPANDED
public static final int MAX_HITS_EXPANDED- See Also:
-
-
Constructor Details
-
SolrSearchIndex
public SolrSearchIndex(org.apache.solr.client.solrj.SolrClient client) Constructor for SolrSearchIndex.
- Parameters:
client- aSolrClientobject.
-
-
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
-
getNewSolrClient
-
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- aStringobject.- Returns:
- a
QueryResponseobject. - 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-Stringfirst-Integerrows-IntegersortFields- Optional field/order pairs for sortingfacetFields- aListobject.facetSort- aStringobject.fieldList- If not null, only the fields in the list will be returned.filterQueries- aListobject.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-Stringfirst-Integerrows-IntegersortFields- Optional field/order pairs for sortingfacetFields- aListobject.fieldList- If not null, only the fields in the list will be returned.filterQueries- aListobject.params- aMapobject.- 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-Stringfirst-Integerrows-IntegersortFields- Optional field/order pairs for sortingfacetFields- aListobject.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- aStringobject.rows- a int.sortFields- Optional field/order pairs for sortingfieldList- If not null, only the fields in the list will be returned.- Returns:
- a
SolrDocumentListobject. - 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- aStringobject.fieldList- aListobject.- 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- aStringobject.- 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- aStringobject.fieldList- aListobject.- 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- aStringobject.fieldList- aListobject.- Returns:
- a
SolrDocumentListobject. - Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getDocumentByIddoc
public org.apache.solr.common.SolrDocument getDocumentByIddoc(String iddoc) throws IndexUnreachableException, PresentationException getDocumentByIddoc.
- Parameters:
iddoc- aStringobject.- Returns:
- a
SolrDocumentobject. - Throws:
IndexUnreachableException- if any.PresentationException- if any.
-
getDocumentByPI
public org.apache.solr.common.SolrDocument getDocumentByPI(String pi) throws IndexUnreachableException, PresentationException getDocumentByPI.
- Parameters:
pi- aStringobject.- Returns:
- a
SolrDocumentobject. - 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- aStringobject.querySuffix- aStringobject.- Returns:
- a
Listobject. - 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- aStringobject.- 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
Stringobject. - 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- aStringobject.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- aStringobject.logId- aStringobject.- 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- aStringobject.- 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:
IndexUnreachableExceptionPresentationException
-
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:
PresentationExceptionIndexUnreachableException
-
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
QueryResponseobject. - 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
QueryResponseobject. - 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
QueryResponseobject. - Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getAllFieldNames
getAllFieldNames.
- Returns:
- a
Listobject. - Throws:
DAOExceptionorg.apache.solr.client.solrj.SolrServerException- if any.IOException- if any.IndexUnreachableException
-
getAllBooleanFieldNames
- Throws:
IndexUnreachableException
-
loadSolrFields
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
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.SolrServerExceptionIOException
-
getDisplayUserGeneratedContentsForPage
@Deprecated(since="24.10") public List<DisplayUserGeneratedContent> getDisplayUserGeneratedContentsForPage(String pi, int page) throws PresentationException, IndexUnreachableException Deprecated.getDisplayUserGeneratedContentsForPage.
- Parameters:
pi- aStringobject.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- aStringobject.- 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:
PresentationExceptionIndexUnreachableException
-
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- aStringobject.order- a int.- Returns:
- a
PhysicalElementobject. - 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
PhysicalElementobject. - Throws:
IndexUnreachableException- if any.PresentationException- if any.DAOException- if any.
-
getDataRepositoryNames
- Returns:
- the dataRepositoryNames
-