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 YonikSeeley.
The comment on this change is: change 1.5 to 3.1, clarify that "function" generally means
single valued.
http://wiki.apache.org/solr/FunctionQuery?action=diff&rev1=68&rev2=69

1. A Field  See "fieldvalue" below. Also see notes later on multivalued/vector fields.
1. Another Function
1. <!> [[Solr4.0]] A parameter substitution: $arg, where arg is another function
in the request.
 * Example request: {{{q={!func}add($v1,$v2)&v1=sqrt(popularity)&v2=100.0}}}
+ * Example request: {{{q={!func}add($v1,$v2)&v1=sqrt(popularity)&v2=100.0}}}
+
+ Unless otherwise indicated, the term "function" or "function query" refer to normal functions
that produce at most one value per document (i.e not vector functions)
= Using FunctionQuery =
There are a few ways to use FunctionQuery from Solr's HTTP interface:
@@ 32, +34 @@
= Sort By Function =
 <!> [[Solr1.5]] (https://issues.apache.org/jira/browse/SOLR1297)
+ <!> [[Solr3.1]] (https://issues.apache.org/jira/browse/SOLR1297)
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:
{{{
@@ 48, +50 @@
. SolrQuerySyntax Example: '''_val_:1.5'''
== literal ==
 <!> [[Solr1.5]] String literals. Warning: not all functions can work with string
literals.
+ <!> [[Solr3.1]] String literals. Warning: not all functions can work with string
literals.
. Signature: literal(value), "value", 'value'
. Example: 'foo', literal("this is a literal")
@@ 220, +222 @@
Also see http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_boost_the_score_of_newer_documents
== Math.* ==
 <!> [[Solr1.5]]
+ <!> [[Solr3.1]]
Most Java Math functions are now supported, including:
@@ 252, +254 @@
See the java.util.Math javadocs for more details.
== dist ==
 [[Solr1.5]] See: https://issues.apache.org/jira/browse/SOLR1302
+ [[Solr3.1]] See: https://issues.apache.org/jira/browse/SOLR1302
Return the Distance between two Vectors (points) in an ndimensional space. See http://en.wikipedia.org/wiki/Lp_space
for more information. Takes in the power, plus two or more !ValueSource instances and calculates
the distances between the two vectors. Each !ValueSource must be a number. There must be
an even number of !ValueSource instances passed in and the method assumes that the first half
represent the first vector and the second half represent the second vector.
@@ 279, +281 @@
1. dist(1,x,y,z,e,f,g)  Euclidean distance between (x,y,z) and (e,f,g) where each letter
is a field name
== sqedist  Squared Euclidean Distance ==
 [[Solr1.5]] See: https://issues.apache.org/jira/browse/SOLR1302
+ [[Solr3.1]] See: https://issues.apache.org/jira/browse/SOLR1302
Similar to the dist() function, the Sq. Euclidean distance calculates the 2norm (Euclidean
distance) but does not take the square root, thus saving a fairly expensive operation. It
is often the case that applications that care about Euclidean distance do not need the actual
distance, but instead can use the square of the distance. See also dist(). There must be
an even number of !ValueSource instances passed in and the method assumes that the first half
represent the first vector and the second half represent the second vector.
@@ 288, +290 @@
Example: sqedist(x_td, y_td, 0, 0)
== hsin, ghhsin  Haversine Formula ==
 [[Solr1.5]] See: https://issues.apache.org/jira/browse/SOLR1302
+ [[Solr3.1]] See: https://issues.apache.org/jira/browse/SOLR1302
The Haversine distance calculates the distance between two points on a sphere when traveling
along the sphere. In other words, it's the Great Circle distance. See http://en.wikipedia.org/wiki/Greatcircle_distance.
In the case of !GeohashHaversine, the sources must be a geohash value.
@@ 307, +309 @@
Example: geohash(lat, lon)
== strdist ==
 [[Solr1.5]]
+ [[Solr3.1]]
Calculate the distance between two strings. Uses the Lucene spell checker StringDistance
interface and supports all of the implementations available in that package, plus allows applications
to plug in their own via Solr's resource loading capabilities.
@@ 345, +347 @@
= Vector Functions =
 Until [[Solr1.5]], all functions were single valued. Since [[Solr1.5]], 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.
+ 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 ==
