11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

StreamFactory streamFactory = new<br />

StreamFactory().withCollectionZkHost("collection1", zkServer.getZkAddress())<br />

.withStreamFunction("search", Cloud<strong>Solr</strong>Stream.class)<br />

.withStreamFunction("unique", UniqueStream.class)<br />

.withStreamFunction("top", RankStream.class)<br />

.withStreamFunction("group", ReducerStream.class)<br />

.withStreamFunction("parallel", ParallelStream.class);<br />

ParallelStream pstream =<br />

(ParallelStream)streamFactory.constructStream("parallel(collection1,<br />

group(search(collection1, q=\"*:*\", fl=\"id,a_s,a_i,a_f\", sort=\"a_s asc,a_f<br />

asc\", partitionKeys=\"a_s\"), by=\"a_s asc\"), workers=\"2\",<br />

zkHost=\""+zkHost+"\", sort=\"a_s asc\")");<br />

Data Requirements<br />

Because streaming expressions relies on the /export handler, many of the field and field type requirements to<br />

use /export are also requirements for /stream, particularly for sort and fl parameters. Please see the<br />

section Exporting Result Sets for details.<br />

Stream Sources<br />

Stream sources originate streams. There are currently five stream sources available: search, jdbc, facet, stats,<br />

and topic.<br />

search<br />

The search function searches a <strong>Solr</strong>Cloud collection and emits a stream of tuples that match the query. This is<br />

very similar to a standard <strong>Solr</strong> query, and uses many of the same parameters.<br />

This expression allows you to specify a request hander using the qt parameter. By default the /select handler<br />

is used. The /select handler can be used for simple rapid prototyping of expressions. For production, however,<br />

you will most likely want to use the /export handler which is designed to sort and export entire result sets.<br />

The /export handler is not used by default because it has much stricter requirements then the /select handl<br />

er so it's not as easy to get started working with. To read more about the /export handler requirements review<br />

the section Exporting Result Sets.<br />

Parameters<br />

Syntax<br />

collection: (Mandatory) the collection being searched.<br />

q: (Mandatory) The query to perform on the <strong>Solr</strong> index.<br />

fl: (Mandatory) The list of fields to return.<br />

sort: (Mandatory) The sort criteria.<br />

zkHost: Only needs to be defined if the collection being searched is found in a different zkHost than the<br />

local stream handler.<br />

qt: Specifies the query type, or request handler, to use. Set this to /export to work with large result<br />

sets. The default is /select.<br />

rows: (Mandatory with the /select handler) The rows parameter specifies how many rows to return.<br />

This parameter is only needed with the /select handler (which is the default) since the /export handle<br />

r always returns all rows.<br />

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

408

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

Saved successfully!

Ooh no, something went wrong!