lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry White <>
Subject How can I use a byte array as a Lucene index field?
Date Wed, 23 Sep 2015 14:17:03 GMT
I'm using Lucene 4.10.3. (I plan to upgrade soon but need to fix an issue
on this version today).

I switched a Lucene index from using string document ids to byte arrays.
The problem I'm having is that the system no longer finds documents by
their id. I *suspect* this is because the lucene code is not doing an
Array.equals(), but rather a standard equals(). This is the code to add the

    Document doc = new Document();
    byte[] key = indexData.getKey().toByteArray();
    doc.add(new StoredField(DOCUMENT_PRIMARY_KEY, new BytesRef(key)));

And this is the code to delete the document. The delete fails because the
document is not found (although it does exist in the index).

    void prepareDelete(byte[] documentId) throws IOException {
        Term term =
                new Term(DOCUMENT_PRIMARY_KEY, new BytesRef(documentId));

By comparing the output of the print statements, I've determined that the
keys are the same (in the sense that they contain the same bytes), but they
do not share identity.

Thanks very much for any and all assistance.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message