archesproject / arches

Arches is a web platform for creating, managing, & visualizing geospatial data. Arches was inspired by the needs of the Cultural Heritage community, particularly the widespread need of organizations to build & manage cultural heritage inventories
GNU Affero General Public License v3.0
211 stars 142 forks source link

Refactor search filters #11477

Open bferguso opened 1 day ago

bferguso commented 1 day ago

As part of the PR #10999 disucssion, the group identified that the search filter logic should be refactored, and the es_mapping_modifier hook be applied to all search filters, not just the search_term filter. Time constraints stopped these changes from targeting version 7.6.x so it was decided to target 8.0.x for these changes.

Currently the append_dsl method does several things:

  1. Create the DSL
  2. Apply the es_mapping_modifier.add_search_filter method if it is configured
  3. Appends the resultant DSL to the search_query_object

It was determined that these 3 steps should be broken into separate methods within each search filter to allow individual parts of the logic to be overriden. Also, the add_search_filter call should be added to the remaining filters.

High level tasks for this are:

The PR should target version dev/8.0.x

whatisgalen commented 1 day ago

Just to add to this, from a high level:

the append_dsl method on a search filter not only appends dsl to a query object, it generates the dsl according to the logic of the search filter. Given these two distinct functionalities and that the dsl is essentially immutable after it's added to the query object, we proposed that one method generate_dsl be created for a search filter's logic, leaving the append_dsl method to do what its name implies: check for custom index mapping hooks to further modify the dsl, then finally add the dsl to the main query object.