Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 3.24 KB

File metadata and controls

61 lines (40 loc) · 3.24 KB

ADDING NEW DATASET FIELD (including indexing in solr)

Example fields: has_quickcharts - not stored but based on existing resource view of type hdx_hxl_preview

computed - steps marked with computed should be done for dataset properties that are computed (not stored in the db)

saved - steps marked with saved should be done for dataset properties that are stored in the db

indexed - steps marked with indexed should be done for dataset properties that are indexed in solr

filtering - steps marked with filtering should be done for dataset properties which will be used for filters

STEPS

  1. In get.py at the end of package_show and/or resource_show() , Use the _should_manually_load_property_value() helped function to only inject the value in case the value is not already in the package_dict / resource_dict (loaded from solr).

    NOTE: can the (computed) property change without the dataset changing ? Then you probably need to trigger a dataset reindex after the property changes. For an example look here: the resource_view_crreate() function (computed, indexed)

  2. In search_controller.py (indexed, filtering)

    • for the system to identify the http request parameter as a filter it needs to realize this in the _prepare_facets_info() function. Either as part of the checkboxes list OR as part of the default facet titles which come from the get_default_facet_titles() function. NOTE that default facet titles can also be added via a plugin by implementing IFacets
    • also in _prepare_facets_info() function, manually extract the number of results for your checkbox facet (for checkbox facets). This number will be used in the UI
  3. In hdx_search module, in plugin.py (indexed, filtering)

    • transform the HTTP request param (ext_quickcharts) into fq param for solr. In before_search()
    • add translation for the facet (how it should appear in UI). In dataset_facets()
  4. In solr's schema.xml (indexed)

    <field name="has_quickcharts" type="boolean" indexed="true" stored="true"/>
    
  5. In the validation schemas - it should at least be part of the validation show schema for computed. Otherwise, for saved, properties it should be part of the create and update schemas as well. This is done in the hdx_package module, in plugin.py (computed / saved)

  6. For Mixpanel / Google Analytics to track filterting by this property. Change this in google_analytics.js, in the setUpSearchTracking() function (indexed, filtering)

IMPORTANT NOTE FOR SOLR INDEXED FIELDS

  • the schema.xml file needs to end up in the solr container
  • you might need a reindex to be able to filter by the new field