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 8E528109E6 for ; Thu, 30 Jan 2014 14:57:56 +0000 (UTC) Received: (qmail 91741 invoked by uid 500); 30 Jan 2014 14:57:53 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 91404 invoked by uid 500); 30 Jan 2014 14:57:49 -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 91394 invoked by uid 99); 30 Jan 2014 14:57:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 14:57:47 +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: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.220.174] (HELO mail-vc0-f174.google.com) (209.85.220.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 14:57:41 +0000 Received: by mail-vc0-f174.google.com with SMTP id im17so2101361vcb.5 for ; Thu, 30 Jan 2014 06:57:20 -0800 (PST) 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; bh=72sd+ob1QKTsefGYfjjuHPVzo7AF7rvqpoxPHUp8gys=; b=lc9j5Uk7jKT5323tuq5dM1szMGQs/j5gQiTdqece6q139TuoVxsB0HYlR+lKZL/kbU m1/zDg+vYsFB85iYuQgaBYxkEjcxGRNjYfI54D5XzeqQefRA+1hY9sCzZSKQr9TR1K6q TPcF4QHnff6EJkm4vXoohpzfRY53Vy9QNSfBLkTnnZ4Y8DhVVhC1wPjV/10ndShz8PTJ NOSTEwvlAMfSjVCgsmYdRpqZfBMwkBJr4ynRip2luEzt/KocwI3fLS/oUUGKlXc1nnVn 2F6XMxpMJLL4Y9MnK995cPToNTF7rDONwDPieGL5qMSYAimNdKGRawilrnyhXvOoYHLC guig== X-Gm-Message-State: ALoCoQngR8WavGHZLG4ylGuSTZhSZiTeMvdDxj6tjtB3B3QDmwxY0i8LOsXtGM0fuOGTB9Pn7DZC X-Received: by 10.220.29.200 with SMTP id r8mr12299403vcc.9.1391093840545; Thu, 30 Jan 2014 06:57:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.221.5.3 with HTTP; Thu, 30 Jan 2014 06:56:59 -0800 (PST) In-Reply-To: References: From: Michael McCandless Date: Thu, 30 Jan 2014 09:56:59 -0500 Message-ID: Subject: Re: BlockJoinQuery is missing in lucene-4.1.0 . To: Lucene Users Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org You are passing ScoreMode.NONE right now, when you create the ToParentBlockJoinQuery; have a look at the javadocs for the other options? You could normalize all scores by the maxScore, if you must produce a percentage? Mike McCandless http://blog.mikemccandless.com On Thu, Jan 30, 2014 at 7:31 AM, Priyanka Tufchi wrote: > Hello Mike > > Thanks for the reply ,Now we are able to get TopGroups. but still we > are not able to get score .how ever we got matched Parent and child > through following code. We need score for showing in our application > for ranking . > > Document childDoc = indexsearcher.doc(group.scoreDocs[0].doc); > Document parentDoc = indexsearcher.doc(group.groupValue); > > And Second Question is that, how does lucene score ? means we have > used it before ,but the score is not between 0 to 1 example(16.0 or > 1.4) so If i want to use it in percentage ..Then how it gonna work and > the score is like this? > > On Thu, Jan 30, 2014 at 3:27 AM, Michael McCandless > wrote: >> You should not use TextField.TYPE_STORED to index your docType field: >> that field type runs the analyzer. I'm not sure that matters in your >> case, but that's deadly in general. Use StringField instead (it >> indexes the provided text as a single token). >> >> Likewise for color, size fields. >> >> Try running your parentQuery as a search itself and confirm you see >> totalHits=2? This will tell you if something is wrong in how you >> indexed the docType field, or created the parent query/filter. >> >> Also try running your childQuery separately and confirm you get >> non-zero totalHits. >> >> Hmm, this code never calls indexsearcher.search on the query? >> >> Mike McCandless >> >> http://blog.mikemccandless.com >> >> >> On Thu, Jan 30, 2014 at 5:41 AM, Priyanka Tufchi >> wrote: >>> Hello Michael, >>> >>> following is the code. This is the Sample which we are trying to get >>> the the hits.Please Guide us >>> >>> -------------------------------------------------------------------- >>> >>> public void newTry() throws IOException >>> { >>> StandardAnalyzer analyzer = new StandardAnalyzer >>> >>> (Version.LUCENE_41); >>> // 1. create the index >>> Directory index = new RAMDirectory(); >>> IndexWriterConfig config = new IndexWriterConfig >>> >>> (Version.LUCENE_41, >>> analyzer); >>> >>> IndexWriter w = new IndexWriter(index, config); >>> List documents=new ArrayList(); >>> documents.add(createProductItem("red", "s", "999")); >>> documents.add(createProductItem("red", "m", "1000")); >>> documents.add(createProductItem("red", "l", "2000")); >>> documents.add(createProduct("Polo Shirt", ".....Made Of 100% >>> >>> cotton")); >>> w.addDocuments(documents); >>> documents.clear(); >>> documents.add(createProductItem("light blue", "s", "1000")); >>> documents.add(createProductItem("blue", "s", "1900")); >>> documents.add(createProductItem("dark blue", "s", "1999")); >>> documents.add(createProductItem("light blue", "m", "2000")); >>> documents.add(createProductItem("blue", "m", "2090")); >>> documents.add(createProductItem("dark blue", "m", "2099")); >>> documents.add(createProduct("white color", "...stripe pattern")); >>> w.addDocuments(documents); >>> IndexReader indexreader=DirectoryReader.open(w, false); >>> IndexSearcher indexsearcher=new IndexSearcher(indexreader); >>> Query parentQuery= new TermQuery(new Term("docType", "product")); >>> Filter parentfilter=new CachingWrapperFilter(new QueryWrapperFilter >>> >>> (parentQuery)); >>> BooleanQuery mainQuery=new BooleanQuery(); >>> Query childQuery=new TermQuery(new Term("size","m")); >>> mainQuery.add(childQuery,Occur.SHOULD); >>> ScoreMode scoremode=ScoreMode.None; >>> ToParentBlockJoinQuery productitemQuery=new ToParentBlockJoinQuery >>> >>> (mainQuery, parentfilter, >>> scoremode); >>> BooleanQuery query = new BooleanQuery(); >>> query.add(new TermQuery(new Term("name", "white color")), Occur.MUST); >>> query.add(productitemQuery, Occur.MUST); >>> ToParentBlockJoinCollector c = new ToParentBlockJoinCollector( >>> Sort.RELEVANCE, // sort >>> 10, // numHits >>> true, // >>> >>> trackScores >>> false // >>> >>> trackMaxScore >>> ); >>> TopGroups hits = >>> c.getTopGroups( >>> productitemQuery, >>> Sort.RELEVANCE, >>> 0, // offset >>> 10, // maxDocsPerGroup >>> 0, // withinGroupOffset >>> true // fillSortFields >>> ); >>> System.out.println("abc"); >>> >>> >>> } >>> private static Document createProduct(String name,String description) >>> { >>> Document document=new Document(); >>> document.add(new org.apache.lucene.document.Field("name", name, >>> >>> org.apache.lucene.document.TextField.TYPE_STORED)); >>> document.add(new org.apache.lucene.document.Field("docType", >>> >>> "product", org.apache.lucene.document.TextField.TYPE_STORED)); >>> document.add(new org.apache.lucene.document.Field("description", >>> >>> description, org.apache.lucene.document.TextField.TYPE_STORED)); >>> return document; >>> } >>> private static Document createProductItem(String color,String size,String >>> >>> price) >>> { >>> Document document=new Document(); >>> document.add(new org.apache.lucene.document.Field("color", color, >>> >>> org.apache.lucene.document.TextField.TYPE_STORED)); >>> document.add(new org.apache.lucene.document.Field("size", size, >>> >>> org.apache.lucene.document.TextField.TYPE_STORED)); >>> document.add(new org.apache.lucene.document.Field("price", price, >>> >>> org.apache.lucene.document.TextField.TYPE_STORED)); >>> return document; >>> } >>> >>> On Thu, Jan 30, 2014 at 2:24 AM, Michael McCandless >>> wrote: >>>> Hi, >>>> >>>> It looks like the mailing list stripped the attachment; can you try >>>> inlining the code into your email (is it brief?). >>>> >>>> Also, have a look at the unit-test for ToParentBJQ and compare how it >>>> runs the query with your code? >>>> >>>> Mike McCandless >>>> >>>> http://blog.mikemccandless.com >>>> >>>> >>>> On Thu, Jan 30, 2014 at 5:15 AM, Priyanka Tufchi >>>> wrote: >>>>> Hello Michael, >>>>> >>>>> We tried the sample of code but the value of "hits" we are getting >>>>> is null. We tried to search on net but no proper sample example given >>>>> which can help us to understand. We attached our code with mail >>>>> .please it would be great if you can give a look to our code. >>>>> >>>>> Thanks. >>>>> >>>>> On Wed, Jan 29, 2014 at 3:15 AM, Priyanka Tufchi >>>>> wrote: >>>>>> Hello Michael, >>>>>> >>>>>> In the example given in your blog in following line there is error >>>>>> >>>>>> searcher.search(query, c); >>>>>> >>>>>> whether it should convert in IndexSearcher >>>>>> >>>>>> there is no explanation given for document addition in blog example ? >>>>>> Can you please provide helping hand. >>>>>> >>>>>> Thanks. >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Jan 29, 2014 at 2:59 AM, Michael McCandless >>>>>> wrote: >>>>>>> Actually, the blog post should still apply: just insert ToParent to >>>>>>> rename things. >>>>>>> >>>>>>> ToChildBlockJoinQuery is the same idea, but it joins in the reverse >>>>>>> direction, so e.g. if your index has CDs (parent docs) and individual >>>>>>> songs on those CDs (child docs), you can take a parent-level >>>>>>> constraint (e.g. maybe price < $12) and join it down to child level >>>>>>> constraints (maybe a query against the song's title) and then see >>>>>>> individual songs (not albums) as the returned hits. >>>>>>> >>>>>>> Mike McCandless >>>>>>> >>>>>>> http://blog.mikemccandless.com >>>>>>> >>>>>>> >>>>>>> On Wed, Jan 29, 2014 at 5:44 AM, Priyanka Tufchi >>>>>>> wrote: >>>>>>>> Hello Michael, >>>>>>>> >>>>>>>> Can i get code snippet for this new classes: ToParentBlockJoinQuery, >>>>>>>> ToChildBlockJoinQuery >>>>>>>> and how to use it. >>>>>>>> >>>>>>>> thanks >>>>>>>> >>>>>>>> On Wed, Jan 29, 2014 at 2:22 AM, Michael McCandless >>>>>>>> wrote: >>>>>>>>> Sorry, BlockJoinQuery was split into two separate classes: >>>>>>>>> ToParentBlockJoinQuery, ToChildBlockJoinQuery. >>>>>>>>> >>>>>>>>> Mike McCandless >>>>>>>>> >>>>>>>>> http://blog.mikemccandless.com >>>>>>>>> >>>>>>>>> >>>>>>>>> On Wed, Jan 29, 2014 at 4:32 AM, Priyanka Tufchi >>>>>>>>> wrote: >>>>>>>>>> Subject: BlockJoinQuery is missing in lucene-4.1.0 . >>>>>>>>>> To: java-user@lucene.apache.org >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Hello , >>>>>>>>>> >>>>>>>>>> I want to Search relational content which has parent child >>>>>>>>>> relationship . I am following below link >>>>>>>>>> >>>>>>>>>> http://blog.mikemccandless.com/2012/01/searching-relational-content-with.html >>>>>>>>>> >>>>>>>>>> but got problem in following line >>>>>>>>>> >>>>>>>>>> BlockJoinQuery skuJoinQuery = new BlockJoinQuery( >>>>>>>>>> skuQuery, >>>>>>>>>> shirts, ScoreMode.None); >>>>>>>>>> >>>>>>>>>> where is "BlockJoinQuery " class in lucene-4.1.0 ? It has been >>>>>>>>>> removed or some other alternative way is in this version. >>>>>>>>>> >>>>>>>>>> Thanks in advance. >>>>>>>>>> >>>>>>>>>> --------------------------------------------------------------------- >>>>>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>>>>>>> >>>>>>>>> >>>>>>>>> --------------------------------------------------------------------- >>>>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>>>>>> >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>>>>> >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>>>> >>>>> >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>> For additional commands, e-mail: java-user-help@lucene.apache.org >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >> For additional commands, e-mail: java-user-help@lucene.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org