/// <summary> /// Performs a search with a maximum number of results /// </summary> private ISearchResults Search(int maxResults = 500) { var searcher = _searchContext.Searcher; if (searcher == null) { return(EmptySearchResults.Instance); } // capture local var query = Query; if (!string.IsNullOrEmpty(Category)) { // if category is supplied then wrap the query (if there's other queries to wrap!) if (query.Clauses.Count > 0) { query = new BooleanQuery { { query, Occur.MUST } }; } // and then add the category field query as a must var categoryQuery = GetFieldInternalQuery(Providers.LuceneIndex.CategoryFieldName, new ExamineValue(Examineness.Explicit, Category), false); query.Add(categoryQuery, Occur.MUST); } var pagesResults = new LuceneSearchResults(query, SortFields, searcher, maxResults); return(pagesResults); }
/// <summary> /// Performs a search with a maximum number of results /// </summary> private ISearchResults Search(int maxResults = 500) { var searcher = _searchContext.Searcher; if (searcher == null) { return(EmptySearchResults.Instance); } // capture local var query = Query; if (!string.IsNullOrEmpty(Category)) { // rebuild the query var existingClauses = query.Clauses.ToList(); query = new BooleanQuery { // prefix the category field query as a must { GetFieldInternalQuery(Providers.LuceneIndex.CategoryFieldName, new ExamineValue(Examineness.Explicit, Category), false), Occur.MUST } }; // add the ones that we're already existing foreach (var c in existingClauses) { query.Add(c); } } var pagesResults = new LuceneSearchResults(query, SortFields, searcher, maxResults, Selector); return(pagesResults); }
/// <summary> /// Performs a search with a maximum number of results /// </summary> private ISearchResults Search(int maxResults = 500) { var searcher = _searchContext.Searcher; if (searcher == null) { return(EmptySearchResults.Instance); } var pagesResults = new LuceneSearchResults(Query, SortFields, searcher, maxResults); return(pagesResults); }