lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: BlockJoinQuery is missing in lucene-4.1.0 .
Date Thu, 30 Jan 2014 14:56:59 GMT
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
<priyanka.tufchi@launchship.com> 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
> <lucene@mikemccandless.com> 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
>> <priyanka.tufchi@launchship.com> 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<Document> documents=new ArrayList<Document>();
>>> 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<Integer> 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
>>> <lucene@mikemccandless.com> 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
>>>> <priyanka.tufchi@launchship.com> 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
>>>>> <priyanka.tufchi@launchship.com> 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
>>>>>> <lucene@mikemccandless.com> 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
>>>>>>> <priyanka.tufchi@launchship.com> 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
>>>>>>>> <lucene@mikemccandless.com> 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
>>>>>>>>> <priyanka.tufchi@launchship.com> 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


Mime
View raw message