Web アプリの検索テキスト フィールドにクエリを入力し、特定のテキストを含む各ドキュメントから強調表示された結果を返せるようにする必要があります。問題は、すべてのドキュメントを表示する応答が得られず、1 つしか表示されないことです。
doc1、doc2、doc3、doc4 などの ID を持つ 4 つのドキュメントがあるとします。コードをループして、1 つだけでなく 4 つのドキュメントすべてのコンテンツを表示するにはどうすればよいですか。doc2 をプログラムにハードコードして動作させましたが、ループ処理に問題があります。
Ext.data.JsonP.request({
url: 'http://localhost:8983/solr/collection1/select?q='+searchValue+'&wt=json&indent=true&hl=true&hl.fl=content&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E',
callbackKey: "json.wrf",
success: function( res, req ) {
for (i=0; i<res.response.numFound; i++) {
var docId = res.response.docs[i].id;
//This returns all ids. ex. doc1, doc2 etc.
alert(docId);
htmlCode += "<h4>Your search term: "+searchValue+"</h4><p>"+res.highlighting.doc2.content+"</p>";
}
//Print code below -- irrelevant for the question.
}