Filtering

With filtering, you can narrow down your search query by specifying additional filters. The Search API enabled filtering on filters that have been added to your Sooqr instance. You can edit the filters in mySooqr.

Filters are linked to a specific Sooqr instance. Each Sooqr account can contain multiple instances, with different filter settings. When required, this enabled you to create one instance for the default search overlay (as provided by Sooqr) and one instance for your API needs. Both instances work independently, but share the same data and enrichment values (like synonyms and tags).

Specifying filters

You can add filters by using the fq parameter in the Search API:

https://api.sooqr.com/v1/search/100000/1?q=tee&fq[brand]=Sooqr

This example only returns results that have the brand Sooqr.

Multiple values can be specified for one filter. Depending on the setting of the filter, the values will be added as AND or OR.

fq[brand][]=Sooqr&fq[brand][]=BCompany

When AND is used, this will return all results that belong to both Sooqr AND BCompany. When OR is used (the default), this returns all results that belong to Sooqr OR BCompany.

Filter names

When creating filters in mySooqr, you specify the name of the filter. This name is converted into a code, by changing all characters to lower-case and converting all non-characters to underscores. Any underscores at the beginning or end of the code are trimmed.

Some examples:

Filter name Resulting code
Brand brand
Your Price your_price
Strange filter name! strange_filter_name

You can view the filter name when editing the filter settings. Filter names are also used in the faceting component. You can enable faceting to view the names of the default filters.

Filters on fields that do not exist (or are not available in the current instance) are silently ignored.

Impact on facets

When specifying a filter, the facets are updated to include only the results that match the filter value. This will also result in different values for the all and current nodes in a facet.

For example, we specify this filter:

fq[category]=VIP

The category facet is unchanged, but the subcategory facet only shows counts for results that are in the VIP category:

{
   "items":[ ... ],
   "metaData":{
      "numFound":1,
      "maxScore":0.018498365,
      "queryTime":12,
      "start":0,
      "rows":10
   },
   "spellcheck":false,
   "facets":{
      "category":{
         "current":{
            "Men":6,
            "VIP":1
         },
         "all":{
            "Men":6,
            "VIP":1
         }
      },
      "subcategory":{
         "current":{
            "New ArrivalsTees, Knits and Polos":1,
            "Tees, Knits and Polos":1
         },
         "all":{
            "Tees, Knits and Polos":6,
            "New Arrivals":1,
            "New ArrivalsTees, Knits and Polos":1
         }
      }
   }
}