[ 
https://issues.apache.org/jira/browse/LUCENE-4043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13558684#comment-13558684
 ] 

David vandendriessche edited comment on LUCENE-4043 at 1/21/13 11:09 AM:
-------------------------------------------------------------------------

Update on my code:

public class TestParserPlugin extends QParserPlugin {

    @Override
    public QParser createParser(String string, SolrParams sp, SolrParams sp1, 
SolrQueryRequest sqr) {
        return new TestParser(string, sp1, sp1, sqr);

    }

    @Override
    public void init(NamedList nl) {
    }

    public class TestParser extends QParser {

        public TestParser(String qstr, SolrParams localParams, SolrParams 
params, SolrQueryRequest req) {
            super(qstr, localParams, params, req);
        }

        @Override
        public org.apache.lucene.search.Query parse() throws 
org.apache.lucene.queryparser.classic.ParseException {

            IndexReader reader;
            try {
                reader = IndexReader.open(FSDirectory.open(new 
File("C:\\java\\apache-solr-4.0.0\\apache-solr-4.0.0\\example\\solr\\Books\\data\\index")));

                IndexSearcher searcher = new IndexSearcher(reader);
                BooleanQuery fromQuery = new BooleanQuery();
                fromQuery.add(new TermQuery(new Term("pageTxt", "crazy")), 
BooleanClause.Occur.MUST);
                fromQuery.add(new TermQuery(new Term("pageTxt", "test")), 
BooleanClause.Occur.SHOULD);
                return JoinUtil.createJoinQuery("pageId", true, 
"fileId",fromQuery, searcher, ScoreMode.Avg);
            } catch (IOException ex) {
                
Logger.getLogger(TestParserPlugin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return null;
        }
    }
}

I still have 2 questions concerning this code:
Is there a way to get the searcher instead of opening from fs everytime I use 
this plugin?(I think this will create a memory leak)
Is it possible to combine this qparser with edismax etc in stead of building 
queries using occur.must etc...
                
      was (Author: davidvdd):
    Update on my code:

public class TestParserPlugin extends QParserPlugin {

    @Override
    public QParser createParser(String string, SolrParams sp, SolrParams sp1, 
SolrQueryRequest sqr) {
        return new TestParser(string, sp1, sp1, sqr);

    }

    @Override
    public void init(NamedList nl) {
    }

    public class TestParser extends QParser {

        public TestParser(String qstr, SolrParams localParams, SolrParams 
params, SolrQueryRequest req) {
            super(qstr, localParams, params, req);
        }

        @Override
        public org.apache.lucene.search.Query parse() throws 
org.apache.lucene.queryparser.classic.ParseException {

            IndexReader reader;
            try {
                reader = IndexReader.open(FSDirectory.open(new 
File("C:\\java\\apache-solr-4.0.0\\apache-solr-4.0.0\\example\\solr\\Books\\data\\index")));

                IndexSearcher searcher = new IndexSearcher(reader);
                BooleanQuery fromQuery = new BooleanQuery();
                fromQuery.add(new TermQuery(new Term("pageTxt", "crazy")), 
BooleanClause.Occur.MUST);
                fromQuery.add(new TermQuery(new Term("pageTxt", "test")), 
BooleanClause.Occur.SHOULD);
                return JoinUtil.createJoinQuery("pageId", true, 
"fileId",fromQuery, searcher, ScoreMode.Avg);
            } catch (IOException ex) {
                
Logger.getLogger(TestParserPlugin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return null;
        }
    }
}

I still have 2 questions concerning this code:
Is there a way to get the searcher instead of opening from fs everytime I use 
this plugin?
Is it possible to combine this qparser with edismax etc in stead of building 
queries using occur.must etc...
                  
> Add scoring support for query time join
> ---------------------------------------
>
>                 Key: LUCENE-4043
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4043
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: modules/join
>            Reporter: Martijn van Groningen
>             Fix For: 4.0-ALPHA
>
>         Attachments: LUCENE-4043.patch, LUCENE-4043.patch, LUCENE-4043.patch, 
> LUCENE-4043.patch
>
>
> Have similar scoring for query time joining just like the index time block 
> join (with the score mode).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to