OpenEugene / little-help-book-web

Human service resource guide powered by White Bird Clinic
MIT License
6 stars 4 forks source link

Search action #127

Open ArthurSmid opened 3 years ago

ArthurSmid commented 3 years ago

The recent work that Colin did to create a JSON of the Airtable data might be useful for the search function: https://github.com/OpenEugene/little-help-book-web/blob/develop/table-of-contents-style-homepage/src/cachedInlineTables.js

It'd be great if any queries entered could search through fields for Name, Description, Address, City, and Hours. Possibly the most essential fields would be the name and provider descriptions, for example, "pregnant" a potential search query, and that word is in the short description for First Way of Eugene:

Provides pregnancy tests, ultrasound, baby and toddler clothes, baby wipes, diapers, all without charge. Pregnant women can be signed up for insurance and receive referrals for health services.

If there happened to be only one provider description with the word "pregnant" then it seems like the result could go directly to the provider's page, for example, the First Way of Eugene provider page: https://little-help-book.netlify.app/table-of-contents-style-homepage/provider.html?place=rec5Spty79kdK1x0P

But in the event that more than one provider includes the word "pregnant" in their description, then results would be displayed like the contents of the subcategory page, with all the relevant providers listed: https://little-help-book.netlify.app/table-of-contents-style-homepage/subcategory.html?category=recYtWC2H01X9ZQeZ&subcategory=recUaACoGqNcegY54&city=NA

It might be simpler to just return all results structured like the contents on the subcategory page, even if only one entry matches the search query. And so, it's fine to have all search results returned in the manner of the contents on a subcategory page.

For example, this subcategory page for "Clothing" (https://little-help-book.netlify.app/table-of-contents-style-homepage/subcategory.html?category=recYtWC2H01X9ZQeZ&subcategory=recHpBkQDFLBUagtg&city=NA) but imagine someone had typed in "free shoes" and then the provider tiles for any that matched would appear.

Hmm. If someone typed "shoes" and all results that included the words clothing or clothes would appear, that seems like a more evolved kind of search feature because it's associative rather than just a direct word match. I don't know what's possible with the resources we have, but given the powerful search engines people are used to on the internet, I think they might expect more from our search feature than would be possible for us. For that reason, when someone clicks the search icon, there's a bit of text to help clarify: "Type keywords and press Search" and hopefully, by mentioning "keywords" they will try typing specific words that might land on it. Say they want "shoes" and they type shoes and nothing returns if the word shoes isn't in the data, but then they type "clothes" and some results are there.

It'd be great if the search results returned with the search query terms they entered displayed at top where the page name is, bold text up top, in the case of the Clothing page, for example, if someone typed in free shoes the words free shoes (without quotes) would be up top in the same style as the Clothing page name, followed by the search results.

colindavey commented 3 years ago

I would think search should access the tables through the data access layer (dal). Whether the cache is used or not depends on the setting of the dal's useCache variable, with the search function unaware of whether the cache is used or not.

markdav-is commented 3 years ago

If you are looking for JS to filter the list, I'd suggest a search results page using Map() Reduce() and Filter() to limit the results. Here's an example: https://medium.com/poka-techblog/simplify-your-javascript-use-map-reduce-and-filter-bd02c593cc2d