Query syntax
The Search API, the search widget and other DigitalNZ search tools share a powerful search syntax borrowed from the Apache Lucene search engine.
You can test your query syntax using the DigitalNZ global search form. In most cases the queries will return the same results in the search form as in any other DigitalNZ tool.
Full documentation
The DigitalNZ search system uses Apache Lucene syntax, which is fully described in the Apache Lucene Query Parser Syntax documentation.
Lucene syntax is very powerful, and gives you access to numerous features, including fielded search, boolean operators, Google-style operators, nesting and grouping, proximity operators, wildcards, even fuzzy search.
Examples
Complex queries can be built up using boolean operators (AND, NOT) and with fielded searches using field:value syntax.
- Results from 1908: year:1908
- Results from the 20th century: century:1900-1999
- Results where the location is Wellington: placename:Wellington
- Results where the location starts with Wellington: placename:Wellington*
- Results from Auckland in 1908: placename:Auckland* AND year:1908
- Results from North Otago Museum: content_partner:"North Otago Museum"
- Results from Dictionary of New Zealand Biography website: collection:"Dictionary+of+New+Zealand+Biography"
- Results covered by Crown Copyright: rights:"Crown copyright"
- Date range searching: date:[1900-01-01T00:00:00Z TO 1903-01-01T00:00:00Z]
- Last modified results: last_modified_at:[2010-03-13T00:00:00.000Z TO *]
- And finally, you can search for everything in DigitalNZ by specifying that you want every value from every field: *:*
For example, results for the name 'William' from within the Dictionary of New Zealand Biography website:
http://api.digitalnz.org/records/v1.xml/?search_text=william%20AND%20collection:"Dictionary+of+New+Zealand
+Biography"&api_key=your_api_key
For example, last modified records from Flickr:
http://api.digitalnz.org/records/v1.xml/?search_text=last_modified_at:[2010-03-13T00:00:00.000Z%20TO%20*]%20AND%20collection:%22Flickr%22&api_key=your_api_key
Fielded, full text, and date searching
DigitalNZ offers exact match, full text, and date range searching.
Exact match indexing
Exact match searches require that the search text matches the indexed data exactly. Fields that can be searched using exact matches include:
- id
- category
- collection
- content_partner
- century
- creator
- decade
- language
- placename (metadata to be cleaned up)
- rights
- subject
- year
Note that DigitalNZ generates the year, decade and century values based on any date metadata associated with a record.
Text indexing
Text index searches do not require an exact match, instead the search text will match against words that appear anywhere in the indexed data. Fields that can be searched using text indexing include:
- title
- description
- fulltext (not used yet, currently full text is stored in the description field)
- text (the default search field - see below)
Date range indexing
Date indexed fields must be searched using date range syntax. Fields that can be searched using date range indexing include
- date (any date associated with the item)
- syndication_date (the date it was added to DigitalNZ)
The default search field
The "text" field is the default search field: if you do not specify a field explicitly, the text field will be searched.
The text field is not a real field, it is a copy of all these fields: title, description, category, content_partner, creator, subject, year, placename, and fulltext.
