How Facets works in IndexDen?

What is Facets in search?

Faceted search, also called faceted navigation or faceted browsing, is a technique for accessing information organized according to a faceted classification system, allowing users to explore a collection of information by applying multiple filters.

Adding Facets to documents

Documents already added can be categorized. Categories are a way to partition your index for different dimensions. For every category (the dimension) every document can have multiple values.

Each category is defined by string, and its values are also defined by strings. So for instance, you can define a category named “articleType” and its values can be “camera”, “laptop”, etc… You can have another category called “priceRange” and its values can be “$0 to $49″, “$50 to $100″, etc…

$categories = array('priceRange' => '$0 to $299',
                   'articleType' => array('camera', 'electronics'));
$index->update_categories($docid, $categories);

Facets in a search results

When searching, you will get an attribute in the results called “facets”, and it will contain a dictionary with categories for keys. For each category the value will be another map, with category value as key and occurrences as values. So for instance:

    'matches': 8,
    'results': [ {'docid': 'doc1'}, ... ],
    'facets': {
        'articleType': {
            'camera': 5,
            'laptop': 3,
	    'electronics': 8
        'priceRange': {
            '$0 to $299': 4,
            '$300 to $599': 4

Means that from the matches, 5 are of the “camera” articleType, 3 are “laptop” and 8 are “electronics”. Also, 4 of them all are in the “$0 to $299″ priceRange, and 4 on the “$300 to $599″.

Facets as filters in search query

Then, you can also filter a query by restricting it to a particular set of category/values. For instance the following will only return results that are of the “camera” articleType and also are either in th “$0 to $299″ or “$300 to $599″ price range.

        array('priceRange' => array('$0 to $299', '$300 to $599'),
              'articleType' => array('camera'))

To see how it works Sing up to IndexDen for Free.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>