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 3D8B810D8A for ; Wed, 9 Jul 2014 17:05:00 +0000 (UTC) Received: (qmail 26167 invoked by uid 500); 9 Jul 2014 17:04:58 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 26104 invoked by uid 500); 9 Jul 2014 17:04:58 -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 26092 invoked by uid 99); 9 Jul 2014 17:04:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2014 17:04:58 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 209.85.213.173 as permitted sender) Received: from [209.85.213.173] (HELO mail-ig0-f173.google.com) (209.85.213.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2014 17:04:55 +0000 Received: by mail-ig0-f173.google.com with SMTP id h18so928971igc.12 for ; Wed, 09 Jul 2014 10:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=wOxnv2jJ5sTPiGbBYmzZg7Vv19B4OewPubJjPC+7YJA=; b=K3BWPw+C+Mp3jLBwECQkNwzOgoZ/8C7NAbwseYH7cKuWy+7L6llOvomEd0+PnY/NfU NaD7Bmk95Eoh/mH5aiXisMQZp28HgtjDtEazTs+EE1GRMmax3ZsIJMXbwSgUskLFrNFu yFsVda8dyNdGjktSWZlBf+rcEha9V5Aar3WAZU/oBj9vKiIoPvEyqyUl6n+o5G9yPZjW qILAdjWtQDkX0X68Bd06bS0HK+z3GPvkyv9/0ziBYs661o47HHTi8P9bQTQkw4fks3FC fRbSa3qDHc7ixmnnljSwlCF2zt5KPgFkALZX8Eo6WGfinffd5qoD1JrLipM/9JSgEyUu +UmQ== X-Received: by 10.43.137.74 with SMTP id in10mr49492176icc.54.1404925470913; Wed, 09 Jul 2014 10:04:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.56.80 with HTTP; Wed, 9 Jul 2014 10:04:10 -0700 (PDT) In-Reply-To: References: From: Ian Lea Date: Wed, 9 Jul 2014 18:04:10 +0100 Message-ID: Subject: Re: IndexSearcher.doc thread safe problem To: java-user@lucene.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org It's more likely to be a demonstration that concurrent programming is hard, results often hard to predict and debugging very hard. Or perhaps you simply need to add acceptsDocsOutOfOrder() to your collector, returning false. Either way, hard to see any evidence of a thread-safety problem in lucene. If adding acceptsDocsOutOfOrder() doesn't fix it, I suggest you verify that your queue is getting the values you expect, in the order you expect, consistently. Then worry about the display part, first checking everything without any lucene calls. -- Ian. On Wed, Jul 9, 2014 at 5:59 AM, =EA=B9=80=EC=84=A0=EB=AC=B4 wrote: > Hi all, > > I know IndexSearcher is thread safe. > But IndexSearcher.doc is not thread safe maybe... > > I try to below > -------------------------------------------- > First, I extract docID at index directory. And that docID add on > queue(ConcurrentLinkedQueue) > > Second, extract field value using docID poll at this queue after extract > process end. This process is work to multi-threads. > > For this I used the following summation code below: > searcher.search( query, filter, new Collector() { public void collect( in= t > doc ) { queue.add( docBase + doc ) } ); > Thread thread1 =3D new Thread( () -> { while( !queue.isEmpty() ) { > System.out.println( searcher.doc(queue.poll()).get("content") ); } } ); > Thread thread2 =3D new Thread( thread1 ); > thread1.start(); > thread2.start(); > ------------------------------------------- > > Result was different in every execution. > > My method is wrong? or IndexSearcher bug? > > Please help me --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org