Differences between revisions 6 and 7
Revision 6 as of 2008-06-27 18:59:49
Size: 1336
Editor: p5B25D386
Comment: no useless links
Revision 7 as of 2009-09-20 21:47:46
Size: 1336
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Payloads are byte arrays stored with Terms on Fields.

See https://issues.apache.org/jira/browse/LUCENE-755

Use Cases

Searching For Payloads

Scoring Payloads

Scoring payloads involves overriding the Similarity.scorePayload() method. For example, if one has implemented storing a Float payload, it could be used for scoring in the following way:

  public float scorePayload(byte [] payload, int offset, int length) {
    assert length == 4;
    int accum = ((payload[0+offset]&0xff)) |
                ((payload[1+offset]&0xff)<<8) |
                ((payload[2+offset]&0xff)<<16)  |

    return Float.intBitsToFloat(accum);

Don't forget to activate your Similarity implementation using IndexSearcher.setSimilarity(). Also, note that even then not all queries will actually make use of your method. For example, you will need to use BoostingTermQuery instead of TermQuery. QueryParser currently (Lucene 2.3.2) always uses TermQuery and you will need to extend QueryParser and overwrite getFieldQuery().

Note, that is just one possible way of scoring a payload. Payloads are application specific. For example payload Token Filters see the payload package in the contrib/Analysis module.

Payloads (last edited 2009-09-20 21:47:46 by localhost)