Solr Typeahead feature implementation

I am trying to implement type-ahead feature in my search engine using solr(index core name is "people") and have done the following configuration changes in my solrconfig.xml:

<queryResponseWriter name="tah"
<requestHandler name="/type-ahead"
    <lst name="defaults">
        <str name="wt">tah</str>
        <str name="defType">dismax</str>
        <str name="qf"> wordPrefix^1.0 </str>

My schema file fields

<field name="wordPrefix" type="prefix" />
<copyField source="name" dest="wordPrefix"/>

Below is the content of my com.sample.TypeAheadResponseWriter

public class TypeAheadResponseWriter implements QueryResponseWriter {
    private Set<String> fields;

    public String getContentType(SolrQueryRequest req, SolrQueryResponse solrQueryResponse) {
        return "text/html;charset=UTF-8";

    public void init(NamedList n) {
        fields = new HashSet<String>();

    public void write(Writer w, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
        SolrIndexSearcher searcher = req.getSearcher();
        NamedList nl = rsp.getValues();
        int sz = nl.size();
        for (int li = 0; li < sz; li++) {
            Object val = nl.getVal(li);
            if (val instanceof DocList) {
                DocList dl = (DocList) val;
                DocIterator iterator = dl.iterator();
                while (iterator.hasNext()) {
                    int id = iterator.nextDoc();
                    Document doc = searcher.doc(id, fields);
                    String name = doc.get("name");
                    w.append("<li>" + name + "</li>n");

But I am not getting any response on hitting URL


But when I change the value of wt to json in my solrconfig.xml, it do get the response. I tried everything I possibly could. Not sure where I am going wrong.


I think, trouble located here:

if (val instanceof DocList) {

Let's look at last lines from QueryComponent.process:

ResultContext ctx = new ResultContext(); = rb.getResults().docList;
ctx.query = rb.getQuery();
rsp.add("response", ctx);

So DocList is located in rsp.getValues().get("response").docs

Need Your Help

Tuleap - Cannot create report

report tuleap

I have installed Tuleap 7.9 on a CentOS6 virtual machine. I have succeed to create a new projet, and I tried to installed the Agile dashboard.

Problems using rxjava-android

android gradle android-gradle

I'm trying tu use Rxjava in a project that I have with gradle. I dont have any compile error, but when I run the project my app crash.