Nadav Har'El wrote:

Hi Michael,

For some uses (e.g., faceted search), one wants to add a payload to each
document, not per position for some text field. In the faceted search example,
we could use payloads to encode the list of facets that each document
belongs to. For this, with the old API, you could have added a fixed term
to an untokenized field, add add a payload to that entire untokenized field.

With the new API, it seems doing this is much more difficult and requires
writing some sort of new Analyzer - one that will do the regular analysis
that I want for the regulr fields, and add the payload to the one specific
field that lists the facets.
Am I understanding correctly? Or am I missing a better way to do this?

Thanks,
Nadav.

Hi Nadav,

you are referring to the first design I proposed in
http://www.gossamer-threads.com/lists/lucene/java-dev/37409

In that design I indeed had a method
public Field(String name, String value, Store store, Index index, TermVector termVector, Payload payload);

which makes it easily possible to add a Payload without having to implement an Analyzer. The Field API is already complex, that's the reason why I removed this method in the new payloads version. And in this thread we're also discussing to make the Token API more flexible, so that it will be easier in the future to add more functionality.

As you pointed out it is still possible to have per-doc payloads. You need an analyzer which adds just one Token with payload to a specific field for each doc. I understand that this code would be quite ugly on the app side. A more elegant solution might be LUCENE-580. With that patch you are able to add pre-analyzed fields (i. e. TokenStreams) to a Document without having to use an analyzer. You could use a TokenStream implementation that emits only one Token. That would be a very simple class. Another benefit is that whenever we add more functionality to Token, we would not have to also provide another Field constructor. Do you think this makes sense? I haven't looked at the LUCENE-580 code and probably it needs to be updated since it is some months old, but I like the idea.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to