Ryan - I just pulled Taming Text off my shelf and refreshed my memory of this 
custom response writer.  

While having a custom writer is a neat example, it’s unnecessary for that 
particular functionality.  Solr has a built-in templatable response writer, the 
VelocityResponseWriter.  You can see it in action for a similar suggest feature 
in Solr’s example /browse interface (type “ip” and wait a second in the /browse 
UI with the sample data indexed).  In there is a little bit of jQuery 
autocomplete plugin usage that calls back to the /terms handler, using a 
suggest.vm template (in conf/velocity).  The difference with the Taming Text 
example is that it is returns stored fields of a standard search rather than 
just raw terms; with a little adjustment you can get basically the same thing 
as TT.  Leveraging the Solr example (v4.10.2 for me here), I created a 
conf/velocity/typeahead.vm:

  <ul>
    #foreach($doc in $response.results)
      <li>$doc.name</li>
    #end
  </ul>

(the docs in the example data have a ‘name’ field)

This request  
http://localhost:8983/solr/collection1/select?q=name%3Aip*&wt=velocity&v.template=typeahead
 
<http://localhost:8983/solr/collection1/select?q=name:ip*&wt=velocity&v.template=typeahead>
 results in this response:

  <ul>
      <li>Belkin Mobile Power Cord for iPod w/ Dock</li>
      <li>iPod & iPod Mini USB 2.0 Cable</li>
      <li>Apple 60 GB iPod with Video Playback Black</li>
  </ul>

        Erik


> On Dec 6, 2014, at 2:24 AM, Ryan Yacyshyn <ryan.yacys...@gmail.com> wrote:
> 
> Hey Everyone,
> 
> I'm a little stuck on building a custom query response writer. I want to
> create a response writer similar to the one explained in the book, Taming
> Text, on the TypeAheadResponseWriter. I know I need to implement the
> QueryResponseWriter, but I'm not sure where to find the Solr JAR files I
> need to include. Where can I find these?
> 
> Thanks,
> Ryan

Reply via email to