lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mitchell, Erica" <>
Subject MultiFieldQueryParser question
Date Fri, 08 Feb 2008 14:53:37 GMT

I'm trying to build up an index of fields to represent an

So I'm adding these fields to my lucene doc

doc.add(new Field(NAME, cls.getName(), Field.Store.YES,
doc.add(new Field(IDENTITY, obj.eGet(cls.getEIDAttribute()).toString(),
Field.Store.YES, Field.Index.TOKENIZED));

I then get the Eattributes from my Eobject and I want to add these to
the index

 for (Object o : cls.getEAllAttributes()) {
            if (o instanceof EAttribute) {
                EAttribute attribute = (EAttribute) o;
                String attributeName = attribute.getName();
       	    Strung attributeValue = obj.eGet(attribute).toString();

		    doc.add(new Field(attributeName , attributeValue ,
Field.Store.YES, Field.Index.TOKENIZED));

This is how I'm searching all fields for text containing "aaa"

        String[] searchFields = {IDENTITY, NAME, ATTRIBUTE}; 
        MultiFieldQueryParser multiparser = new
MultiFieldQueryParser(searchFields, new StandardAnalyzer()); 
        Query query = multiparser.parse("aaa*");
        Hits hits =;

So using Luke I can see my index contains information like this

<id> aaa2
<id> aaa1

<guid> aaa2
<guid> pi4

<name> attribute
<name> poliyinstance

I'd like my query to return both the id fields and the guids.
The problem is the guid is added to the index by virtue of my
doc.addField(attributeName, attributeValue ...) 

So for the query to return the attributes correctly, I'd need to pass in
the attributeName which I don't have.

Is the answer simply that I should be keeping an array of the
attributeName's returned, and passing these as part of the String[] into

Thanks a million,

IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message