grav-plugin-tntsearch icon indicating copy to clipboard operation
grav-plugin-tntsearch copied to clipboard

Multiple filters

Open maliyshock opened this issue 5 years ago • 7 comments

Hey, guys. I need to release search form with: category drop-list, text input named "name" and another one named "profession". All of them should work at the same time and specify the content.

For example imagine a catalog of people with different professions, names, and categories. If type "Jhon" in the field "Name" it is going to rid off all over, but it keeps all "John's" with different professions and categories. If I type "engineer" in profession field, it is going to leave all "Jhon's" with engineer profession.

Does your plugin provide such kind of functionality? Can I work with droplists? Do you have API?

maliyshock avatar Mar 19 '19 13:03 maliyshock

I re-reaad the documentation. I think it could be possible by adding custom fields. But there are no instructions how can I do that? I see the pieces of code in tntsearch.php but I still do not understand what should i do to add one more field

maliyshock avatar Mar 23 '19 09:03 maliyshock

It’s certainly possible to index different fields but the problem is tntsearch (the actual library we use) has no way to filter or specify fields during query. This is something that they say they will add but it’s not there yet. All you can do is get results back then load the objects for each item and further filter manually in php. Far from ideal.

rhukster avatar Mar 23 '19 11:03 rhukster

Yes. What I found is GravTNTSearch.php file, where onTNTSearchQuery event is firing. So I guess I need to make fixes here or maybe make them right before render, as you said when I got result from tnt search. Need to think about it.

Thanks.

maliyshock avatar Mar 23 '19 15:03 maliyshock

Ok. I digged deeply to the core of TNT search. I guess there is no reason to do something with that, because all aechitecture of search engine is specified of 1 word or phrase search.

My case is more like this one https://github.com/ash0080/grav-plugin-cascade-filters

@rhukster there is big API right here https://learn.getgrav.org/15/api May I ask you to give me a hint, where I can find info how to get all Gav pages with specific taxonomies?

maliyshock avatar Mar 24 '19 09:03 maliyshock

My suggestion is to look at the taxonomy plugin. It does just that.

rhukster avatar Mar 24 '19 17:03 rhukster

Ok. May I ask you to share the link? or did you meant this one? https://github.com/getgrav/grav-plugin-taxonomylist

I belive this one should work too https://github.com/ash0080/grav-plugin-cascade-filters

maliyshock avatar Mar 25 '19 06:03 maliyshock

First one was the one I was referring to. Not familiar with second.

rhukster avatar Mar 25 '19 06:03 rhukster