Search

Beyond basic retrieval by URI, Corona includes extremely robust support for search-style queries. Results can be sorted by relevance or (soon) by a scalar. Result items can be paged (viewing a small number at a time), returned documents can be snippeted (showing a short content blurb containing the matching terms) and highlighted (to perhaps bold the matching word occurrences).

When executing a search you can choose to retrieve a simple description of the matching documents, or fetch the documents as well, for the sake of efficiency to avoid repeated calls. If you fetch the documents as part of the search, you can request the same subsetting and transformation occur as for singular document retrievals.

Ok, that sounds cool. Let's move on to the endpoints and some sample code.

Search Service: String Query

The Search Service provides a user-friendly way to specify a query as a specially marked-up string similar to those used by Google. This is something a developer could pass directly from a user interface text box to the Corona back-end for execution.

To run a search that retrieves documents with the word, "delicious":

If you only want documents with this word that are in your drinks collection, you can do:

The string query syntax supports many but not all search features exposed by Corona.

Search Service: Structured Query

The Search Service also provides a programmer-friendly way to specify a query as a set of hierarchical query constraints expressed using a JSON encoding. The structured query syntax is highly expressive and supports: free-text search, text containment within a location, text equality to a location, strict value equality at a location, scalar-based range constraints, property-based search, collection-based search, directory-based search, and geospatial search -- or any boolean hierarchical mix of these.

Below are a few very simple examples of the structured query syntax: The following query will return documents where the author key is equal to "Noam Chomsky":

The next query below will return documents where the author key contains "Chomsky":

You can also queries properties and combine queries with boolean logic like:

To run a search that uses the structured syntax:

These examples barely scratch the surface of the long list of controls and features available through the Structured Query Syntax.

Search Configuration Management

These search services work well enough for basic purposes out of the box, but for more useful custom functionality it's often necessary for the developer admin to configure some aspects of the Corona environment. These controls are discussed in the API documentation on the Corona wiki.

CRUD APIs

Next Steps

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.