SolrJ TermsComponent Support
Posted 10 months, 1 week ago at 9:03 pm. 2 comments
I was working on implementing an auto-complete search box today using Solr 1.4 and the new TermsComponent. TermsComponent is a simple plugin that provides access to Lucene’s term dictionary and is very fast. Being fast and the fact it can hook into a search index makes it perfect for an auto-completion server.
Unfortunately, SolrJ does not support this new functionality yet. Well not officially because you could always parse the raw response object yourself. That is exactly what I was doing until I figured I might as well just add the support to SolrJ. I did, and it was extremely easy.
I added support for TermsComponent parameters and implemented a new TermsComponent response type. The TermsComponent response is parsed into a list of Type objects. The Type object has two methods, getTerm() and getFrequency(). getTerm() returns the suggested term, and getFrequency() returns the frequency of the term appearing in the index.
I have submitted my patch upstream for inclusion into a future version of SolrJ.
Here is the link to the JIRA bug report:
https://issues.apache.org/jira/browse/SOLR-1139
Here is the patch:
https://issues.apache.org/jira/secure/attachment/12407047/SOLR-1139.patch




Great!!! but how can it works in current example Solr 1.3.
TermsComponent is not in Solr 1.3. You need to apply this patch to the latest trunk version of Solr 1.4 for this functionality.