Advanced Search #807
-
Is there a way to implement advacned search as in this screenshot ("Refine Search" section)? I'm thinking of some kind of "filter hook" (in Wordpress terminology) that we can override that traverse each search result, assuming they all are pages, and comparing each against its metadata or maybe whatever.yaml. But is that even possible, and if it is how much work will it need programatically? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
@junedtan Thank you for your inquiry. We will get back to you at our earliest convenience. Until then, we invite the community to share their feedback. |
Beta Was this translation helpful? Give feedback.
-
Pinging here.. Anything? After delving into the code more, and if I understand correctly, the search is done client-side using index (kinda full-text search). I don't see anywhere that we can do something like database search (WHERE a_field = 'something') and it's understandable since all pages are static (instead of like php system that might have mysql behind it). With that said, it still might be nice to have this feature. |
Beta Was this translation helpful? Give feedback.
-
@daniel-keller, your publication Masterpieces from the Clowes Collection has an advanced search implemented. Do you have any feedback or advice for @junedtan? |
Beta Was this translation helpful? Give feedback.
-
@junedtan I'm not familiar with v1 of quire (built on 11ty) but the v0 (built on Hugo) came with lunr which is a client side full text search engine. At build time a template called 'search-index.html' iterates over every page you specify in the catalog and outputs a large json file (this is your search index). Another page template creates the actual search page a user would visit. When the search page is visited a GET request fetches the json and loads it into a Search class (which stores the lunr instance). The Search class can be used to query the index. What we did was use lunr full text search to get the initial search results and the iterate over each result to further filter by our "refine search" selection. It looks like Lunr supports adding clauses so it should be possible to build that into the Search class instead of manually filtering the results (I suspect it would be more efficient as well). |
Beta Was this translation helpful? Give feedback.
-
@daniel-keller Thank you so much! I can confirm that your approach also works on v1. As a bonus, I can share a specific URL that directly filters the search page because it's in the URL parameter. To those who are also looking, keep in mind that once a filter is selected the options for the other filter "groups" narrow. In my example above, if I select "Tempus" under Material, option for Type of Text and Date groups become less, adjusting to the found result from Tempus. |
Beta Was this translation helpful? Give feedback.
@junedtan I'm not familiar with v1 of quire (built on 11ty) but the v0 (built on Hugo) came with lunr which is a client side full text search engine.
At build time a template called 'search-index.html' iterates over every page you specify in the catalog and outputs a large json file (this is your search index). Another page template creates the actual search page a user would visit.
When the search page is visited a GET request fetches the json and loads it into a Search class (which stores the lunr instance). The Search class can be used to query the index. What we did was use lunr full text search to get the initial search results and the iterate over each result to further filter by ou…