Sitecore Search Contrib (new name for the advanced database crawler) is the best option, you just configure its configuration in the application’s configuration folder to tell it the launch database, etc.
Then you can use your API to search folders by template type, where a specific field has a specific value. Here is a sample code.
MultiFieldSearchParam parameters = new MultiFieldSearchParam(); parameters.Database = "web"; parameters.InnerCondition = QueryOccurance.Should; parameters.FullTextQuery = searchTerm; parameters.TemplateIds = array of pipe seperated ID's var refinements = Filters.Select(item => new MultiFieldSearchParam.Refinement(item.Value, item.Key.ToString())).ToList(); parameters.Refinements = refinements;
// Actual search
var returnItems = new List<Item>(); var runner = new QueryRunner(IndexName); var skinnyItems = runner.GetItems(new[] {parameters}); skinnyItems.ForEach(x => returnItems.Add(Database.GetItem(new ItemUri(x.ItemID)))); return returnItems;
Otherwise, you can simply configure web.config for the standard lucene search and use this code to search. (Database to use "web", starting element, etc.)
public Item[] Search(string searchterms) { var children = new List<Item>(); var searchIndx = SearchManager.GetIndex(IndexName); using (var searchContext = searchIndx.CreateSearchContext()) { var ftQuery = new FullTextQuery(searchterms); var hits = searchContext.Search(ftQuery); var results = hits.FetchResults(0, hits.Length); foreach (SearchResult result in results) { if (result.GetObject<Item>() != null) {
source share