How to add item category to a filter/facet that doesn't have any data yet?

So the idea is always show all categories even the category doesn’t have any related data yet.

My current implementation is I was made the city category index separately from the datas index, and tried to inject the category before the instantsearch perform search, but the issue it was break the history state from the search, so when we was searched and searched again, and go back to previous page, we would get wrong data because the instantsearch not records the external city category.

Is there another way how to handle this?

Hi @gilbertgoes11

I’m not sure I completely followed what your are trying to accomplish, but my understanding is that your manipulating the query for searches and it is not getting recorded in the local search history.

I wonder if it makes sense in this case to inject your category information into the search box, similar to what we do for query suggestions, so it is stored as local state in the browser as well.

There’s an example of this pattern here: