//<start id="solrj-search-1"/>
SolrQuery queryParams = new SolrQuery();//<co id="solrj-search.co.query"/>
queryParams.setFields("description", "title");//<co id="solrj-search.co.fields"/>
queryParams.setQuery("description:win OR description:all");//<co id="solrj-search.co.terms"/>
queryParams.setRows(10);
QueryResponse response = solr.query(queryParams);//<co id="solrj-search.co.process"/>
assertTrue("response is null and it shouldn't be", response != null);
SolrDocumentList documentList = response.getResults();
System.out.println("Docs: " + documentList);
assertTrue("response.getResults() Size: " + documentList.size() +
" is not: " + 3, documentList.size() == 3);
/*
<calloutlist>
<callout arearefs="solrj-search.co.query"><para>A <classname>SolrQuery</classname> is a easy-to-use container for creating the most common types of queries.</para></callout>
<callout arearefs="solrj-search.co.fields"><para>Set the names of the Fields to be returned in the documents.</para></callout>
<callout arearefs="solrj-search.co.terms"><para>Set the terms to search. The "OR" is a boolean operator which allows one or the other or both to be present in the query.</para></callout>
<callout arearefs="solrj-search.co.process"><para>Submit the query to Solr and get back a <classname>QueryResponse</classname> which contains the results of the search.</para></callout>
</calloutlist>
*/
//<end id="solrj-search-1"/>
//<start id="solrj-search-dismax"/>
queryParams.setQuery("lazy");
queryParams.setParam("defType", "dismax");//<co id="solrj-search.co.dismax"/>
queryParams.set("qf", "title^3 description^10");//<co id="sorlj-search.co.qf"/>
System.out.println("Query: " + queryParams);
response = solr.query(queryParams);
assertTrue("response is null and it shouldn't be", response != null);
documentList = response.getResults();
assertTrue("documentList Size: " + documentList.size() +
" is not: " + 2, documentList.size() == 2);
/*
<calloutlist>
<callout arearefs="solrj-search.co.dismax"><para>Tell Solr to use the <classname>DisMax</classname> Query Parser (named dismax in solrconfig.xml). </para></callout>
<callout arearefs="sorlj-search.co.qf"><para>The DisMax parser will search across the fields given by the "qf" parameter and boosts the terms accordingly.</para></callout>
</calloutlist>
*/
//<end id="solrj-search-dismax"/>
//<start id="solrj-search-facets"/>
queryParams = new SolrQuery();
queryParams.setQuery("description:number");
queryParams.setRows(10);
queryParams.setFacet(true);//<co id="solrj-search-facets-facetOn"/>
queryParams.set("facet.field", "date");//<co id="solrj-search-facets-date"/>
response = solr.query(queryParams);
assertTrue("response is null and it shouldn't be", response != null);
System.out.println("Query: " + queryParams);
documentList = response.getResults();
assertTrue("documentList Size: " + documentList.size() +
" is not: " + 10, documentList.size() == 10);
System.out.println("Facet Response: " + response.getResponse());//<co id="solrj-search-facets-print"/>
/*
<calloutlist>
<callout arearefs="solrj-search-facets-facetOn"><para>Turn on faceting for this query</para></callout>
<callout arearefs="solrj-search-facets-date"><para>Specify the Field to facet on</para></callout>
<callout arearefs="solrj-search-facets-print"><para>Print out the facet information</para></callout>
</calloutlist>
*/
//<end id="solrj-search-facets"/>
//<start id="solrj-search-more-like-this"/>
queryParams = new SolrQuery();
queryParams.setQueryType("/mlt");//<co id="solrj-search.co.mlt"/>
queryParams.setQuery("description:number");
queryParams.set("mlt.match.offset", "0");//<co id="solrj-search.co.mlt.off"/>
queryParams.setRows(1);
queryParams.set("mlt.fl", "description, title");//<co id="solrj-search.co.mlt.fl"/>
response = solr.query(queryParams);
assertTrue("response is null and it shouldn't be", response != null);
SolrDocumentList results = (SolrDocumentList) response.getResponse().get("match");
assertTrue("results Size: " + results.size() + " is not: " + 1,
results.size() == 1);
/*
<calloutlist>
<callout arearefs="solrj-search.co.mlt"><para>Create a "MoreLikeThis" search to find similar documents to the specified document.</para></callout>