Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 8702 invoked from network); 4 Feb 2005 07:12:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 4 Feb 2005 07:12:27 -0000 Received: (qmail 49738 invoked by uid 500); 4 Feb 2005 07:12:21 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 49713 invoked by uid 500); 4 Feb 2005 07:12:21 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 49698 invoked by uid 99); 4 Feb 2005 07:12:21 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of prettykely@gmail.com designates 64.233.184.198 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.198) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 03 Feb 2005 23:12:20 -0800 Received: by wproxy.gmail.com with SMTP id 55so508326wri for ; Thu, 03 Feb 2005 23:12:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=tSEIk+8MktXTR+cJ4/ljWEuO98Xgv2FLuLYrGUG3Kzhyy3UhjDwix51uMmNSKcWe7+en7ZJNbtswJZ6HW2frA4eHsjiC0EENXuiWTPDZ9pyVrvviRB94/Z4CZKEVefrUc4oE61l+2M6VmlAfRMEro6EDpAA0E2TrCSQ/e3MPqws= Received: by 10.54.57.39 with SMTP id f39mr79052wra; Thu, 03 Feb 2005 23:12:17 -0800 (PST) Received: by 10.54.25.31 with HTTP; Thu, 3 Feb 2005 23:12:17 -0800 (PST) Message-ID: <8fa7a78e0502032312556841da@mail.gmail.com> Date: Fri, 4 Feb 2005 15:12:17 +0800 From: =?UTF-8?B?5byg55G+?= Reply-To: =?UTF-8?B?5byg55G+?= To: Lucene Users List Subject: Re: Parsing The Query: Every document that doesn't have a field containing x In-Reply-To: <013201c50a1a$db152270$7703d00a@hypermedia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable References: <4202590F.8080209@polopoly.com> <013201c50a1a$db152270$7703d00a@hypermedia.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I think you may can use a filter to get right result! See examlples below package lia.advsearching; import junit.framework.TestCase; import org.apache.lucene.analysis.WhitespaceAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.QueryFilter; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.RAMDirectory; public class SecurityFilterTest extends TestCase { private RAMDirectory directory; protected void setUp() throws Exception { directory =3D new RAMDirectory(); IndexWriter writer =3D new IndexWriter(directory, new WhitespaceAnalyzer(), true); // Elwood Document document =3D new Document(); document.add(Field.Keyword("owner", "elwood")); document.add(Field.Text("keywords", "elwoods sensitive info")); writer.addDocument(document); // Jake document =3D new Document(); document.add(Field.Keyword("owner", "jake")); document.add(Field.Text("keywords", "jakes sensitive info")); writer.addDocument(document); writer.close(); } public void testSecurityFilter() throws Exception { TermQuery query =3D new TermQuery(new Term("keywords", "info")); IndexSearcher searcher =3D new IndexSearcher(directory); Hits hits =3D searcher.search(query); assertEquals("Both documents match", 2, hits.length()); QueryFilter jakeFilter =3D new QueryFilter( new TermQuery(new Term("owner", "jake"))); hits =3D searcher.search(query, jakeFilter); assertEquals(1, hits.length()); assertEquals("elwood is safe", "jakes sensitive info", hits.doc(0).get("keywords")); } } On Thu, 3 Feb 2005 13:04:50 -0500, Luke Shannon wrote: > Hello; >=20 > I have a query that finds document that contain fields with a specific > value. >=20 > query1 =3D QueryParser.parse("jpg", "kcfileupload", new StandardAnalyzer(= )); >=20 > This works well. >=20 > I would like a query that find documents containing all kcfileupload fiel= ds > that don't contain jpg. >=20 > The example I found in the book that seems to relate shows me how to find > documents without a specific term: >=20 > QueryParser parser =3D new QueryParser("contents", analyzer); > parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND); >=20 > But than it says: >=20 > Negating a term must be combined with at least one nonnegated term to ret= urn > documents; in other words, it isn't possible to use a query like NOT term= to > find all documents that don't contain a term. >=20 > So does that mean the above example wouldn't work? >=20 > The API says: >=20 > a plus (+) or a minus (-) sign, indicating that the clause is required o= r > prohibited respectively; >=20 > I have been playing around with using the minus character without much lu= ck. >=20 > Can someone give point me in the right direction to figure this out? >=20 > Thanks, >=20 > Luke >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: lucene-user-help@jakarta.apache.org >=20 >=20 --=20 =E6=84=BF=E4=BD=A0=E5=BF=AB=E4=B9=90=E6=AF=8F=E4=B8=80=E5=A4=A9 --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org