boost(attribute, operator, value, factor)

Adds a “boost” subquery to the given ObjSearch instance.

Copy
Scrivito.Obj.all().boost("_objClass", "equals", "Product", 5)

Compares the attribute value(s) with the given value(s) using the operator of this subquery. All CMS objects to which this criterion applies are boosted by the given factor.

Boosting only affects the order of the search results. The search result set is not affected, regardless of the boosting.

Params

  • attribute (String or Array<String>) – Name(s) of the attribute(s) whose values are to be searched. For arrays, the subquery matches if one or more of these attribute values meet this criterion.
  • operator (String) – See Available operators.
  • value (String, Date, Time, Number, Obj, or Array) – The value(s) to compare with the attribute value(s) using the operator of this subquery. For arrays, the subquery matches if the condition is met for at least one of the array elements.
  • factor (Number) – The factor by which the rank of the search hits to which the attribute-operator-value condition applies is to be increased. Must be in the range from 0.1 to 10. A value less than 1 will rank the results lower.

Returns

ObjSearch – Itself

Remarks

This boost query performs value-based boosting. It is also possible to perform attribute-based boosting by using the optional boost parameter of an Obj.where query or an “and” subquery.

Example

Find all CMS objects that contain the word “brush”. Rank hits of the Product class as high as possible (10), and PDF objects as low as possible (0.1):

Copy
Scrivito.Obj.where("*", "contains", "brush")
  .boost("_objClass", "equals", "Product", 10)
  .boost("_objClass", "equals", "PDF", 0.1)