Searching

Searching all fields

The broadest search you can carry out is for the occurance of a word/phrase (or the absence of one) anywhere in an object record. This is a good starting point in finding an object record matching your search, as it will recall all object records containing (or not containing) that word/phrase. However, the relevancy to your interests of the object records returned could be fairly poor, as you may be finding the same word used across multiple meanings, for example searching for China will bring back both objects from that country, objects made using the material, addresses mentioning China, people and organisations with China in their name, and so on. If you already know that you are only looking for objects relating to China the country or the material, you can use a more targeted search parameter (‘q_place_name’ or ‘q_material’), or even better use a filter (‘id_place’ or ‘id_material’) (see Filtering).

Example: Search all records

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q="china"')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that have the word 'china' somewhere in the record")
There are 24799 objects that have the word 'china' somewhere in the record

As opposed to this general search query, the following methods of searching will only search within a subset of fields in the object record.

Searching by object name (object title and/or object type)

You might expect that every object has a title, but, outside of unique objects (often but not always paintings, sculpture, etc), this is not always the case. To assist in returning relevant results, this parameter lets you specify a search across both the object title and the object type (Vase, Etching, etc).

Note

If you do just want to search for a title, or alternatively if you just want to search for a type of object, there are also API parameters to let you do just that, covered below.

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_object_name="book"')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that have the word book in the titles assigned to it or the type of object")
print("The tenth object is called '%s' and has the type of %s" % (object_records[10]["_primaryTitle"], object_records[10]["objectType"]))     
There are 11531 objects that have the word book in the titles assigned to it or the type of object
The tenth object is called 'Book of floral designs' and has the type of Book

Searching by object title only

This searches amongst objects that have a title and whose title matches the query string.

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_object_title="book"')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that have the word 'book' in the titles assigned to it")
print("The fifth object is called '%s' and has the type of %s" % (object_records[10]["_primaryTitle"], object_records[5]["objectType"]))
There are 4774 objects that have the word 'book' in the titles assigned to it
The fifth object is called 'Year Book and Table Book' and has the type of Furnishing fabric

Searching by object type only

This searches amongst objects that have an object type matching the query string

Note

It should be noted here that there is an alternative parameter that can be used for object type searches: ‘kw_object_type’, which will only match on exactly what you have written. However, you might want to try and find all the variations (spelling, capitlisation, singlular/plural, etc) on the way the object type can be written, so using this parameter may be better for that purpose.

In addition, it’s useful to remember that objects can have parts, which is most commonly used to describe objects with discrete components, for example a cutlery set has parts for each item of cutlery within it. If you want to search for all the spoons in the collection you would ideally like to combine results from searching at the object level (for individual spoons) and searching at the part level (for spoons within a cutlery set). Sadly, part level searching is not available in the current API

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_object_type="book"')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} object records that have the word 'book' in the object type")
print("The fifth object is called '%s' and has the type of '%s'" % (object_records[10]["_primaryTitle"], object_records[5]["objectType"]))
There are 6938 object records that have the word 'book' in the object type
The fifth object is called '' and has the type of 'Book'

Searching by place

This is a way to search for a place connected to objects. Instead of an exact identifier match (as with Filter by place), this will search the place names as a string, so for example, if you search for London you will match on both “Greater London” and “City of London”, but also ‘London, Ontario’ which may or may not be what you want. If you want an exact match to only a specific place, you are better to use place filtering.

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_place_name=London')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that are connected to a place containing the word 'London'")
There are 87689 objects that are connected to a place containing the word 'London'

For comparison, place filtering on London (x28980) returns:

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?id_place=x28980')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that are connected to the place London, England (x28980)")
There are 86008 objects that are connected to the place London, England (x28980)

Searching by material or technique

Similiarly to place, this lets you search for use of a material or technique in the objects production, so searching for ‘Silver’ will find both ‘Silver engraving’ and ‘silver gelatin photography’. As with place, there are equivalent filter parameters (‘id_material’ and ‘id_technique’) that would offer more precise results, see Filter by material.

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_material_technique=Silver')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that use a material or technique containing the word 'Silver'")
There are 25757 objects that use a material or technique containing the word 'Silver'

Searching by person, people or organisation

Following the same pattern as above, this lets you search for a person or organisation involved, depicted or associated with an object. As you might have guessed by now, there are much better filtering parameters that let you perform the same query but better, see {ref} filter:person.

import requests
req = requests.get('https://api.vam.ac.uk/v2/objects/search?q_actor=william morris')
object_data = req.json()
object_info = object_data["info"]
object_records = object_data["records"]
record_count = object_info["record_count"]
print(f"There are {record_count} objects that connected with a person, people or organisation containing the words 'william' and 'morris'")
There are 36252 objects that connected with a person, people or organisation containing the words 'william' and 'morris'

Note

Any suggestion the author of this guide is completely biased towards the use of Filtering over Searching and recommends its use in almost all situations is completely correct.