futil-js / contexture-core

Contexture DSL Processor
MIT License
21 stars 1 forks source link

factor out and export tree to filters fn #51

Closed doug-patterson closed 3 years ago

doug-patterson commented 3 years ago

Right now in the course of running a search the contexture JSON is converted to appropriate elastic/mongo/etc stuff by running it through the providers here: https://github.com/smartprocure/contexture/blob/master/src/index.js#L28-L33

This logic is would be useful for those constructing advanced custom types as in some cases one has contexture search JSON to hand (e.g. from a saved search feature) and wants to use it to construct a filter for a node type (to make, for example, a filter that shows you things that don't match previous searches) - but this requires transforming the existing search to something provider-compliant itself as a node's filter is supposed to output a query fragment appropriate for the schema's provider.

Factoring the relevant lines and their dependencies into src/util and exporting appropriately will make this functionality available in custom node types