[ 
https://issues.apache.org/jira/browse/SOLR-7097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14328574#comment-14328574
 ] 

Noble Paul commented on SOLR-7097:
----------------------------------

documents are always streamed out . So we only handle one document at a time. 
So , Solr cannot give a mechanism to modify previous docs.

However, it is possible for the transformer to cache docs . 

The API does not let you do that today , it is pretty rigid.

The current method is like this
{code:java}
 public abstract void transform(SolrDocument doc, int docid) throws IOException;
{code}
If it was like the following

{code:java}
 public abstract List<SolrDocument> transform(SolrDocument doc, int docid) 
throws IOException;
{code}
Then you could return an empty list when you want to cache stuff. or you can 
spit out multiple docs all at once.

But the challenge is , your {{rows}} parameter will be totally screwed. you may 
specify rows=10 and you may get 100 in return or none at all




> Update other Document in DocTransformer
> ---------------------------------------
>
>                 Key: SOLR-7097
>                 URL: https://issues.apache.org/jira/browse/SOLR-7097
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: jefferyyuan
>            Priority: Minor
>              Labels: searcher, transformers
>
> Solr DocTransformer is good, but it only allows us to change current 
> document: add or remove, update fields.
> It would be great if we can update other document(previous especially) , or 
> better we can delete doc(especially useful during test) or add doc in 
> DocTransformer.
> User case:
> We can use flat group mode(group.main=true) to put parent and child close to 
> each other(parent first), then we can use DocTransformer to update parent 
> document when access its child document.
> Some thought about Implementation:
> org.apache.solr.response.TextResponseWriter.writeDocuments(String, 
> ResultContext, ReturnFields)
> when cachMode=true, in the for loop, after transform, we can store the 
> solrdoc in a list, write these doc at the end.
> cachMode = req.getParams().getBool("cachMode", false);
> SolrDocument[] cachedDocs = new SolrDocument[sz];
> for (int i = 0; i < sz; i++) {
>  SolrDocument sdoc = toSolrDocument(doc);
>  if (transformer != null) {
>   transformer.transform(sdoc, id);
>  }
>  if(cachMode)
>  {
>     cachedDocs[i] = sdoc;
>  }
>  else{
>     writeSolrDocument( null, sdoc, returnFields, i );
>  }
>   
> }
> if (transformer != null) {
>  transformer.setContext(null);
> }
> if(cachMode) {
>  for (int i = 0; i < sz; i++) {
>   writeSolrDocument(null, cachedDocs[i], returnFields, i);
>  }
> }
> writeEndDocumentList();



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to