hi all, i have a table Sample containing fields menu1, menu2, menu3 and some more columns
Sample table :
id Menu1 Menu2 Menu3 other columns ------------------------------------------------------------------------------------------ 1 java oracle sap 2 accounts finance administration some more rows follows..
i have indexed 3 fields (menu1, menu2, menu3)
so when a story(containing 100 to 200 words) containing all the 3 words java, oracle, sap comes i want to fetch the first row from database
(Example: some text here java some more text here sap some more text oracle and some more text)
For this i have implemented the following 2 ways but unfortunately none of them is working:
CASE 1: QueryParser parser1 = new QueryParser("menu1", new WhitespaceAnalyzer()); org.apache.lucene.search.Query query1 = parser1.parse(Story); QueryParser parser2 = new QueryParser("menu2", new WhitespaceAnalyzer()); org.apache.lucene.search.Query query2 = parser2.parse(Story); QueryParser parser3 = new QueryParser("menu3", new WhitespaceAnalyzer()); org.apache.lucene.search.Query query3 = parser3.parse(Story); BooleanQuery bq = new BooleanQuery(); bq.add(query1, Occur.MUST); bq.add(query2, Occur.MUST); bq.add(query3, Occur.MUST); org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(bq, Sample.class); List list = hibQuery.list();
CASE 2: String[] fields = {"menu1", "menu2", "menu3"}; Occur[] occur = new Occur[3]; occur[0] = Occur.MUST; occur[1] = Occur.MUST; occur[2] = Occur.MUST; org.apache.lucene.search.Query query = MultiFieldQueryParser.parse(story, fields, occur, new WhitespaceAnalyzer()); org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, Sample.class); List list = hibQuery.list();
in both cases iam getting no errors, and also no results for the text some text here java some more text here sap some more text oracle and some more text
can any one tell what iam doing wrong here Thanks a lot, Bye
|