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.

The predicate above searches for term1 OR term2 in fieldC.<br />

The <strong>Solr</strong> range query syntax can be used as follows:<br />

WHERE fieldC = '[0 TO 100]'<br />

Complex boolean queries can be specified as follows:<br />

WHERE ((fieldC = 'term1' AND fieldA = 'term2') OR (fieldB = 'term3'))<br />

To specify NOT queries, you use the AND NOT syntax as follows:<br />

WHERE (fieldA = 'term1') AND NOT (fieldB = 'term2')<br />

ORDER BY Clause<br />

The ORDER BY clause maps directly to <strong>Solr</strong> fields. Multiple ORDER BY fields and directions are supported.<br />

The score field is accepted in the ORDER BY clause in queries where a limit is specified.<br />

Order by fields are case sensitive.<br />

LIMIT Clause<br />

Limits the result set to the specified size. In the example above the clause LIMIT 100 will limit the result set to<br />

100 records.<br />

There are a few differences to note between limited and unlimited queries:<br />

Limited queries support score in the field list and ORDER BY. Unlimited queries do not.<br />

Limited queries allow any stored field in the field list. Unlimited queries require the fields to be stored as a<br />

DocValues field.<br />

Limited queries allow any indexed field in the ORDER BY list. Unlimited queries require the fields to be<br />

stored as a DocValues field.<br />

SELECT DISTINCT Queries<br />

The SQL interface supports both MapReduce and Facet implementations for SELECT DISTINCT queries.<br />

The MapReduce implementation shuffles tuples to worker nodes where the Distinct operation is performed.<br />

This implementation can perform the Distinct operation over extremely high cardinality fields.<br />

The Facet implementation pushes down the Distinct operation into the search engine using the JSON Facet API.<br />

This implementation is designed for high performance, high QPS scenarios on low-to-moderate cardinality fields.<br />

The aggregationMode parameter is available in the both the JDBC driver and HTTP interface to choose the<br />

underlying implementation ( map_reduce or facet). The SQL syntax is identical for both implementations:<br />

SELECT distinct fieldA as fa, fieldB as fb FROM tableA ORDER BY fa desc, fb desc<br />

Statistics<br />

The SQL interface supports simple statistics calculated on numeric fields. The supported functions are count(*<br />

), min, max, sum, and avg.<br />

Because these functions never require data to be shuffled, the aggregations are pushed down into the search<br />

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

430

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

Saved successfully!

Ooh no, something went wrong!