Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5AA45186B6 for ; Tue, 23 Jun 2015 13:58:09 +0000 (UTC) Received: (qmail 48241 invoked by uid 500); 23 Jun 2015 13:58:07 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 48185 invoked by uid 500); 23 Jun 2015 13:58:07 -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 48164 invoked by uid 99); 23 Jun 2015 13:58:07 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Jun 2015 13:58:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 039A91A5F7C for ; Tue, 23 Jun 2015 13:58:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 3i3gBiNo6qCB for ; Tue, 23 Jun 2015 13:57:55 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 32821428CC for ; Tue, 23 Jun 2015 13:57:48 +0000 (UTC) Received: by lbnk3 with SMTP id k3so7254468lbn.1 for ; Tue, 23 Jun 2015 06:57:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=T91vemQD0TnMA+SjYELTefUnvVQ7m8TaTwZq58vdc5g=; b=DJovUMnCy3Mv0EcCtKYVNLxpucMu0h9nt/kX6xOdiglrRaCs6+JacTqhX6OkAgWEOD ZCdiv8lYPmxhpHLsPngTfs3Gl2YaPRxySqpeubcDzW5PZ7PSCuAyds6dQqro8pT8Qpo3 LqWiVAc3vzKstDp6zpZ3v/Idlw2YtKgYbMYy6z7YsTFzkkpIdKj2rhYj5DhdatRN0skg EYFowlRB30FDXQMWAd/xMRz/ukmzuNEe2UeQZO1SR4oONy/w9EgDw37Jkn9i9iwzwmmO /gakk280RlIXEqYvdkZhRR+Bchwj8dvxljX+2zXcJXKwJVZG9i3F/8+U9yxBHmtAZhV6 Tymg== X-Gm-Message-State: ALoCoQl9jDf/UvBT6xEOw7vQG0shZV2nrEl9/tc7T1W8QKbqTUAjg41iDq5nEK51xt1y6XwSHrRX X-Received: by 10.152.204.7 with SMTP id ku7mr35222897lac.38.1435067866957; Tue, 23 Jun 2015 06:57:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.156.15 with HTTP; Tue, 23 Jun 2015 06:57:27 -0700 (PDT) In-Reply-To: References: From: Michael McCandless Date: Tue, 23 Jun 2015 09:57:27 -0400 Message-ID: Subject: Re: delete one document from index not working To: Lucene Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable You should not setTokenized(true) for your id field? This splits it into tokens according to your analyzer. Mike McCandless http://blog.mikemccandless.com On Tue, Jun 23, 2015 at 7:40 AM, Behnam Khoshsafar wrote: > I'm using Lucene 5.1.0 to index a document and search it. I have a lot of= documents, over 1000000, which are stored in a database. When I start runn= ing the project for the first time, I use Lucene to index these documents. = Now I want to delete one document from the database and indexes. I also cho= ose an id for each index. I am using the following command to delete, but i= t's delete all index. > > iw.deleteDocuments(new Term("id", doc.id)); > Also, I used a Query to delete but it's delete all index. > > I add documents to the index as follows: > > iDoc =3D new org.apache.lucene.document.Document(); > FieldType fieldType =3D new FieldType(); > fieldType.setIndexOptions( > IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS); > fieldType.setTokenized(true); > fieldType.setStored(true); > fieldType.setOmitNorms(true); > fieldType.setStoreTermVectors(true); > fieldType.setStoreTermVectorOffsets(true); > fieldType.setStoreTermVectorPayloads(true); > fieldType.setStoreTermVectorPositions(true); > iDoc.add(new Field("id", doc.id.toString(), fieldType)); > iw.addDocument(iDoc); > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org