Skip to content

Connecting to States local controlled vocabulary

E. Lynette Rayle edited this page Feb 26, 2019 · 1 revision

Overview

The States controlled vocabulary was created as an example of using YAML to define a custom controlled vocabulary. This doc describes how to setup and use the States vocabulary.

Prerequisites

Run the generator to install configuration files and an example authority.

rails generate qa:local:files

This creates the file config/authorities/states.yml. The following gives a few examples of terms defined in that file.

:terms:
    - :id: AL
      :term: Alabama
    - :id: AK
      :term: Alaska
    - :id: AZ
      :term: Arizona

Accessing via QA

Authority: local

Subauthorities:

  • states

Example search queries

Example search subauthority states:

/qa/search/local/states?q=Nor

Result:

[
  {"id":"NC","label":"North Carolina"},
  {"id":"ND","label":"North Dakota"}
]

NOTES:

  • Search searches terms, but not IDs. If you search for q=NC, the result set will be empty.
  • Search is NOT case-sensitive. The result set is the same when searching for q=nor.

Example term fetch request

Example fetch from subauthority states:

/qa/show/local/states/NE

Result:

{"id":"NE","term":"Nebraska"}

Example list all terms

/qa/terms/local/states

Result:

[
  {"id":"AL","label":"Alabama","active":true},
  {"id":"AK","label":"Alaska","active":true},
  {"id":"AZ","label":"Arizona","active":true},
  etc.
]

Documentation

This is a locally defined controlled vocabulary and does not have any associated documentation.

Clone this wiki locally