Solr 1.4 supports this new feature:

http://wiki.apache.org/solr/TermsComponent
https://issues.apache.org/jira/browse/SOLR-877

It would seem like this component would be useful for some of the autocomplete needs of project_solr, but so far I don't see a way to apply any filtering to the generated terms - i.e. unless project nodes have a distinct field, it might not be that useful.

Note - also - the wiki page references a tutorial including this
/autocomplete path, but I cannot find any trace of such. I was able
to get results similar to the examples on the wiki page by adding the
following to solrconfig.xml:

 <searchComponent name="terms"
class="org.apache.solr.handler.component.TermsComponent" />
 <!-- a request handler utilizing the elevator component -->
 <requestHandler name="/autocomplete" class="solr.SearchHandler"
startup="lazy">
   <lst name="defaults">
     <str name="echoParams">explicit</str>
   </lst>
   <arr name="components">
     <str>terms</str>
   </arr>
 </requestHandler>

Comments

janusman’s picture

Just noting that in order to get the list of terms the Solr request URL for the partial string "foo" could be something like:

http://example.com:8983/solr/autocomplete?terms=true&terms.fl=body&terms.lower=foo&terms.upper=fooz

The response in this case is:

<response>

  <lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">1</int>
  
  <lst name="params">
    <str name="terms">true</str>
    <str name="terms.upper">fooz</str>
    <str name="terms.fl">body</str>
    <str name="terms.lower">foo</str>
    </lst>
  </lst>

  <lst name="terms">
    <lst name="body">
      <int name="food">8</int>
      <int name="fool">1</int>
      <int name="footbal">1</int>
      <int name="footer">1</int>
    </lst>
  </lst>
  
</response>
janusman’s picture

BTW #394076: Autocomplete in search box powered by Solr has a patch for apache solr that implements this.