Class IndexResource

java.lang.Object
io.goobi.viewer.api.rest.v1.index.IndexResource

@Path("/index") public class IndexResource extends Object
REST resource providing search, field information, and statistical queries against the Solr index.
Author:
Florian Alpers
  • 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:
      IndexUnreachableException
      PresentationException
      de.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 resultFields or facetFields property is treated as an empty list; only an explicit JSON null and malformed field names are rejected. Setting randomize discards any configured sort fields in favor of a random sort field, and setting includeChildHits aggregates 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 unreachable
      ViewerConfigurationException - if the viewer configuration needed to build the JSON records cannot be read
      DAOException - if license types cannot be read from the database
      de.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 a query that starts with a Solr {!join ...} local param. The response is cacheable per client for 5 minutes.

      Parameters:
      solrField - Solr field containing spatial coordinate data
      wktRegion - WKT coordinate string restricting the search area
      filterQuery - additional Solr query to filter results
      facetQuery - facetting expression applied to heatmap results
      gridLevel - heatmap grid resolution level
      Returns:
      Heatmap as String
      Throws:
      IndexUnreachableException - if the Solr index is unreachable
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException - if solrField, the region parameter, or gridLevel is invalid
      de.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.

      region restricts the search area to a WKT range (the whole world by default), query adds further filter criteria, and facetQuery narrows which documents contribute coordinates; for some query forms region is ignored once facetQuery is set. Up to 50,000 matching hits are evaluated and grouped by searchScope (RECORDS, DOCSTRUCTS, or METADATA; RECORDS by default), one feature per coordinate and label, labelled from labelField. A query built by the aggregated search-results view is detected and re-scoped to METADATA automatically.

      Parameters:
      solrField - Solr field containing spatial coordinate data
      wktRegion - WKT coordinate string restricting the search area
      filterQuery - additional Solr query to filter results
      facetQuery - facetting expression applied to which documents contribute coordinates
      labelField - the Solr field to be used as label for each feature
      searchScope - 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 unreachable
      PresentationException - if the Solr request fails for a reason other than a query syntax error
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException - if solrField or the region parameter is malformed
      de.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
      Throws:
      PresentationException
      IndexUnreachableException
    • getMarkerMetadataList

      public String getMarkerMetadataList(String config)
    • getItemMetadataList

      public String getItemMetadataList(String config)