IndexViewer.SitecoreSearcher.FieldSearch C# (CSharp) Method

FieldSearch() public method

public FieldSearch ( QueryInfo qis, int maxResults ) : SitecoreSearchResultCollection
qis QueryInfo
maxResults int
return SitecoreSearchResultCollection
        public SitecoreSearchResultCollection FieldSearch(QueryInfo[] qis, int maxResults)
        {
            HighResTimer timer = new HighResTimer(true);
            var combinedQuery = new CombinedQuery();
            foreach (var qi in qis)
            {
                var q = GetQuery(qi);
                if (q != null)
                    combinedQuery.Add(q, qi.SitecoreSearchQueryOccurance);
            }

            SearchResultCollection results = null;

            if (combinedQuery.Clauses.Count > 0)
                results = GetSearchHits(combinedQuery, maxResults);

            return results != null
                    ? new SitecoreSearchResultCollection(results, timer.Elapsed())
                    : null;
        }

Usage Example

示例#1
0
        private void DoSearch(bool explain)
        {
            var search = new SitecoreSearcher(SessionManager.Instance.CurrentIndex);
            var infos  = new QueryInfo[]
            {
                new QueryInfo()
                {
                    FieldName      = txtFieldName1.Text,
                    SearchString   = txtSearchWord1.Text,
                    QueryType      = SitecoreQueryType1.Dropdown.SelectedValue,
                    QueryOccurance = QueryOccurance1.Dropdown.SelectedValue
                },
                new QueryInfo()
                {
                    FieldName      = txtFieldName2.Text,
                    SearchString   = txtSearchWord2.Text,
                    QueryType      = SitecoreQueryType2.Dropdown.SelectedValue,
                    QueryOccurance = QueryOccurance2.Dropdown.SelectedValue
                },
                new QueryInfo()
                {
                    FieldName      = txtFieldName3.Text,
                    SearchString   = txtSearchWord3.Text,
                    QueryType      = SitecoreQueryType3.Dropdown.SelectedValue,
                    QueryOccurance = QueryOccurance3.Dropdown.SelectedValue
                }
            };

            if (explain)
            {
                search.Explain = SearchResultGrid.SelectedIndex;
            }

            SessionManager.Instance.SitecoreSearchResult = search.FieldSearch(infos, 200);

            txtExplanation.Text = explain ? search.Explanation.ToString() : string.Empty;
        }
All Usage Examples Of IndexViewer.SitecoreSearcher::FieldSearch