Is there a way to get Lucene's query from Solr query?. I have a requirement
to search for terms in multiple heterogeneous indices. Presently, I am using
the following approach

                try {
                        Directory directory1 = FSDirectory.open(new
File("E:\\database\\patient\\index"));
                        Directory directory2 = FSDirectory.open(new
File("E:\\database\\study\\index"));

                        BooleanQuery myQuery = new BooleanQuery();
                        myQuery.add(new TermQuery(new Term("PATIENT_GENDER", 
"Male")),
BooleanClause.Occur.SHOULD);
                        myQuery.add(new TermQuery(new 
Term("STUDY_DIVISION","Cancer Center")),
BooleanClause.Occur.SHOULD);

                        int indexCount = 2;
                        IndexReader[] indexReader = new IndexReader[indexCount];
                        indexReader[0] = DirectoryReader.open(directory1);
                        indexReader[1] = DirectoryReader.open(directory2);

                        IndexSearcher searcher = new IndexSearcher(new 
MultiReader(indexReader));               
                        TopDocs col  = searcher.search(myQuery, 10);    

                        //results
                        ScoreDoc[] docs =  col.scoreDocs;        

                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

Here, I need to create TermQuery based on Field Names and its value. If I
can get this boolean query directly from Solr query q=PATIENT_GENDER:Male OR
STUDY_DIVISION:"Cancer Center", that will save my coding effort. This one is
a simple example but when we need to create more complex query it will be a
time consuming activity and error prone. So, is there a way to get the
lucense's query from solr query.




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Getting-Lucense-Query-from-Solr-query-Or-converting-Solr-Query-to-Lucense-s-query-tp4031187.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to