Improve this doc View source

# `FacetResultHandler`
service in module `seco.facetedSearch`

## Description

Service for retrieving SPARQL results based on facet selections.

## Usage

    new FacetResultHandler(endpointConfig, resultOptions);

#### Parameters

Param | Type | Details
--- | --- | ---
endpointConfig | string | The URL of the SPARQL endpoint, or a configuration object as taken by `AdvancedSparqlService`. See the angular-paging-sparql-service package.
- resultOptions | Object | Configuration object. The object has the following properties: queryTemplate - `{string}` - The result query with a `<RESULT_SET>` placeholder for the facet selections. The variable `?id` should be used for the result resources. The query should not restrict the results in any way (outside of the facet selections), or the results will not reflect the facets. The best way to insure this is to wrap each result value in an `OPTIONAL` block. For example:
         SELECT * WHERE {
             <RESULT_SET>
             OPTIONAL {
                 ?id rdfs:label ?name .
                 FILTER(langMatches(lang(?name), "en"))
             }
         }
[prefixes] - `{string}` - Any prefixes used in the `queryTemplate`. Required if the query uses any other prefixes than `rdf`, `rdfs`, or `skos`. [paging] - `{boolean}` - If truthy, results will be paged. Default is `true`. [resultsPerPage] - `{number}` - The number of results per page. Default is 10. [pagesPerQuery] - `{number}` - The number of pages to retrieve per query. Default is 1. [mapper] - `{Object}` - Mapper service for the results. The default is `objectMapperService`. See the angular-paging-sparql-service package for more information.

## Methods

- ### getResults(facetSelections, [orderBy])

  Get results based on the facet selections and the query template. Use paging if defined in the options.

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  facetSelections | Object | The facet states as broadcast by `FacetHandler`
  [orderBy] | string | SPARQL order comparators to use in sorting the results. Any variables used here have to be present in the `<RESULT_SET>` part of the query. I.e. they need to be included in the `constraint` parameter of `FacetHandler`. The default is to sort by `?id`.