lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "FunctionQuery" by GrantIngersoll
Date Thu, 17 Feb 2011 15:54:20 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "FunctionQuery" page has been changed by GrantIngersoll.
http://wiki.apache.org/solr/FunctionQuery?action=diff&rev1=70&rev2=71

--------------------------------------------------

  <<TableOfContents>>
  
  = What is a Function? =
- 
  A function can be:
+ 
   1. A Constant (numeric or string literal) - See "constant" and "literal" below.
   1. A Field - See "fieldvalue" below. Also see notes later on multivalued/vector fields.
   1. Another Function
@@ -23, +23 @@

   1. Set '''func''' as the default query type, e.g. {{{defType=func&q=log(foo)}}}
   1. Use a parameter that has an explicit type of FunctionQuery, such as [[DisMaxQParserPlugin]]'s
'''bf''' (boost function) parameter, or extended dismax '''boost''' parameter (multiplicative
boost).
    * NOTE: the '''bf''' parameter actually takes a list of function queries separated by
whitespace and each with an optional boost.  Make sure to eliminate any internal whitespace
in single function queries when using '''bf'''.
-   * Example: {{{q=foo&bf="ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3"}}}

+   * Example: {{{q=foo&bf="ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3"}}}
  
  See SolrPlugins#ValueSourceParser for information on how to hook in your own FunctionQuery.
  
@@ -33, +33 @@

  There is currently no infix parser - functions must be expressed as function calls (e.g.
sum(a,b) instead of a+b)
  
  = Sort By Function =
- 
  <!> [[Solr3.1]]
  
  It is now possible to sort the results by the output of a function.  For instance, if an
application wanted to sort by distance, it could do:
+ 
  {{{
  http://localhost:8983/solr/select?q=*:*&sort=dist(2, point1, point2) desc
  }}}
- 
- 
  = Available Functions =
  == constant ==
  <!> [[Solr1.3]] Floating point constants.
@@ -174, +172 @@

  
   . Example Syntax: '''max(myfield,0)'''
  
+ [[Solr3.2]][[Solr4.0]] See https://issues.apache.org/jira/browse/SOLR-2371
+ max no longer requires one value to be a constant, as in '''max(fieldA,fieldB)''' or '''max(0,fieldA)'''
  
+ == min ==
+ [[Solr3.2]][[Solr4.0]] See https://issues.apache.org/jira/browse/SOLR-2371
+ min(x,y) returns the minimum of two functions.
+ 
+  . Example Syntax: '''min(fieldA,fieldB)''', '''min(fieldA, 37)'''
+ 
+ 
+  
  == ms ==
  <!> [[Solr1.4]]
  
@@ -185, +193 @@

  Arguments may be numerically indexed date fields such as !TrieDate (recommended field type
for dates since Solr 1.4), or date math (examples in SolrQuerySyntax) based on a constant
date or '''NOW'''.
  
  Things other than these will _not_ work as arguments. For example, you cannot currently
use:
+ 
   * "classic", non-numerically indexed date fields (i.e. fields backed by DateField or LegacyDateField
classes)
   * other functions (e.g. map, sum, etc.)
  
@@ -298, +307 @@

  
  '''Values must be in Radians'''.  See the rad() function. Please note Haversine distance
has known problems with antipodal values.  See the Wikipedia page for details.
  
+ Signature: hsin(radius, true|false, x1,y1,x2,y2), ghhsin(radius, hash1, hash2) The boolean
value determines whether hsin will automatically convert the input values from degrees to
radians.
- Signature: hsin(radius, true|false, x1,y1,x2,y2), ghhsin(radius, hash1, hash2)
- The boolean value determines whether hsin will automatically convert the input values from
degrees to radians.
  
  Example: hsin(2, true, x, y, 0, 0) - Calculate the haversine distance between the lat/lon
0, 0 on a sphere of radius 2 and the values in field x,y, converting the values automatically
to radians.
  
@@ -321, +329 @@

   . Example: strdist("SOLR",id,edit)
  
  The third argument is the name of the distance measure to use.  The abbreviations stand
for:
+ 
   1. jw - Jaro-Winkler
   1. edit - Levenstein or Edit distance
   1. ngram - The NGramDistance, if specified, can optionally pass in the ngram size too.
 Default is 2.
   1. FQN - Fully Qualified class Name for an implementation of the StringDistance interface.
 Must have a no-arg constructor.
-  
  
  == top ==
  <!> [[Solr1.4]] Causes it's function query argument to derive it's values from the
top-level IndexReader containing all parts of an index.  For example, the ordinal of a value
in a single segment will be different from the ordinal of that same value in the complete
index.  The ord() and rord() functions implicitly use top() and hence ord(foo) is equivalent
to top(ord(foo)).
@@ -348, +356 @@

  {{{
  http://localhost:8983/solr/select/?q=boxname:findbox+_val_:"div(weight,product(product(x,y),z))"&fl=boxname,x,y,z,weight,score
  }}}
- 
  = Vector Functions =
- 
  Until [[Solr3.1]], all functions were single valued.  Since [[Solr31.]], it is now possible
for functions to use multiple values as part of a function calculation.  There is not yet
support for fields that have more than one token, but it is possible to aggregate multiple
single value fields into a vector.
  
  == vector ==
- 
  Takes in one or more single sources (i.e. all the stuff above) and creates a vector source.
  
  Signature: vector(x,y,z)
  
  === Distances ===
- 
  dist(), hsine() and sqedist() can work with vector functions (implemented in Java via !MultiValueSource
)
  

Mime
View raw message