You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by nilesh <ni...@polaris.co.in> on 2013/03/18 15:59:12 UTC

Wrong record returned retrieved

Following is the code which is returning data from correct table but with 3
rows pripor entry.
Emaple it incremental PK is 10 then it will return mr record for 7 , if
query is changed with other column, same problem noticed.


		File INDEX_DIR = new File("index");
		Directory dir = FSDirectory.open(INDEX_DIR);
		IndexSearcher searcher = new IndexSearcher(IndexReader.open(dir));
		Query query = new
QueryParser(Version.LUCENE_40,"lawname",analyzer).parse("Law");   
		
		TopDocs hits = searcher.search(query,10);
		
		Class.forName("org.sqlite.JDBC");  
		Connection conn =
DriverManager.getConnection("jdbc:sqlite:\\D:\\Sqlite\\SysDb.db");
		
		//Quering Laws table
		String sql = "select * from laws where lawid = ?;";   
		PreparedStatement pstmt = conn.prepareStatement(sql);
		   
		for (int i = 0; i < hits.totalHits; i++){
		   int id = hits.scoreDocs[i].doc;
		   pstmt.setInt(1, id);   
		   displayResults(pstmt, "laws");   
		}





	void displayResults(PreparedStatement pstmt,String tableName) {   
	   try {   
	      ResultSet rs = pstmt.executeQuery();   
	      
	      System.out.println("********" + tableName + "********");
	      
	      while (rs.next()) {   
	         System.out.println(rs.getString("lawid"));   
	         System.out.println(rs.getString("lawname")+"\n");   
	      }   
	   } catch (SQLException e) {   
	      e.printStackTrace();   
	   }   
	}



--
View this message in context: http://lucene.472066.n3.nabble.com/Wrong-record-returned-retrieved-tp4048588.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

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