Ektron Reference |
This section presents an overview of Ektron's Search API. For a more detailed documentation of the Search API and all other APIs, install Ektron's OnTrek sample site and click Developer Reference.
The following webinar is another good resource: http://ektron.com/Resources-And-Tools/Webinars/Screencasts/Ektron-8-5-and-the-Search-Framework-API/
This section also contains the following topics.
Element | Description | Example |
---|---|---|
Search manager See Also: Search Manager |
Includes search method you use to execute search, based on specified criterion Use Criteria object to define query text |
|
Search See Also: |
Simple |
|
Advanced - can create complex queries using expressive syntax |
AdvancedSearchCriteria criteria = new AdvancedSearchCriteria(); criteria.ExpressionTree = SearchContentProperty.Title.Contains("ektron"); |
|
SearchResponse Data Type See Also: To see the list of properties that can be returned, see Properties. |
The type of structure returned when a developer executes a search via the |
s s {
s |
Use to specify an access mode, which defines permissions of the user performing the search.
using Ektron.Cms.Framework.Search;
SearchManager manager=
new SearchManager
SearchManager manager=
new SearchManager(ApiAccessMode.Admin);
SearchManager manager=
new SearchManager(ApiAccessMode.LoggedInUser);
If the user is an admin (see line 5 above), all search results are returned.
If the user is a logged in user (see line 6 above), only search results available to the currently logged in user are returned.
Use Keyword Search to run a simple search query.
KeywordSearchCriteria criteria = new KeywordSearchCriteria();
criteria.QueryText = "ektron";
When stemming is enabled, a search for "run" returns content that contains running, ran, and run, etc.
criteria.EnableStemming = true;
criteria.EnableStemming = false;
You cannot combine an exact phrase search with stemming. For example, the search term "run" does not return content that includes ran
. However, with stemming enabled, the term run
does return content that includes ran
.
NOTE: To use stemming with an Advanced Search, use Inflection Search.
Use Advanced Search to return specific results and run complex queries.
AdvancedSearchCriteria criteria = new AdvancedSearchCriteria();
criteria.ExpressionTree = SearchContentProperty.Title.Contains("ektron");
Below is a complex query example that uses the advanced search class.
criteria.ExpressionTree = SearchContentProperty.Title.Contains("Animal") & !(SearchContentProperty.Title.Contains("dog") | SearchContentProperty.Title.Contains("cat"));
A complex query can use several Operators and Properties.
You can use the following operators in a complex query.
NOTE: Ektron's Search API does not support NEAR searches.
A complex query can use the following properties.
If set to true, search terms have an AND relationship. If set to false, search terms have an OR relationship.
criteria.ImplicitAnd = true;
criteria.ImplicitAnd = false;
Set to true to include suggested results along with regular search results. See Also: Suggested Results
criteria.IncludeSuggestedResults = true;
criteria.IncludeSuggestedResults = false;
Sets a return property's order to ascending or descending.
criteria.OrderBy = new List<OrderData>()
{
new OrderData(SearchContentProperty.Id, OrderDirection.Descending)
};
NOTE: You cannot sort the Description and Highlighted Summary properties.
Sets the number of search results that appear per page.
criteria.PagingInfo.RecordsPerPage = 10;
Allows you to search as a specific user or administrator.
criteria.Permission = Permission.CreateAdministratorPermission();
criteria.Permission = Permission.CreateCurrentUserPermission();
criteria.Permission = Permission.CreateManualUserPermission(1);
In the last example above, the search is executed using the permissions of the user whose ID is specified in parentheses.
The text that is queried.
criteria.QueryText = "Ektron";
The properties for each Search Class you want returned with search results.
criteria.ReturnProperties = new HashSet<PropertyExpression>()
{
SearchContentProperty.Title,
SearchContentProperty.Id,
};
The following table lists the properties available in each class.
Lets you search other scopes in Search Server. Used for Integrated Search. See Also: Using Integrated Search
criteria.Scope = new ScopeExpression("NewScope");
Returns content that contains any word in a synonym set. See Also: Synonym Sets
NOTE: Synonyms are always returned for keyword searches. You cannot turn them off.
Always uses synonyms
criteria.QueryText = "hockey";
criteria.ExpressionTree = SearchContentProperty.Title.Contains("hockey", WordForms.Synonyms);
Returns private content only. See Also: Making Content Private
criteria.ExpressionTree = SearchContentProperty.Private == true;
criteria.ExpressionTree = SearchContentProperty.Private == false;
Search before, after, or between dates to get results.
criteria.ExpressionTree = SearchContentProperty.DateCreated < new DateTime(2006, 2, 22);
criteria.ExpressionTree = SearchContentProperty.DateCreated > new DateTime(2010, 8, 22);
criteria.ExpressionTree = SearchContentProperty.DateCreated < new DateTime(2010, 8, 22) & SearchContentProperty.DateCreated > new DateTime(2009, 2, 22);
An inflection search on "run" returns contains various forms of the word, such as running, ran, and run, etc.
criteria.ExpressionTree = SearchContentProperty.Title.Contains("run", WordForms.Inflections);
If you specify a siteroot/web.config LogLevel
of 3 or higher, then open the Windows Event Viewer, Windows Logs > Application on the Ektron server, you can view the exact query issued by the API to the search server.
You can use either the Framework API or the Search API to retrieve and display search results. The following table contrasts criteria for using both APIs.
Criterion | Content manager of Framework API | Search API |
---|---|---|
Available properties of returned content |
A list of strongly- typed content data objects. They provide access to every property of the ContentData object. |
You specify properties of the SearchResult object to be returned. |
Immediacy | Queries directly against the database, so is immediately available | Search indexes are not updated immediately. So, content added or changed since last crawl is not available. |
Can query against | ContentData properties only | Properties that span types (taxonomy, metadata, content tags, etc.) |
Criteria | Simple criteria using filters. Cannot nest conditions. | Complex criteria using expression trees See Also: Advanced Search |
Ektron Version 8.5, Doc. Rev. 2.0 (Dec. 2011)
Visit the Ektron Dev Center at http://dev.ektron.com 1–866–4–EKTRON
Ektron Documentation, © 2011 Ektron, Inc.