The Search API provides a model for indexing documents that contain structured data. You can search an index, and organize and present search results. The API supports partial text matching on string fields. Documents and indexes are saved in a separate persistent store optimized for search operations. The Search API can index any number of documents. However, an index search can find no more than 10,000 matching documents. The App Engine Datastore may be more appropriate for applications that need to retrieve very large result sets.
- Overview
- Documents and fields
- Creating a document
- Working with an index
- Index schemas
- Viewing indexes in the Admin Console
- Search API quotas
- Search API pricing
Overview
The Search API is based on four main concepts: documents, indexes, queries, and results.
Documents
A document is an object with a unique ID and a list of fields containing user data. Each field has a name and a type. There are several types of fields, identified by the kinds of values they contain:
- Atom Field - an indivisible character string
- Text Field - a plain text string that can be searched word by word
- HTML Field - a string that contains HTML markup tags, only the text outside the markup tags can be searched
- Number Field - a floating point number
-
Time Field - a
time.Time
value (stored with millisecond precision) - Geopoint Field - a data object with latitude and longitude coordinates
The maximum size of a document is 1 MB.
Indexes
An index stores documents for retrieval. You can retrieve a single document by its ID, a range of documents with consecutive IDs, or all the documents in an index. You can also search an index to retrieve documents that satisfy given criteria on fields and their values, specified as a query string. You can manage groups of documents by putting them into separate indexes.
There is no limit to the number of documents in an index, or the number of indexes you can use. However, the total size of all the documents in a single index cannot be more than 10GB.
Queries
To search an index, you construct a query, which has a query string, and possibly some additional options. A query string specifies conditions for the values of one or more document fields. When you search an index you get back only those documents in the index with fields that satisfy the query.
The simplest query, sometimes called a "global search" is a string that contains only field values. This search uses a string that searches for documents that contain the words "rose" and "water":
index.Search(c, "rose water", nil)
This one searches for documents with date fields that contain the date July 4, 1776, or text fields that include the string "1776-07-04":
index.Search(c, "1776-07-04", nil)
A query string can also be more specific. It can contain one or more terms, each naming a field and a constraint on the field's value. The exact form of a term depends on the type of the field. For instance, assuming there is a text field called "Product", and a number field called "Price", here's a query string with two terms:
// search for documents with pianos that cost less than $5000
index.Search(c, "Product = piano AND Price < 5000", nil)
Query options are not yet available in the Go runtime.