You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by climbingrose <cl...@gmail.com> on 2008/07/15 18:00:37 UTC

Best way to return ExternalFileField in the results

Hi all,
I've been trying to return a field of type ExternalFileField in the search
result. Upon examining XMLWriter class, it seems like Solr can't do this out
of the box. Therefore, I've tried to hack Solr to enable  this behaviour.
The goal is to call to ExternalFileField.getValueSource(SchemaField
field,QParser parser) in XMLWriter.writeDoc(String name, Document
document,...) method. There are two issues with doing this:

1) I need to create an instance of QParser in writeDoc method. What is the
best way to do this? What kind of overhead of creating a new QParser for
every document returned?

2) I have to modify writeDoc method to include the internal Lucene document
Id because I need it to retrieve the ExternalFileField:

fileField.getValueSource(schemaField,
qparser).getValues(request.getSearcher().getIndexReader()).floatVal(docId)

The immediate affect is that it breaks writeVal() method (because this
method references writeDoc()).

Any comments?

Thanks in advance.


-- 
Regards,

Cuong Hoang

Re: Best way to return ExternalFileField in the results

Posted by Ryan McKinley <ry...@gmail.com>.
>
> In general though i wondering if steping back a bit and modifying your
> request handler to use a SolrDocumentList where you've already  
> flattened
> the ExternalFileField into each SolrDocument would be an easier  
> approach
> -- then you wouldnt' need to modify the ResponseWriter at all.



Consider using a search component at the end of the chain that adds  
fields to your document...  this way things work for any writer (json,  
xml, whatever)

We really should add an example to do this... but in the meantime, a  
good example (though a bit complex) is with the local lucene:
http://sourceforge.net/projects/locallucene/

this adds a calculated distance to each document before it gets passed  
to the writer

Re: Best way to return ExternalFileField in the results

Posted by Chris Hostetter <ho...@fucit.org>.
: I've been trying to return a field of type ExternalFileField in the search
: result. Upon examining XMLWriter class, it seems like Solr can't do this out
: of the box. Therefore, I've tried to hack Solr to enable  this behaviour.
: The goal is to call to ExternalFileField.getValueSource(SchemaField
: field,QParser parser) in XMLWriter.writeDoc(String name, Document
: document,...) method. There are two issues with doing this:

Some of what you're specificly asking about could probably be achieved by 
modifying the XMLWriter constructor to hang on to the SolrCore associated 
with the request.

In general though i wondering if steping back a bit and modifying your 
request handler to use a SolrDocumentList where you've already flattened 
the ExternalFileField into each SolrDocument would be an easier approach 
-- then you wouldnt' need to modify the ResponseWriter at all.




-Hoss