Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 59569 invoked from network); 8 Feb 2008 17:43:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2008 17:43:17 -0000 Received: (qmail 16318 invoked by uid 500); 8 Feb 2008 17:43:05 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 15896 invoked by uid 500); 8 Feb 2008 17:43:03 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 15885 invoked by uid 99); 8 Feb 2008 17:43:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 09:43:03 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of erica.mitchell@iona.com designates 62.221.12.55 as permitted sender) Received: from [62.221.12.55] (HELO emea-mx1.iona.com) (62.221.12.55) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 17:42:48 +0000 X-IronPort-AV: E=Sophos;i="4.25,322,1199664000"; d="scan'208";a="1153486" Received: from emea-ems1.ionaglobal.com ([10.2.1.125]) by emea-mx1.iona.com with ESMTP; 08 Feb 2008 17:42:41 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: MultiFieldQueryParser question Date: Fri, 8 Feb 2008 17:42:40 -0000 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: MultiFieldQueryParser question Thread-Index: AchqVhSQ32ufYdbhSRqX2NDeDoXSBAACpwkgAAYN/rA= From: "Mitchell, Erica" To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Solved it, for those who were wondering where I went wrong.... I've built up an ArrayList while adding my attributes to a lucence doc and updated my multiquerySearchParser to contain all these attribute names as follows Object[] attributeNamesArray =3D (Object[]) attrList.toArray(); String[] otherFieldsArray =3D {IDENTITY, NAME}; String[] searchFields =3D new String[attributeNamesArray.length + otherFieldsArray.length]; =20 =20 System.arraycopy(attributeNamesArray, 0, searchFields, 0, attributeNamesArray.length); System.arraycopy(otherFieldsArray, 0, searchFields, attributeNamesArray.length, otherFieldsArray.length); =20 MultiFieldQueryParser multiparser =3D new MultiFieldQueryParser(searchFields, new StandardAnalyzer()); multiparser.setDefaultOperator(QueryParser.Operator.OR);=20 Query query =3D multiparser.parse("aaa*"); When I call toString() on my query, the syntax looks correct Query guid:aaa* name:aaa* value:aaa* id:aaa* name:aaa*=20 When I debug into the hits documents, I can see that only the 2 id results are returned. Its not finding the guid as a hit because its in the same document as the id. I discovered this by using Luke to inspect the documents. -----Original Message----- From: Mitchell, Erica [mailto:Erica.Mitchell@iona.com]=20 Sent: 08 February 2008 14:54 To: java-user@lucene.apache.org Subject: MultiFieldQueryParser question Hi, I'm trying to build up an index of fields to represent an org.eclipse.emf.ecore.EObject; So I'm adding these fields to my lucene doc doc.add(new Field(NAME, cls.getName(), Field.Store.YES, Field.Index.TOKENIZED)); 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 =3D (EAttribute) o; String attributeName =3D attribute.getName(); Strung attributeValue =3D 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 =3D {IDENTITY, NAME, ATTRIBUTE};=20 =20 MultiFieldQueryParser multiparser =3D new MultiFieldQueryParser(searchFields, new StandardAnalyzer());=20 multiparser.setDefaultOperator(QueryParser.Operator.OR);=20 Query query =3D multiparser.parse("aaa*"); Hits hits =3D isearcher.search(query); So using Luke I can see my index contains information like this aaa2 aaa1 aaa2 pi4 attribute 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 ...)=20 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 searchFields? Thanks a million, Erica ---------------------------- IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org ---------------------------- IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org