Class IndexResource
- Author:
- Florian Alpers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<GeoMapFeature> createFeatures(String query, String coordinateQuery, String labelConfig, String searchScope) getGeoJsonResuls(String solrField, String wktRegion, String filterQuery, String facetQuery, String labelField, String searchScope) Returns matching records or docstructs as GeoJSON feature objects for the given spatial field.getHeatmap(String solrField, String wktRegion, String filterQuery, String facetQuery, Integer gridLevel) Returns a heatmap over matching geospatial search results for the given Solr field.getItemMetadataList(String config) getMarkerMetadataList(String config) Executes a caller-supplied Solr query against the index and returns matching records as JSON.getStatistics(String query) Returns the number of indexed records matching an optional Solr query.
-
Constructor Details
-
IndexResource
public IndexResource()
-
-
Method Details
-
getStatistics
@GET @Path("/statistics") @Produces("application/json") public String getStatistics(@QueryParam("query") String query) throws IndexUnreachableException, PresentationException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException Returns the number of indexed records matching an optional Solr query.Without a query, only top-level work records (
ISWORK:*) are counted; supplying a query replaces that restriction rather than narrowing it, and either way the caller's access-condition suffixes are always applied.- Parameters:
query- optional Solr query to filter counted records- Returns:
- Indexed records statistics as JSON
- Throws:
IndexUnreachableExceptionPresentationExceptionde.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- if the query contains non-ASCII characters or has invalid Solr syntax
-
getRecordsForQuery
@POST @Path("/query") @Consumes("application/json") @Produces("application/json") public String getRecordsForQuery(RecordsRequestParameters params) throws IndexUnreachableException, ViewerConfigurationException, DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException Executes a caller-supplied Solr query against the index and returns matching records as JSON.Result and facet field names are validated against a Solr field-identifier pattern. An omitted
resultFieldsorfacetFieldsproperty is treated as an empty list; only an explicit JSONnulland malformed field names are rejected. Settingrandomizediscards any configured sort fields in favor of a random sort field, and settingincludeChildHitsaggregates matching child documents under their top-level structure and expands them into the response via Solr's expand mechanism.- Parameters:
params- query parameters including query, sort, facet, and result field configuration- Returns:
- Records as JSON
- Throws:
IndexUnreachableException- if the Solr index is unreachableViewerConfigurationException- if the viewer configuration needed to build the JSON records cannot be readDAOException- if license types cannot be read from the databasede.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- if the query is invalid, or facetFields/resultFields is an explicit null or contains an invalid field name
-
getAllIndexFields
@GET @Path("/fields") @Produces("application/json") public List<SolrFieldInfo> getAllIndexFields() throws IOException- Returns:
- List
- Throws:
IOException
-
getHeatmap
@GET @Path("/spatial/heatmap/{solrField}") @Produces("application/json") public String getHeatmap(@PathParam("solrField") String solrField, @QueryParam("region") @DefaultValue("[\"-180 -90\" TO \"180 90\"]") String wktRegion, @QueryParam("query") @DefaultValue("*:*") String filterQuery, @QueryParam("facetQuery") @DefaultValue("") String facetQuery, @QueryParam("gridLevel") Integer gridLevel) throws IndexUnreachableException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException Returns a heatmap over matching geospatial search results for the given Solr field.The result excludes polygon coordinate documents (
MD_GEOJSON_POLYGON,MD_GPS_POLYGON) so a heatmap over point data does not saturate, and always applies the caller's access-condition suffixes as a separate filter query, so they are enforced even for aquerythat starts with a Solr{!join ...}local param. The response is cacheable per client for 5 minutes.- Parameters:
solrField- Solr field containing spatial coordinate datawktRegion- WKT coordinate string restricting the search areafilterQuery- additional Solr query to filter resultsfacetQuery- facetting expression applied to heatmap resultsgridLevel- heatmap grid resolution level- Returns:
- Heatmap as
String - Throws:
IndexUnreachableException- if the Solr index is unreachablede.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- if solrField, the region parameter, or gridLevel is invalidde.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if the given Solr field does not exist in the index
-
getGeoJsonResuls
@GET @Path("/spatial/search/{solrField}") @Produces("application/json") public String getGeoJsonResuls(@PathParam("solrField") String solrField, @QueryParam("region") @DefaultValue("[\"-180 -90\" TO \"180 90\"]") String wktRegion, @QueryParam("query") @DefaultValue("*:*") String filterQuery, @QueryParam("facetQuery") @DefaultValue("") String facetQuery, @QueryParam("labelField") String labelField, @QueryParam("scope") String searchScope) throws IndexUnreachableException, PresentationException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException Returns matching records or docstructs as GeoJSON feature objects for the given spatial field.regionrestricts the search area to a WKT range (the whole world by default),queryadds further filter criteria, andfacetQuerynarrows which documents contribute coordinates; for some query formsregionis ignored oncefacetQueryis set. Up to 50,000 matching hits are evaluated and grouped bysearchScope(RECORDS,DOCSTRUCTS, orMETADATA;RECORDSby default), one feature per coordinate and label, labelled fromlabelField. A query built by the aggregated search-results view is detected and re-scoped toMETADATAautomatically.- Parameters:
solrField- Solr field containing spatial coordinate datawktRegion- WKT coordinate string restricting the search areafilterQuery- additional Solr query to filter resultsfacetQuery- facetting expression applied to which documents contribute coordinateslabelField- the Solr field to be used as label for each featuresearchScope- the scope of documents to search in. One of 'RECORDS', 'DOCSTRUCTS' and 'METADATA'- Returns:
- the matching features as a JSON array string in GeoJSON format
- Throws:
IndexUnreachableException- if the Solr index is unreachablePresentationException- if the Solr request fails for a reason other than a query syntax errorde.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- if solrField or the region parameter is malformedde.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if the given Solr field does not exist in the index
-
createFeatures
protected Collection<GeoMapFeature> createFeatures(String query, String coordinateQuery, String labelConfig, String searchScope) throws PresentationException, IndexUnreachableException -
getMarkerMetadataList
-
getItemMetadataList
-