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: Need Help In code
Date Thu, 30 Jan 2014 10:35:10 GMT
After indexsearcher.search you should call c.getTopGroups?  See the
TestBlockJoin.java example...

Can you boil this down to a runnable test case, i.e. include
createProductItem/createProduct sources, etc.

Mike McCandless

http://blog.mikemccandless.com


On Thu, Jan 30, 2014 at 2:20 AM, Priyanka Tufchi
<priyanka.tufchi@launchship.com> wrote:
> Hello
>
> This is the Sample Code Of BlockJoinQuery( we tried  .
> Issues:
> 1)Dont know how to get hits and score from it
> 2) This code is not giving output.
>
> I have attached the code for easy view
>
>
> 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));
> Query childQuery=new TermQuery(new Term("size","m"));
> ScoreMode scoremode=ScoreMode.Max;
> //String Query="blue AND l";
> BooleanQuery mainQuery=new BooleanQuery();
> //need to check this parameters
> mainQuery.add(childQuery,Occur.MUST);
> //mainQuery.add(query, occur);
> ToParentBlockJoinQuery productitemQuery=new
> ToParentBlockJoinQuery(mainQuery, parentfilter,
> scoremode);
> ToParentBlockJoinCollector c = new ToParentBlockJoinCollector(
>    Sort.RELEVANCE, // sort
>    10,             // numHits
>    true,           // trackScores
>    false           // trackMaxScore
>    );
>
> indexsearcher.search(productitemQuery,c);
>
>
>
> ---------------------------------------------------------------------
> 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