Remove Facet from Active Filters -- Lucene

Vote:
 

Hi,

I am using the following code to retrieve results from Lucene. 

 SearchManager manager = new SearchManager(AppContext.Current.ApplicationName);

ICatalogSystem system = CatalogContext.Current;
            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();
            WOWSearchFilterHelper helper = new WOWSearchFilterHelper();
            // Create Entry Criteria         
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteriaTest("", new SearchSort(""));

            // Bind default catalogs if none found
            if (criteria.CatalogNames.Count == 0)
            {
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive &&
                        row.StartDate <= frameworkcontext.current.currentdatetime && row.enddate>= FrameworkContext.Current.CurrentDateTime)
                        {

                            //Change later. 
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }

            criteria.RecordsToRetrieve = ConfigHelper.getCustomerConfigurationInt("defaultThumbnailPageSize");
            //criteria = updatePageNumber(criteria);
            criteria.MarketId = ServiceLocator.Current.GetInstance().GetCurrentMarket().MarketId;
            criteria.Currency = new Currency("USD");

            string sortField = ConfigHelper.getCustomerConfiguration("defaultProductSorting");


            if (sortField != null)
            {

                criteria.Sort = new SearchSort(sortField);

            }
            criteria.IncludeInactive = false;
            criteria.ClassTypes.Clear();
            criteria.ClassTypes.Add("Variation");
            // criteria.Add(
            criteria.IgnoreFilterOnLanguage = true;

  criteria.Add(FacetGroup, new SimpleValue
                    {
                        key = FacetValue.ToLower(),
                        value = FacetValue.ToLower(),
                        locale = "us",
                        Descriptions = new Descriptions()
                        {
                            defaultLocale = "us",
                            Description = new Description[] 
                    { 
                        new Description 
                        { 
                            locale = "us", 
                            Value = LocalizationService.Current.GetString(string.Format("/facets/{0}/{1}", "itemwebcolor", "black"))
                        } 
                    }
                        }
                    });
SearchResults resultstest = null;
                 
                  resultstest = manager.Search(criteria);



I would like to remove the applied filters. I don't see any method to do that in the criteria object. Any help would be approciated. 

Thanks, 

Syed

#114975
Jan 07, 2015 0:16
Vote:
 

Hi,

Unfortunately there's no API to clear the filters. You will need to create a new instance to get empty filters.

Regards.

/Q

#114977
Jan 07, 2015 6:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.