{% extends "name/base.html" %} {% load name_extras %} {% block title %}About{% endblock %} {% block content %}
Notice there are two modes of searching. The first mode is a traditional search which takes a query and a type, filtering records containing your query in either the authorized name field or the variant field. The second search method is more of an existence lookup of the authorized name. The user should request {% absolute_url "name:label" "name_string_here" %}
. The API will then either return a 302 Found and redirect to the matching record, or a 404 Not Found. This page will first address the 'traditional' search API, then the label API.
Let's dive right in! The following are various search examples using curl:
$ curl "{% absolute_url "name:search-json" %}?q=joey+liechty" [ { "URL": "{% absolute_url "name:detail" "nm0051457" %}", "id": "nm0051457", "name": "joey liechty", "type": "Personal" } ] $ curl "{% absolute_url "name:search-json" %}?q=abc&q_type=Organization&callback=foo" foo([ { "URL": "{% url "name:detail" "nm0000063" %}", "id": "nm0000063", "name": "ABC Shop", "type": "Organization" } ]) $ curl "{% absolute_url "name:search-json" %}?q_type=Software" [ { "URL": "{% absolute_url "name:detail" "nm0051455" %}", "id": "nm0051455", "name": "Watson", "type": "Software" }, { "URL": "{% absolute_url "name:detail" "nm0012345" %}", "id": "nm0012345", "name": "Software Foo", "type": "Software" }, { "URL": "{% absolute_url "name:detail" "nm0043212" %}", "id": "nm0043212", "name": "123 SoftCom", "type": "Software" } ] $ curl "{% absolute_url "name:search-json" %}?q_type=Software,Organization" [ { "URL": "{% absolute_url "name:detail" "nm0051455" %}", "id": "nm0051455", "name": "Watson", "type": "Software" }, { "URL": "{% absolute_url "name:detail" "nm0012345" %}", "id": "nm0012345", "name": "Software Foo", "type": "Software" }, { "URL": "{% absolute_url "name:detail" "nm0043212" %}", "id": "nm0043212", "name": "123 SoftCom", "type": "Software" }, { "URL": "{% absolute_url "name:detail" "nm0000063" %}", "id": "nm0000063", "name": "ABC Shop", "type": "Organization" } ]
Parameters hang off the end of a search request to narrow the results you get in your response and will get you closer to the name you are attempting to lookup.
q: Optional - the text respresentation of the record name you want to search.The second method of searching is with the label API. The label API is essentially a quick way to determine if an authorized name exists in {{ name_app_title }}. The only two responses to this API are a 404 Not Found or a 302 Redirect.
$ curl "{% absolute_url "name:label" "joey-not-here" %}" No matching term found - authoritative, or variant - for "joey-not-here" $ curl -I "{% absolute_url "name:label" "thisrecordisforsureinthedatabase" %}" HTTP/1.0 302 FOUND Date: Mon, 25 Feb 2013 22:33:19 GMT Server: WSGIServer/0.1 Python/2.7.3 Content-Type: text/html; charset=utf-8 Location: {% absolute_url "name:detail" "nm0000085" %}