Adding numeric metadata constraints via a hook script

Managed by | Updated .


This article discusses how to add a numerical metadata constraint via a hook script. Numerical metadata constraints are set using special CGI parameters, and these are pre-processed populating other parts of the data model (before the pre_process hook script runs) so special steps are required to set the values in the hook script.

Pre-process hook script

The pre-process hook script is used to set the numerical constraint, but adding the parameters to both the inputParameterMap and the additionalParameters elements within the data model.


// Add a numeric metadata constraint.  Restrict results to items when the price metadata field 
// contains a value greater than or equal to 50
// This is equivalent to adding a CGI parameter &ge_price=50 to the query string.

transaction.question.inputParameterMap["ge_price"] = "50"
transaction.question.additionalParameters["ge_price"] = ["50"]
Was this artcle helpful?