Best way to return ExternalFileField in the results

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Best way to return ExternalFileField in the results

climbingrose
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
Reply | Threaded
Open this post in threaded view
|

Re: Best way to return ExternalFileField in the results

hossman

: 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

Reply | Threaded
Open this post in threaded view
|

Re: Best way to return ExternalFileField in the results

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