Skip to content

Auto complete searches in OData

Auto completion in OData searches refers to capability to search for partial strings that match up against multiple fields in the underlying provider. The *_Summary property of the OData entities enables auto-completion in OData searches and is often a combination of multiple database fields .Auto completion is related specifically to the *_Summary (Elaborating text) of the entity.

The auto completion functionality is available in OData by entering a search criteria on the *_Summary property.

There are two mechanisms in the underlying provider for accomplishing auto completion functionality:

  • Freetext search: Freetext searches are by definition case insensitive and performs automatically partial matches. The entities File, Record and Document use the freetext form.
  • Regular Search: Regular searching is performed in all other places. Not all entities are enabled for regular searches.

Example:

Search Files based on the text “Test” (freetext)

var query =
from f in context.Files
where f.Summary == "Test"
select new File { ID = f.ID };
// Equivalent Url: Files?$filter=Summary eq 'Test'&$select=ID

Example:

Search Employees based on the text “John” (regular case insensitive partial match)

var query =
from e in context.Employees
where e.Summary.ToLower().Contains("john")
select new Employee { ID = e.ID, Summary = e.Summary };
// Equivalent Url: Employees?$filter=substringof('john', tolower(Summary))&$select=ID,Summary

Entities that support criterias on *_Summary properties