简体   繁体   中英

re-indexing objects with lucene

I have a question still related to my objects in memory. I initialize the model as follows:

model.init("" +
        "<root>" +
        "  <objA nb='5' attrA1='string(val1)' attrA2='int(0)'>" +
        "    <objB nb='8' attrB1='string(val2)' attrB2='int(102)' />" +
        "    <objQ nb='4' attrD3='int(250)' attrD6='string(ok)'  />" +
        "  </objA>" +
        "  <objC nb='1' attrC1='int(1)'/>" +
        "  <objD nb='1' attrD1='string(valx)'/>" +
        "     <objZ nb='8' attrB1='string(val2)' attrB2='int(102)' />" +
        "  <objR nb='4' attrR1='string(val3)' />" +
        "  <mark nb='2' attrR9='string(valeur)'>" +
        "    <ttt name='string(qsa)'>" +
        "      <aaa></aaa>" +
        "    </ttt>" +
        "  </mark>" +
        "</root>");
    rootType = model.getRootType();

Then I index all the elements with their attributes; After that I modify some of them (I change the value of their attributes, I delete some objects, I create some news). How to detect that I modified the object and re-index it with lucene? I'll be really grateful for help.

How to detect that I modified the object

This is generally done by having a "modified" flag that is set to true by all setters and set to false whenever is's indexed.

and re-index it with lucene?

IIRC, Lucene cannot modify indexed documents, so you have to delete and re-add them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM