#community-help

Facet Searching and Filtering in Typesense

TLDR David asked about how to perform a facet search and filter specific categories in documents. Kishore Nallan guided them on how to accomplish it and also mentioned curation based on filter_by is available in recent RC builds. This solution was also confirmed by Jason.

Powered by Struct AI

1

1

12
14mo
Solved
Join the chat
Oct 19, 2022 (14 months ago)
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
08:16 AM
How do I preform a facet search for all documents against a type like this?
{
  "facet": true,
  "index": true,
  "infix": false,
  "locale": "",
  "name": "categories.lvl0",
  "optional": false,
  "sort": false,
  "type": "string[]"
}
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:46 AM
You should be able to facet by just sending "facet_by": "categories.lvl0" as a search param. What problem are you facing?
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
08:59 AM
Kishore Nallan That's for responding 🙂 I want all the documents where lvl0 is Furniture { "categories.lvl0": ["Furniture"] } for example, or all the documents where lvl1 is Sofas, like { "categories.lvl0": ["Furniture"], "categories.lvl1": ["Sofas", "Poufs"] }
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:00 AM
That's filtering and you can do that via filter_by , e.g. filter_by=categories.lvl0:= Furniture
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
09:02 AM
Ok, thanks! Side-question: Do you recommend the whole { "categories.lvl0": ["Furniture"], "categories.lvl1": ["Furniture > Sofas", "Furniture > Poufs"] } dance where you add the parent and a seperator into the lvls? I know Algolia recommends that
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:07 AM
I think our examples also follow the same pattern, tagging Jason who can maybe suggest if there's a better way here.
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
01:05 PM
Another related question :thinking_face: Kishore Nallan Jason I'm now using this query q=*&filter_by=categories.lvl1:= Furniture > Shelving and storage&per_page=32 for a category page, and it works great. But how does the curation work here? From what I can tell curation is only for the query (* in this case) and not for the filter? If i want to move item id 123 to the top of the Furniture > Shelving and storage page and document id 456 to the top of the Furniture > Tables and side tables page, how do I do that?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:07 PM
Curation based on filter_by rules is available on recent RC builds. See: https://github.com/typesense/typesense/issues/536#issuecomment-1238746446
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
01:09 PM
Since it is on a RC build, it's not available through the Typesense Cloud UI then?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:14 PM
We can upgrade from our end, you can schedule an upgrade from the UI.

1

01:14
Kishore Nallan
01:14 PM
Or you can also email us if there is no specific time where the upgrade should happen.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:21 PM
> https://typesense-community.slack.com/archives/C01P749MET0/p1666170133558749?thread_ts=1666167377.380949&cid=C01P749MET0
If you’re using Instantsearch, then this is the format that those widgets work with

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Fixing Multiple Document Retrieval in Typesense

Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.

4

26
26mo
Solved

Issue with Categories Facet in Typesense InstantSearch Adapter

David encountered an issue with not being able to add fields categories to facets. Kishore Nallan assisted in troubleshooting. After some back and forth communication, David finally managed to resolve the issue.

1

8
13mo
Solved

User-Specific Tagging and Filtering in UI

bnfd asked for the best way to create user-specific tags available on the UI. Jason suggested using personalized filters and creating a separate collection for each user's movies. The duo clarified the use of 'tags' in schemas and the refinementList widget in instantsearch. They also discussed various approaches to import and search large document collections.

1

46
29mo
Solved

Querying with Typesense-Js and Handling Null Values

michtio was querying using typesense-js and receiving fewer results than expected. Kishore Nallan suggested using different query parameters. Further discussion led to the handling of 'null' values and filtering syntax in the search queries. The thread ended with Jason offering migration support from Algolia to Typesense.

4

39
17mo
Solved

Query on Facet Values, `max_facet_values` , and `facet_query_num_typos`.

Jan asked about sorting facet values, managing `max_facet_values` and issues with `facet_query_num_typos`. Jason clarified the details on instantsearch widget handling of `max_facet_values` and identified a bug on the Typesense Server. Jason suggested a solution to the sorting issue.

2

23
1mo
Solved