You can replace them, but it is not pretty. Also, the results are in at least two places in the ResponseBuilder which seems a bit odd.

   //replace the DocList in ResponseBuilder
DocList dl = new DocSlice(docs.offset(), kept, keepDocs, keepScores, docs.matches(), docs.maxScore());
   DocListAndSet dlas = new DocListAndSet();
   dlas.docList = dl;
   dlas.docSet = rb.getResults().docSet;
   rb.setResults(dlas);
   NamedList nl = rb.rsp.getValues();
   nl.setVal(nl.indexOf("response",0),rb.getResults().docList);

-Sean

Erik Hatcher wrote:
Suppose you have a custom SearchComponent that wants to muck with the response built prior? You can replace values in a NamedList, but you can't remove them. Any reason we can't add this to NamedList?

 /**
  * Removes the name/value pair at the specified index.
  * @return the value at the index removed
  */
 public T remove(int idx) {
   int index = (idx<<1);
   nvPairs.remove(index);
return (T)nvPairs.remove(index); // same index, as things shifted in previous remove
 }

It brings up an interesting philosophical question - should a SearchComponent even be allowed to muck with the response at all, other than adding to it? But for now I'm fine with letting components do what they want with the response.

   Erik

Reply via email to