QueryPropositionManager
The QueryPropositionManager provides access to query the index of a configured search provider.
Namespace
Ektron.Cms.Framework.Search.QueryPropositionManager
Constructors
Constructors
QueryPropositionManager()
QueryPropositionManager(ApiAccessMode)
Properties
Properties
QueryPropositionService
. Gets the underlying query proposition service supporting the configured search provider.
Methods
Methods
- GetQueryCompletions
GetQueryCompletions(String,Int32,QueryCompletionSortOrder)
. Gets query completions as directed by the specified query completion request parameters.GetQueryCompletions(QueryCompletionRequest).
Gets query completions as directed by the specified query completion request parameters.- GetQuerySuggestions
GetQuerySuggestions(QuerySuggestionRequest).
Return Query suggestions based on request parameters.
GetQueryCompletions. Gets query completions as directed by the specified query completion request parameters.
GetQueryCompletions
GetQueryCompletions(System.String,System.Int32)
Return query suggestions based on request parameters.
Parameters
searchText
. Search termmaxCount
. Suggested maximum count of query completions for the search engine. Actual counts may vary according to term availability as determined by the search engines internal algorithms.
Returns
Query completions.
.aspx code snippet
<div> <ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxSearchTextLabel" AssociatedControlID="uxSearchText" CssClass="span-4 last" runat="server" Text="Search Text:" /> <ektronUI:Autocomplete ID="uxSearchText" CssClass="span-6" runat="server" ValidationGroup="RegisterValidationGroup" /> </li> <li class="clearfix"> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="Search"></ektronUI:Button> </li> </ol> </div>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using Ektron.Cms; using Ektron.Cms.Framework.Content; using Ektron.Cms.Framework.UI.Controls.EktronUI; using Ektron.Cms.Framework.UI.Controls.EktronUI.Widgets; using Ektron.Cms.Search; using Ektron.Cms.Search.Expressions; using Ektron.Site.Developer;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { if (!String.IsNullOrWhiteSpace(uxSearchText.Text)) { KeywordSearchCriteria criteria = new KeywordSearchCriteria(); criteria.OrderBy = new List<OrderData>() { new OrderData(SearchContentProperty.Rank, OrderDirection.Descending) }; criteria.PagingInfo = new PagingInfo(10); criteria.PagingInfo.CurrentPage = 1; criteria.ReturnProperties = new HashSet<PropertyExpression>() { SearchContentProperty.Id, SearchContentProperty.Title, SearchContentProperty.QuickLink }; ContentManager contentManager = new ContentManager(); Expression expressionTree = Ektron.Cms.Search.SearchType.IsNonUserContent(); if (contentManager.RequestInformation.ContentLanguage == 0) { expressionTree &= SearchContentProperty.Language.EqualTo(contentManager.RequestInformation.DefaultContentLanguage); } else if (contentManager.RequestInformation.ContentLanguage > 0) { expressionTree &= SearchContentProperty.Language.EqualTo(contentManager.RequestInformation.ContentLanguage); } criteria.ExpressionTree = expressionTree; //Pass in query text criteria.QueryText = uxSearchText.Text; ISearchManager manager = ObjectFactory.GetSearchManager(); SearchResponseData response = manager.Search(criteria); uxSearchResultView.Visible = true; uxSearchResultView.DataSource = response.Results; uxSearchResultView.DataBind(); uxPageMultiView.SetActiveView(uxViewMessage); if (response.PagingInfo.TotalRecords > 0) { string pagingInfo = "Total # of Results = " + response.PagingInfo.TotalRecords.ToString() + "<br />"; pagingInfo += "Total # of Pages = " + response.PagingInfo.TotalPages.ToString() + "<br />"; pagingInfo += "Displaying search result " + response.PagingInfo.StartRow.ToString() + " through " + response.PagingInfo.EndRow.ToString(); MessageUtilities.UpdateMessage(uxMessage, pagingInfo, Message.DisplayModes.Success); } } else { MessageUtilities.UpdateMessage(uxMessage, "Please enter a search text", Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }
GetQuerySuggestions. Return Query suggestions based on request parameters.
GetQuerySuggestions
GetQuerySuggestions(System.String,System.Int32)
Return Query suggestions based on request parameters.
Parameters
searchText
. Query text.maxCount
. Maximum number of query completions requested.
Returns
Query suggestions.
Remarks
All Providers
. The terms returned for any request are subject to the internal algorithms of the configured search provider, the quality of the content in the index, and the configuration of any supporting dictionaries.The maximum count parameter is a suggestion for the search engine. Actual counts may vary according to term availability, as determined by the search engine's internal algorithms.
.aspx code snippet
<div> <ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxSearchTextLabel" AssociatedControlID="uxSearchText" CssClass="span-4 last" runat="server" Text="Search Text:" /> <ektronUI:Autocomplete ID="uxSearchText" CssClass="span-6" runat="server" ValidationGroup="RegisterValidationGroup" /> </li> <li class="clearfix"> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="Search"></ektronUI:Button> </li> </ol> </div>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using Ektron.Cms; using Ektron.Cms.Framework.Content; using Ektron.Cms.Framework.UI.Controls.EktronUI; using Ektron.Cms.Framework.UI.Controls.EktronUI.Widgets; using Ektron.Cms.Search; using Ektron.Cms.Search.Expressions; using Ektron.Site.Developer;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { if (!String.IsNullOrWhiteSpace(uxSearchText.Text)) { KeywordSearchCriteria criteria = new KeywordSearchCriteria(); criteria.OrderBy = new List<OrderData>() { new OrderData(SearchContentProperty.Rank, OrderDirection.Descending) }; criteria.PagingInfo = new PagingInfo(10); criteria.PagingInfo.CurrentPage = 1; criteria.ReturnProperties = new HashSet<PropertyExpression>() { SearchContentProperty.Id, SearchContentProperty.Title, SearchContentProperty.QuickLink }; ContentManager contentManager = new ContentManager(); Expression expressionTree = Ektron.Cms.Search.SearchType.IsNonUserContent(); if (contentManager.RequestInformation.ContentLanguage == 0) { expressionTree &= SearchContentProperty.Language.EqualTo(contentManager.RequestInformation.DefaultContentLanguage); } else if (contentManager.RequestInformation.ContentLanguage > 0) { expressionTree &= SearchContentProperty.Language.EqualTo(contentManager.RequestInformation.ContentLanguage); } criteria.ExpressionTree = expressionTree; //Pass in query text criteria.QueryText = uxSearchText.Text; ISearchManager manager = ObjectFactory.GetSearchManager(); SearchResponseData response = manager.Search(criteria); uxSearchResultView.Visible = true; uxSearchResultView.DataSource = response.Results; uxSearchResultView.DataBind(); uxPageMultiView.SetActiveView(uxViewMessage); if (response.PagingInfo.TotalRecords > 0) { string pagingInfo = "Total # of Results = " + response.PagingInfo.TotalRecords.ToString() + "<br />"; pagingInfo += "Total # of Pages = " + response.PagingInfo.TotalPages.ToString() + "<br />"; pagingInfo += "Displaying search result " + response.PagingInfo.StartRow.ToString() + " through " + response.PagingInfo.EndRow.ToString(); MessageUtilities.UpdateMessage(uxMessage, pagingInfo, Message.DisplayModes.Success); } } else { MessageUtilities.UpdateMessage(uxMessage, "Please enter a search text", Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }