You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Michael Garski <mg...@myspace-inc.com> on 2010/02/27 19:25:55 UTC

RE: Retrieving Attributes

Andy,

I moved this thread to the user mailing list as it applies to the use rather than development of Lucene.Net.

There is no direct way to access the attributes after indexing, however the use of payloads may fit your needs.

I don't believe the value of the TypeAttribute is encoded in the index in any way, but is intended to be consumed by other TokenFilters in the analysis chain.  You can create a PayloadAttribute in your tokenizer that encodes the value of the TypeAttribute for a give Token, then using a PayloadQuery at search time you can customize your scoring based on the payload values.  In this way you could score matches on 'tags' different from matches on 'words'.

Is that along the lines of what you are looking for?

Michael


-----Original Message-----
From: Andy Pook [mailto:andy.pook@gmail.com]
Sent: Fri 2/26/2010 10:58 PM
To: lucene-net-dev@lucene.apache.org
Subject: Re: Retrieving Attributes
 
I'd like to be able to access the collection/stream of Attributes in a
Field _after_ I've done a search.

The result of a search is a collection of Documents. A Document has
Fields. But I cannot see a simple way of getting at the Attributes of
each Field.

For example: The TypeAttribute has a default value of "word". We have
a custom Tokenizer that adds extra "tokens" with the TypeAttribute set
to "tag".
After a search is done, I'd like to be able to iterate over the
"tokens" in this field and do something with the "tag"s and ignore the
"word"s.

I hope this is more coherent :)

Thanks.

On 26 February 2010 18:40, Michael Garski <mg...@myspace-inc.com> wrote:
> Andy,
>
> Can you give a bit more information on what you are looking to do?  I
> don't quite understand what you are looking to do.
>
> Michael
>
> -----Original Message-----
> From: Andy Pook [mailto:andy.pook@gmail.com]
> Sent: Friday, February 26, 2010 10:37 AM
> To: lucene-net-dev@lucene.apache.org
> Subject: Retrieving Attributes
>
> Attributes are a great thing from the indexing side of things. What
> I'd really like to be able to do is find a document. Then be able to
> retrieve the attributes for each field.
> We are considering storing some custom attributes against some of the
> "tokens" in a field. But we would like to be able to effectively
> reconstitute the TokenStream for a field.
>
> Is that possible? I can't see anything simple that gives access to
> attributes on a per field basis. Any clues?
>
> Thanks in advance,
>
>
>