codeforamerica / ohana-web-search

A mobile-friendly website for finding human and social services in your community
http://ohana-web-search-demo.herokuapp.com
BSD 3-Clause "New" or "Revised" License
69 stars 74 forks source link

Return sub-categories when searching by taxonomy terms #815

Closed cderenburger closed 9 years ago

cderenburger commented 9 years ago

I am not sure if this belongs here or at https://github.com/codeforamerica/ohana-api

I use the AIRS taxonomy for indexing services. I can search by taxonomy terms by searching by 'category[]=Soup Kitchens' where a service has an exact match for the code.

What I need to do is be able to search the children of a term. Below is an example branch of codes.

lv 1 Basic Needs lv 2 - Food lv 3 - - Summer Food Service Programs lv 3 - - Soup Kitchens lv 3 - - Low Cost Meals lv 3 - - Home Delivered Meals lv 3 - - Congregate Meals . . .

In our database we code only to the lowest level of the taxonomy, but we can search higher. For example I might index one service as offering "Congregate Meals" and another as "Soup Kitchens", but a search for lv 2 "Food" includes all of the lower-level lv 3 categories.

While I 'could' add each higher-level term above the lowest level to work with the current search, but some location records already show 60+ codes for the services offered at the location. I submit that it makes sense to search child categories by default.

I've only recently started teaching myself RoR, so I'm not sure where or how to add this feature. Any advice? I do want to thank you as well for the great documentation on these projects.

Thanks, Cory

monfresh commented 9 years ago

Hi Cory (@cderenburger). Thanks for using Ohana. This issue fits better in Ohana API, but we can discuss it here first to see where the problem lies. From your description of the problem, it sounds like you haven't set up your taxonomy properly. Ohana expects a taxonomy to be hierarchical, and when it's set up properly, the admin interface will automatically add parent categories when selecting a sub category. More details are available in our Taxonomy Basics Wiki article.

When the taxonomy is set up properly, it's impossible to tag a service with only a sub category. The parent categories all the way up the chain are automatically included. You can try it out in our demo admin interface.

To confirm my suspicion, could you please send a screenshot of your categories section in your admin interface with a sub category checkbox checked?

greggish commented 9 years ago

@cderenburger it would be great to hear about your plans for using Ohana, and I'd be glad to share a bit about the Open Referral initiative. I'm at bloom@openreferral.org - hope to hear from you...

cderenburger commented 9 years ago

Unfortunately I've not been able to access the admin area. I'm using the virtual machine, everything but the admin area has worked. It reports 'bad password' and I've tried running $ script/users to reset the users but no luck. Since I'm just exporting I haven't worried about getting the admin interface up and running.

Back to the api, when I run GET http://localhost:8080/api/categories/BD-5000/children The api does list out the child categories associated with the code.

When the taxonomy is set up properly, it's impossible to tag a service with only a sub category. The parent categories all the way up the chain are automatically included.

So here the higher level codes are always included. I should be able to export my data to include the higher level codes. This should solve this issue.

Is there a place to ask questions rather than opening an issue? I may need to ask for clarification on a few other things as I go along.

Thanks @monfresh

@greggish My intention is to just export from our database into Ohana to act as a public search website as our current providers public site is not very user friendly, and their api is limited. I was hoping that Ohana would give me the flexibility I need to provide more specialized searching for various contracts that could potentially come our way.

greggish commented 9 years ago

@cderenburger that sounds great. Perhaps at some point in the coming weeks we could chat by phone or skype. I know of a couple of prospective stakeholders in King County who might be interested in supporting your work on this, and there may other ways that we can be helpful to you all.

monfresh commented 9 years ago

@cderenburger If the documentation is not clear, feel free to open an issue. We don't really have another place for project-related questions, so GitHub is fine for now.

As for the admin interface, is it possible that you are trying to sign in on the wrong page? The API has two portals that look similar. The one at the root is the developer portal, and should say "Ohana API Developers" in the top left. The admin interface is at the /admin path and should say "Ohana API Admin" in the top left. You should be able to sign in with username masteradmin@ohanapi.org and password ohanatest.

cderenburger commented 9 years ago

Adding the parent categories has fixed the category[]= issue. Also thanks for pointing out that I needed to go to the /admin path, that is what I had been doing wrong.