You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2008/05/09 22:18:12 UTC
[Solr Wiki] Update of "FunctionQuery" by umar
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The following page has been changed by umar:
http://wiki.apache.org/solr/FunctionQuery
The comment on the change is:
added an example for usage of function query
------------------------------------------------------------------------------
max(x,c) returns the max of another function and a constant. Useful for "bottoming out" another function at some constant.
Example Syntax: '''max(myfield,0)'''
+ === General Example ===
+ To give more idea about teh use of the function query, suppose index stores dimensionsin metres '''x''', '''y''','''z''' of different some hypothetical boxes with arbitary names stored in field '''boxname'''.
+ suppose we want to search for box matching name ''findbox'' but ranked according to volumes of boxes, the query params would be: '''q=boxname:findbox _val_:"product(product(x,y),z)"'''.
+ Although this will rank the results based on volumes but in order to get the computed volume you will need to add parameter '''&fl=*, score''' where '''score''' will contain the resultant volume.
+ Suppose you also have a field containing weight of the box as 'weight', then to sort by the density of the box and return the value of the density in score you query should be:
+
+
+ '''http ://localhost:8983/solr/select/?q=boxname:findbox _val_:"div(weight,product(product(x,y),z))"&fl=boxname x y z weight score'''
+
+