2016-06-15 16 views
0

私はエンタープライズ検索エンジンを作成しています。私は検索エンジンを作成するためにSolrを使い、JSPを使ってフロントエンドにSolrJを使っています。私は検索結果にページネーションを適用したい。 solr coreから結果を得るための私のコードは以下の通りです。検索エンジンのページ番号

while(iter.hasNext()) 
     { 
     SolrDocument doc1 =iter.next(); 
     String dc =iter.next().toString(); 

     out.println(doc1.getFieldValue("id")); 


     out.println(doc1.getFieldValue("title")); 
     out.println("<BR>"); 
     out.println("content_type :"); 
     out.println(doc1.getFieldValue("content_type")); 
     out.println("<BR>"); 
     out.println("doc_type :"); 
     out.println(doc1.getFieldValue("doc_type")); 
     } %>  

検索エンジンには600件のレコードがあります。特定のキーワードを検索すると、それに関連するすべてのレコードが単一のページに表示されます。どのボディでもJavaScriptを使ってページ分割のロジックを教えてもらえますか?私はクライアントサイドページネーションを使いたい。助けてください。 Solrのクエリを作成しながら

答えて

0

あなたが起動して設定することができ、行例えば:

SolrQuery query = new SolrQuery(searchTerm); 
query.setStart((pageNum - 1) * numItemsPerPage); 
query.setRows(numItemsPerPage); 
// execute the query on the server and get results 
QueryResponse res = solrServer.query(solrQuery); 

また、あなたがiter.nextを行うたびに()を使用すると、イテレータの次の要素を読んでいます。したがって、行うことによって

SolrDocument doc1 =iter.next(); 
String dc =iter.next().toString(); 

あなたは1つの要素をスキップしています。参照先:here