Hello, first a huge thank you for how do you help the community! , I have a question I hope you can help me with.
I need to create the following experience with the search-ui library. I will use "books" to keep it simple.
Books have "categories" and after searching without filters it should show the first 5 results of each category and at the end of each results block a "view more" button.
Then if I press the "view more" button, or I filter by category using facets, then only results related to that category must be displayed.
This categories are fixed and known. My guess is I have to do 1 search per category and render it as different blocks (each category block has its own design) but I have no idea on how to start.
There's a couple of ways this could go. I think the best way to work through this is if you can put a CodeSandbox together to illustrate. Here is an example to start with: search-ui-national-parks-example - CodeSandbox.
Thanks! , I think grouping could do it, but I'm using Site-search and seems like it is not supported or the syntax is different because I'm getting this error:
if "all" records facet or no filter is selected then show grouped results for each category
if any category filter is selected then run a regular search
what I think is I should have a general search provider to handle the general facets and search bar, and inside 5 more providers with searchQuery filters set
then show the parent provider if filter selected, and show all the children providers if no filter selected
is that accurate? , any guidance would be appreciated thanks again for your time
I think you have the general idea. See if you can fork that codesandbox I posted and get something working. I will circle back around to give you a hand with it as soon as I can.
Hello Jason, I tried many things and this is the closest I could get:
the first load looks good, but then the results doesnt update on setSearchTerm event
The other thing I need to achieve is to keep the facets fixed when filtering a category, and only updating it when the search term changes
I tried many trackUrlState true/false combinations without sucess. This page can be called from a global search form so I guess I need this setting in true
Create a top level regular state variable "q"
Pass "setQ" to searchbox onsubmit to set it on each search
Pass "q" to all nested searchproviders to setSearchTerm(q)
Add a useEffect to the nested components on "q" updates
Disable trackurl on nested search providers
I'm not sure if this is the best way to do it but works smoothly
I need facets remaining fixed on filtering (site-search doesnt support disjunctive ) is there a way to do without creating a whole new component? and if thats the only way then whats the approach?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.