Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Solr json响应需要所有突出显示的文档_Solr_Jsonp_Highlighting - Fatal编程技术网

Solr json响应需要所有突出显示的文档

Solr json响应需要所有突出显示的文档,solr,jsonp,highlighting,Solr,Jsonp,Highlighting,我需要能够在我的web应用程序的搜索文本字段中键入查询,并从包含特定文本的每个文档返回突出显示的结果。问题是,我无法得到显示所有文档的响应,它只显示一个 假设我有4个ID为doc1、doc2、doc3、doc4等的文档。如何让代码循环显示所有4个文档的内容,而不是仅显示一个文档的内容。我已经将doc2硬编码到我的程序中以使其工作,我在循环它时遇到了问题 Ext.data.JsonP.request({ url: 'http://localhost:8983/solr/collection1/se

我需要能够在我的web应用程序的搜索文本字段中键入查询,并从包含特定文本的每个文档返回突出显示的结果。问题是,我无法得到显示所有文档的响应,它只显示一个

假设我有4个ID为doc1、doc2、doc3、doc4等的文档。如何让代码循环显示所有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.
} 
Ext.data.JsonP.request({
网址:'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”,
成功:功能(res,req){

对于(i=0;i您可以尝试直接迭代
res.response.docs
集合

e、 g


从这篇博文中可以看出:

我在for循环中包含了以下内容以使其正常工作:

 var hl = res.highlighting;
 var content="";
 Object.keys(hl).forEach(function (key) {
     if(key == docId) {
         content = hl[key].content;
     }
 });
 var hl = res.highlighting;
 var content="";
 Object.keys(hl).forEach(function (key) {
     if(key == docId) {
         content = hl[key].content;
     }
 });