ckan / ckanext-scheming

Easy, shareable custom CKAN schemas
Other
85 stars 163 forks source link

Support for automatic "Advanced Search" forms. #178

Open TkTech opened 6 years ago

TkTech commented 6 years ago

This feature adds a new optional field-level flag, make_searchable: True. When this field exists on at least one field an advanced search page will be created. Currently it adds a link under the search bar:

image

This page will render all fields in the schema marked make_searchable, re-using the existing form snippets to render them.

image

If a date pair exists (start_date and end_date by default), a date range selector will be rendered instead using bootstraprap-daterangepicker (with small fixes to make it compatible with all versions of CKAN bootstrap and icons):

image

Hitting search generates a query and redirects to the normal search page. If you got to the advanced search page from a type-specific page (ex: /my-schema) it'll redirect there. Since this tool is just a query builder, normal search plugins, sort, faceting etc all work as expected.

image

The one gotcha is that date fields need to end in _date when using the default CKAN solr schema, since this will cause them to index as TrieDateField.

wardi commented 6 years ago

Very cool!

camfindlay commented 6 years ago

Is there an open PR for this?

TkTech commented 6 years ago

This and all the associated tickets (default field values, group descriptions, hidden fields on resources, etc...) are all part of an ongoing contract. Unfortunately at the moment the main requirement is "finish it yesterday" so these changes are not of reasonable quality, or are very specific to the current contract. I hope to have something merge worthy shortly after the contract is over.

camfindlay commented 6 years ago

Great thanks for that @TkTech - happy to help test once you have something in play.

ted-strauss-K1 commented 6 years ago

Would love to take this feature for a spin. Any update @TkTech ?

camfindlay commented 5 years ago

ping @TkTech just checking in on this... happy to help tidy up code if it's in a "bit of a state" to get this out in the wild for reuse...

edmondchuc commented 5 years ago

@TkTech any update on this?

TkTech commented 5 years ago

I'm currently not receiving any funding so it's at the bottom of the priority list. There's an old, simple version of this that's part of the ckanext-dfo extension that could very easily be ripped out. It has some quirks; The date pair is hard-coded, and select boxes need to be modified before they're rendered to always have a blank default value otherwise you can't exclude them from being searched.

https://github.com/tk-technologies/ckanext-dfo/blob/master/ckanext/dfo/plugins.py#L202 https://github.com/tk-technologies/ckanext-dfo/blob/master/ckanext/dfo/templates/advanced_search.html https://github.com/tk-technologies/ckanext-dfo/tree/master/ckanext/dfo/fanstatic