# Searching and Filtering

Once you have built out your landing page, you will want to give your customers ways to filter by category and to search for a specific type of product. To do this, you will use the same **menu-products-demo** index, but you will also use various attributes to filter or search those products.

## Filtering

In order to filter, you will first need to retrieve a list of categories (or facets) that users may want to filter by. You can do this with the following query.

```javascript
const productsIndex = searchClient.initIndex('menu-products-demo');
productsIndex.search('', { filters: 'store_id:5, facets: ['*'] }).then((results) => { 
  // Your code here 
});
```

An example return would be:

```json
{
  kind: { 
    flower: 106, 
    edible: 67, 
    extract: 28, 
    vape: 22, 
    tincture: 12, 
    topical: 11, 
    'pre-roll': 4 
  },
  activities: { 
    'Ease my mind': 14, 
    'Get relief': 6, 
    'Get some sleep': 4, 
    'Hang with friends': 4, 
    'Get Active': 1, 
    'Stimulate my mind': 1 
  }
}
```

After you have a list of categories, you can filter by category by using one of the facets in a search. For example, to filter by "flower" products for the activity "Ease my mind", you would use the following query:

```javascript
const productsIndex = searchClient.initIndex('menu-products-demo');
productsIndex.search('', { 
  filters: 'store_id:5 AND kind:flower AND activities:"Ease my mind"' 
})
  .then((results) => { 
  // Your code here 
});
```

For more information on composing filters, see the [Algolia docs](https://www.algolia.com/doc/api-reference/api-parameters/filters/).

## Searching

In addition to filtering, you may also want to search. To search, you just include a value for the `search` parameter, which would typically be what the customer enters in the search box. For example:

```javascript
const productsIndex = searchClient.initIndex('menu-products-demo');
productsIndex.search('a', { 
  filters: 'store_id:5 AND kind:flower' 
}).then((results) => { 
  // Search all flower product name/descriptions for 'a' 
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.iheartjane.com/jane-docs/implementing-roots/building-your-menu/using-other-technologies/searching-and-filtering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
