You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by David <zh...@gmail.com> on 2007/01/09 11:55:28 UTC

can Lucene index different amount of attributes to one document?

Hi all:
    I know that we can use doc.add(attr, value) to add attributes to the
document, can we add different amount of attributes to one document?
for example, can this pseudo code  runnable?

public static Document Document(MyObject o)
{
    Document doc = new Document();

    for(i=0; i<o.attribute_len(); i++)
       if(o.attributes(i).value != "") //only if the attribute exist, we
index it.
              doc.add(new Field(o.attrbute(i).name, o.attrbute(i).value)
....);
    }
    return doc;
}

if we can do this, are there any special steps when search the on these
attributes?

Appreciate your help!



-- 
David