11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

dist<br />

docfreq(field,val)<br />

exists<br />

field<br />

hsin<br />

Return the distance between two<br />

vectors (points) in an n-dimensional<br />

space. Takes in the power, plus two or<br />

more ValueSource instances and<br />

calculates the distances between the<br />

two vectors. Each ValueSource must<br />

be a number. There must be an even<br />

number of ValueSource instances<br />

passed in and the method assumes<br />

that the first half represent the first<br />

vector and the second half represent<br />

the second vector.<br />

Returns the number of documents that<br />

contain the term in the field. This is a<br />

constant (the same value for all<br />

documents in the index).<br />

You can quote the term if it's more<br />

complex, or do parameter substitution<br />

for the term value.<br />

Returns TRUE if any member of the<br />

field exists.<br />

Returns the numeric docValues or<br />

indexed value of the field with the<br />

specified name. In it's simplest (single<br />

argument) form, this function can only<br />

be used on single valued fields, and<br />

can be called using the name of the<br />

field as a string, or for most<br />

conventional field names simply use<br />

the field name by itself with out using<br />

the field(...) syntax.<br />

When using docValues, an optional<br />

2nd argument can be specified to<br />

select the " min" or " max" value of<br />

multivalued fields.<br />

0 is returned for documents without a<br />

value in the field.<br />

The Haversine distance calculates the<br />

distance between two points on a<br />

sphere when traveling along the<br />

sphere. The values must be in radians.<br />

hsin also take a Boolean argument to<br />

specify whether the function should<br />

convert its output to radians.<br />

dist(2, x, y, 0, 0): calculates the<br />

Euclidean distance between (0,0) and (x,y) for<br />

each document<br />

dist(1, x, y, 0, 0): calculates the<br />

Manhattan (taxicab) distance between (0,0) and<br />

(x,y) for each document<br />

dist(2, x,y,z,0,0,0): Euclidean distance<br />

between (0,0,0) and (x,y,z) for each document.<br />

dist(1,x,y,z,e,f,g): Manhattan distance<br />

between (x,y,z) and (e,f,g) where each letter is a<br />

field name<br />

docfreq(text,'solr')<br />

...&defType=func<br />

&q=docfreq(text,$myterm)<br />

&myterm=solr<br />

exists(author) returns TRUE for any<br />

document has a value in the "author" field.<br />

exists(query(price:5.00)) returns TRUE<br />

if "price" matches "5.00".<br />

These 3 examples are all equivalent:<br />

myFloatFieldName<br />

field(myFloatFieldName)<br />

field("myFloatFieldName")<br />

The last form is convinient when your field name<br />

is atypical:<br />

field("my complex float<br />

fieldName")<br />

For multivalued docValues fields:<br />

field(myMultiValuedFloatField,min)<br />

field(myMultiValuedFloatField,max)<br />

hsin(2, true, x, y, 0, 0)<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

271

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!