5. ZOOM Facets
Prev | Chapter 3. ZOOM | Next

## 5. ZOOM Facets

Facets are only supported for a few Z39.50 targets. It is a relatively new non-standard Z39.50 extension (see facets.asn in the YAZ source). However, facets are usually supported for Solr and SRU 2.0 targets.

Facets may be specified by the facets option before a search is sent. See Section 8, “Facets” for the notation. For inspection of the returned facets, the following functions are available:

        ZOOM_facet_field *ZOOM_resultset_facets(ZOOM_resultset r);

        size_t ZOOM_resultset_facets_size(ZOOM_resultset r);

        ZOOM_facet_field ZOOM_resultset_get_facet_field(ZOOM_resultset r,
                                                        const char *facet_name);

        ZOOM_facet_field ZOOM_resultset_get_facet_field_by_index(ZOOM_resultset r,
                                                                 int pos);

        const char *ZOOM_facet_field_name(ZOOM_facet_field facet_field);

        size_t ZOOM_facet_field_term_count(ZOOM_facet_field facet_field);

        const char *ZOOM_facet_field_get_term(ZOOM_facet_field facet_field,
                                              size_t idx, int *freq);

References to temporary structures are returned by all functions. They are only valid as long the Result set is valid.

All facet fields may be returned by a call to `ZOOM_resultset_facets`. The length of the array is given by `ZOOM_resultset_facets_size`. The array is zero-based and the last entry will be at `ZOOM_resultset_facets_size(result_set)`-1.

Facet fields can also be fetched via its name using `ZOOM_resultset_get_facet_field`. Or by its index (starting from 0) by a call to `ZOOM_resultset_get_facet_field_by_index`. Both of these functions return NULL if name is not found or index is out of bounds.

Function `ZOOM_facet_field_name` gets the request facet name from a returned facet field.

Function `ZOOM_facet_field_get_term` returns the idx'th term and term count for a facet field. Idx must between 0 and `ZOOM_facet_field_term_count`-1, otherwise the returned reference will be `NULL`. On a valid idx, the value of the freq reference will be the term count. The `freq` parameter must be valid pointer to integer.

Prev | Up | Next
4. Records | Home | 6. Scan