You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Andreas Sewe <an...@codetrails.com> on 2016/07/28 10:35:47 UTC

Order of StoredFieldVisitor.*Field calls?

Hi,

I am currently looking at the StoredFieldVisitor visitor to make the
conversion from Documents into my own search results more efficient. My
current code looks like this:

  Document doc = searcher.doc(id);
  ISearchResult result = convert(doc);

My convert(Document) method creates, depending on a dedicated "type"
field of the Document, one of several different subtypes of
ISearchResult and then copies over the Document's field data into the
newly created object.

Obviously, going through an intermediate Document object is wasteful.
Hence, I want to use a StoredFieldVisitor that directly produces
ISearchResults. In order to create the correct subtype of ISearchResult,
however, I would need so assurance that my "type" field is visited
first. Is this possible?

Best wishes,

Andreas

-- 
Codetrails GmbH
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Phone: +49-6151-276-7092
Mobile: +49-170-811-3791
http://www.codetrails.com/

Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Order of StoredFieldVisitor.*Field calls?

Posted by Michael McCandless <lu...@mikemccandless.com>.
I suspect the visitor will be called in order that the stored fields were
originally added to the Document at indexing time, but I'm not sure whether
this is guaranteed behavior across Lucene releases.

Mike McCandless

http://blog.mikemccandless.com

On Thu, Jul 28, 2016 at 6:35 AM, Andreas Sewe <an...@codetrails.com>
wrote:

> Hi,
>
> I am currently looking at the StoredFieldVisitor visitor to make the
> conversion from Documents into my own search results more efficient. My
> current code looks like this:
>
>   Document doc = searcher.doc(id);
>   ISearchResult result = convert(doc);
>
> My convert(Document) method creates, depending on a dedicated "type"
> field of the Document, one of several different subtypes of
> ISearchResult and then copies over the Document's field data into the
> newly created object.
>
> Obviously, going through an intermediate Document object is wasteful.
> Hence, I want to use a StoredFieldVisitor that directly produces
> ISearchResults. In order to create the correct subtype of ISearchResult,
> however, I would need so assurance that my "type" field is visited
> first. Is this possible?
>
> Best wishes,
>
> Andreas
>
> --
> Codetrails GmbH
> The knowledge transfer company
>
> Robert-Bosch-Str. 7, 64293 Darmstadt
> Phone: +49-6151-276-7092
> Mobile: +49-170-811-3791
> http://www.codetrails.com/
>
> Managing Director: Dr. Marcel Bruch
> Handelsregister: Darmstadt HRB 91940
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>