+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Search Results without search fields

Search Results without search fields

1 posts, 0 answered
  1. Tre
    Tre avatar
    0 posts
    Registered:
    03 Dec 2013
    05 Dec 2016
    Link to this post

    Looking at this example

    http://docs.sitefinity.com/81/for-developers-customize-search-results-by-overriding-the-searchresults-class

     

    Can we do a search without specifying the search fields so that we can add new search fields in the index without having to do a code deployment to pick up new properties?

     

     

    var control = this.control;
                var service = Telerik.Sitefinity.Services.ServiceBus.ResolveService<ISearchService>();
                var queryBuilder = ObjectFactory.Resolve<IQueryBuilder>();

                var searchQuery = queryBuilder.BuildQuery(query, control.SearchFields);
                searchQuery.IndexName = catalogue;
                searchQuery.Skip = skip;
                searchQuery.Take = take;
                searchQuery.OrderBy = null;
                searchQuery.HighlightedFields = control.HighlightedFields;

                // Contains the default filter - by current language
                var currentFilter = searchQuery.Filter;
                var myDatesFilter = new SearchFilter();
                myDatesFilter.Operator = QueryOperator.And;

                // Here we add a clause, that only results for the last 10 days will be displayed
                myDatesFilter.AddClause(new SearchFilterClause("PublicationDate", DateTime.UtcNow.AddDays(-10), FilterOperator.Greater));

                // Persist the language filter, if exists
                if (currentFilter != null) myDatesFilter.AddFilter(currentFilter);
                searchQuery.Filter = myDatesFilter;

    IResultSet result = service.Search(searchQuery);

1 posts, 0 answered