/// <summary> /// Searches the specified query. /// </summary> /// <param name="query">The query.</param> /// <param name="database">The database.</param> /// <returns>Returns collection of items</returns> public override IEnumerable<Item> Search(Query query, Database database) { Assert.ArgumentNotNull(query, "query"); Assert.ArgumentNotNull(database, "database"); string indexName = string.IsNullOrEmpty(this.IndexName) ? "products" : this.IndexName; IEnumerable<Item> items; LuceneQueryBuilder builder = new LuceneQueryBuilder(query, this.Database); BooleanQuery luceneQuery = builder.BuildResultQuery(); using (IndexSearchContext context = SearchManager.GetIndex(indexName).CreateSearchContext()) { this.AddDecorations(luceneQuery, database.Name); PreparedQuery pq = new PreparedQuery(luceneQuery); ////Sitecore Query parser does not allow to use IDs in field values. SearchHits hits = context.Search(pq, int.MaxValue); items = this.GetSearchResultItems(hits); } return items; }
/// <summary> /// Searches the specified query. /// </summary> /// <param name="query">The query.</param> /// <param name="database">The database.</param> /// <returns>Returns collection of items</returns> public override IEnumerable <Item> Search(Query query, Database database) { Assert.ArgumentNotNull(query, "query"); Assert.ArgumentNotNull(database, "database"); string indexName = string.IsNullOrEmpty(this.IndexName) ? "products" : this.IndexName; IEnumerable <Item> items; LuceneQueryBuilder builder = new LuceneQueryBuilder(query, this.Database); BooleanQuery luceneQuery = builder.BuildResultQuery(); using (IndexSearchContext context = SearchManager.GetIndex(indexName).CreateSearchContext()) { this.AddDecorations(luceneQuery, database.Name); PreparedQuery pq = new PreparedQuery(luceneQuery); ////Sitecore Query parser does not allow to use IDs in field values. SearchHits hits = context.Search(pq, int.MaxValue); items = this.GetSearchResultItems(hits); } return(items); }