lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Creating a Custom Query Response Writer
Date Sat, 06 Dec 2014 11:40:19 GMT
Ryan - I just pulled Taming Text off my shelf and refreshed my memory of this custom response

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:

    #foreach($doc in $response.results)

(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
results in this response:

      <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>


> On Dec 6, 2014, at 2:24 AM, Ryan Yacyshyn <> 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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message