Thx to you two. Just in case anybody else is trying to do "this". The following SolrJ code corresponds to the http request GET http://localhost:8983/solr/solrpedia/suggest?q=atmo of "Solr in Action" (chapter 10): ... SolrServer server = new HttpSolrServer("http://localhost:8983/solr/solrpedia"); SolrQuery query = new SolrQuery( "atmo" ); query.setRequestHandler( "/suggest" ); QueryResponse queryresponse = server.query( query ); ... queryresponse.getSpellCheckResponse().getSuggestions(); ...
-----Ursprüngliche Nachricht----- Von: Shawn Heisey [mailto:s...@elyograg.org] Gesendet: Donnerstag, 25. September 2014 17:37 An: solr-user@lucene.apache.org Betreff: Re: /suggest through SolrJ? On 9/25/2014 8:43 AM, Erick Erickson wrote: > You can call anything from SolrJ that you can call from a URL. > SolrJ has lots of convenience stuff to set particular parameters, > parse the response, etc... But in the end it's communicating with Solr > via a URL. > > Take a look at something like SolrQuery for instance. It has a nice > command setFacetPrefix. Here's the entire method: > > public SolrQuery setFacetPrefix( String field, String prefix ) { > this.set( FacetParams.FACET_PREFIX, prefix ); > return this; > } > > which is really > this.set( "facet.prefix", prefix ); All it's really doing is > setting a SolrParams key/value pair which is equivalent to > &facet.prefix=blahblah on a URL. > > As I remember, there's a "setPath" method that you can use to set the > destination for the request to "suggest" (or maybe "/suggest"). It's > something like that. Yes, like Erick says, just use SolrQuery for most accesses to Solr on arbitrary URL paths with arbitrary URL parameters. The "set" method is how you include those parameters. The SolrQuery method Erick was talking about at the end of his email is setRequestHandler(String), and you would set that to "/suggest". Full disclosure about what this method actually does: it also sets the "qt" parameter, but with the modern example Solr config, the qt parameter doesn't do anything -- you must actually change the URL path on the request, which this method will do if the value starts with a forward slash. Thanks, Shawn