I have made a Qparserplugin to get querytimejoin from lucene in to Solr. But
I'm facing 2 major issues.
This is the code I'm using (With the right jars added to config etc it's
working.)

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 myself using occur.must etc...


Note: I also asked this question to the author of querytimejoin(on the jira
issue). 



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-combine-Qparsers-in-a-plugin-tp4035011.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to