Loading TOC...
Search Developer's Guide (PDF)

Search Developer's Guide — Chapter 1

Developing Search Applications in MarkLogic Server

This chapter provides an overview of developing search applications in MarkLogic Server, and includes the following sections:

Overview of Search Features in MarkLogic Server

MarkLogic Server includes rich full-text search features. All of the search features are implemented as extension functions available in XQuery. This section provides a brief overview some of the main search features in MarkLogic Server and includes the following parts:

Search API Library Module

The Search API is an XQuery library module designed to simplify creating search applications. The Search API makes it easy to create complex search applications that include faceted navigation, complex and extensible search grammar, and many other search features. The Search API uses the core text search capabilities of MarkLogic Server, but abstracts those APIs from the developer. It is designed to be easy to use in the normal cases, and to be flexible enough to allow complex customization. For details on the Search API, see Search API Library Module.

Built-In Search Functions in the cts and xdmp Namespaces

The core search functionality in MarkLogic Server are a set of built-in XQuery functions to perform full-text search. The cts:search function returns nodes matching a cts:query, which is a composable search query which allows you to perform fine-grained searches. MarkLogic Server is designed to scale to extremely large databases (100s of terabytes or more), and the search operates directly against the database, no matter what the database size. As part of loading a document, full-text indexes are created making arbitrary searches fast. Searches automatically use the indexes, and the xdmp:estimate function and the unfiltered option to cts:search allow you to return results directly out of the indexes in MarkLogic Server.

The built-in search capabilities are designed to be extensible and to work in a large number of applications. For example, the Search API is built using the core text search features such as cts:search, cts:word-query, cts:element-value-query, and so on.

Full XPath Search Support

MarkLogic Server implements the XQuery language, which includes XPath 2.0. XPath expressions are searches which can search across the entire database. For example, consider the following XPath expression:

/my-node/my-child[fn:contains(., "hello")]

This expression searches across the entire database returning my-child nodes that match the expression. XPath expressions take full advantage of the indexes in the database and are designed to be fast.

Lexicon and Range Index-Based APIs

MarkLogic Server has range indexes which index named XML structures such as elements and attributes. There are also range indexes over geospatial values. Each of these range indexes has lexicon APIs associated with them. The lexicon APIs allow you to return values directly from the indexes. Lexicons are very useful in constructing facets and in finding fast counts of element or attribute values. The Search API makes extensive use of the lexicon APIs. For details about lexicons, see Browsing With Lexicons.

Stemming, Wildcard, Spelling, and Much More Functionality

MarkLogic Server search supports a wide range of full-text features. These features include stemming, wildcarded searches, diacritic-sensitive/insensitive searches, case-sensitive/insensitive searches, spelling correction functions, thesaurus functions, geospatial searches, advanced language and collation support, and much more. These features are all designed to build off of each other and work together in an extensible and flexible way.

Alerting API and Built-Ins

You can create applications that notify users when new content is available that matches a predefined query. There is an API to help build these applications as well as a built-in cts:query constructor (cts:reverse-query) and indexing support to build large and scalable alerting applications. For details on alerting applications, see Creating Alerting Applications.

« Table of contents
Next chapter »