Search requests can be made to search an entire account, a particular container or a specified path, based on the URL entered at the time of search. Utilize one of the following examples and your authentication code to perform the desired search.
After accessing the desired area of the Search Service API, a “‘GET”’ request is performed utilizing the “‘X-Context”’ header with the value of “‘search”’. To filter results, a number of parameters are available for use:
The search query string.
If you specify fields (including meta information) when use a period to separate ‘q’ and the field names.
For meta fields, you can use a period or a dash to separate ‘meta’ from the actual meta key name.
Examples (these produce identical results):
Field to search. Default settings search for name and custom meta values.
The type of entity to search for. The default displays all types (containers and objects)
The return format. Examples are shown below. Default: plain
Defines whether or not the search will be limited to one directory level or to search recursively. Default: true
A basic search query may contain one or more parameters, based on your desired return. When inputting more than one search parameter, separate parameters with an ampersand (&). For example, to search an account recursively for objects with the content type of “application/directory” and request the return in XML format, format the request as follows:
The Search API’s response to your query is returned with a basic header and a body that can be formatted for json, xml or in plain text. The response header indicates the dateTime stamp of your query, the content and return type, the return count and the total number of items related to your query. The response header is formatted as follows:
HTTP/1.1 200 OK
Date: Thu, 19 Oct 2011 12:00:00 GMT
Content-Type: application/xml; charset=utf-8
In your response header, X-Search-Items-Count indicates the number of items included in the response, while X-Search-Items-Total indicates the total number of items available. If the total exceeds the count, there are additional items that may be fetched. Amending your parameters can result in additional information included in your return.
The response body contains a number of properties relating to your query, including the content type, last modified date, MD5 hash, etc. It is important to note that for any response, all properties associated with the data will be returned – there are no relational or count properties as there is currently no application for object masks in the Object Storage API. Examples of a potential response body are below in json, XML and in plain text.
“last_modified”: “Wed, 19 Oct 2011 21:26:30 GMT”,
“last_modified”: “Mon, 17 Oct 2011 14:31:11 GMT”,
last_modified: Wed, 19 Oct 2011 21:26:30 GMT
container: test name: test_data/3.txt object: test_data/3.txt last_modified: Mon, 17 Oct 2011 14:31:11 GMT content_type: text/plain hash: d41d8cd98f00b204e9800998ecf8427e type: object meta_mtime: 1318861839.0
As mentioned before, all requests can be structured to invoke a specific type of response utilizing the parameters listed in the previous section. When you’re familiar with the functionality of this service, please refer to the Methods page for basic details on this and all methods pertaining to the Object Storage and Search Service APIs.