I'm trying to use the TermsComponent to implement autosuggest with Solrj, but I don't see how to specify the path (i.e. the /terms
portion of http://localhost:8983/solr/terms
).
How can I specify the path using Solrj?
Bonus: is there a way to specify multiple fields for the terms.fl
param?
Thanks
Here we go:
SolrQuery query = new SolrQuery();
query.setParam(CommonParams.QT, "/terms");
query.setParam(TermsParams.TERMS, true);
query.setParam(TermsParams.TERMS_LIMIT, "10");
query.setParam(TermsParams.TERMS_FIELD, "title", "description"); // or whatever fields you want
query.setParam(TermsParams.TERMS_PREFIX_STR, typedInput);
This is assuming that you have the TermsComponent wired in at "/terms"; the default solrconfig.xml has it there.
And for the bonus: you can add multiple fields simply by adding multiple strings for TERMS_FIELD
(or multiple URL &terms.fl=foo
params).
Thank you Mauricio, for pointing me in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With