More in this section
Forums / General Discussions / Search Results without search fields

Search Results without search fields

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. trevor
    trevor avatar
    0 posts
    03 Dec 2013
    05 Dec 2016
    Link to this post

    Looking at this example


    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