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.
Read full article from autocomplete - Solrj: how to specify path - Stack Overflow
No comments:
Post a Comment