搜索结果不显示代码段solr drupal
嗨 我有一个Drupal7、ApacheSolr集成模块和SolrAttachments模块。我以前从未收到过这样的通知,但我很困惑为什么搜索片段没有显示出来。查看了通知中提到的代码并进行了打印($snippets),发现该代码段位于变量中,只是没有显示在搜索结果中。这可能是什么原因 solrconfig.xml搜索结果不显示代码段solr drupal,drupal,solr,Drupal,Solr,嗨 我有一个Drupal7、ApacheSolr集成模块和SolrAttachments模块。我以前从未收到过这样的通知,但我很困惑为什么搜索片段没有显示出来。查看了通知中提到的代码并进行了打印($snippets),发现该代码段位于变量中,只是没有显示在搜索结果中。这可能是什么原因 solrconfig.xml <requestHandler name="drupal" class="solr.SearchHandler" default="true"> <lst name
<requestHandler name="drupal" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<bool name="omitHeader">true</bool>
<float name="tie">0.01</float>
<str name="pf">
content^2.0
</str>
<int name="ps">15</int>
<!-- Abort any searches longer than 4 seconds -->
<!-- <int name="timeAllowed">4000</int> -->
<str name="mm">1</str>
<str name="q.alt">*:*</str>
<!-- example highlighter config, enable per-query with hl=true -->
<str name="hl">true</str>
<str name="hl.fl">content</str>
<int name="hl.snippets">1</int>
<str name="hl.mergeContiguous">true</str>
<!-- instructs Solr to return the field itself if no query terms are
found -->
<str name="f.content.hl.alternateField">teaser</str>
<str name="f.content.hl.maxAlternateFieldLength">256</str>
<!-- JS: I wasn't getting good results here... I'm turning off for now
because I was getting periods (.) by themselves at the beginning of
snippets and don't feel like debugging anymore. Without the regex is
faster too -->
<!--<str name="f.content.hl.fragmenter">regex</str>--> <!-- defined below -->
<!-- By default, don't spell check -->
<str name="spellcheck">false</str>
<!-- Defaults for the spell checker when used -->
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<!-- The number of suggestions to return -->
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
沮丧
明确的
真的
0.01
内容^2.0
15
1.
*:*
真的
内容
1.
真的
戏弄者
256
假的
假的
假的
1.
拼写检查
这是apachesolru attachments.module中的通知中的代码
enter code here
function theme_apachesolr_search_snippets__file($vars) {
$doc = $vars['doc'];
$snippets = $vars['snippets'];
$parent_entity_links = array();
// Retrieve our parent entities. They have been saved as
// a small serialized entity
foreach ($doc->zm_parent_entity as $parent_entity_encoded) {
$parent_entity = (object) drupal_json_decode($parent_entity_encoded);
$parent_entity_uri = entity_uri($parent_entity->entity_type, $parent_entity);
$parent_entity_uri['options']['absolute'] = TRUE;
$parent_label = entity_label($parent_entity->entity_type, $parent_entity);
$parent_entity_links[] = l($parent_label, $parent_entity_uri['path'], $parent_entity_uri['options']);
}
if (module_exists('file')) {
$file_type = t('!icon @filemime', array('@filemime' => $doc->ss_filemime, '!icon' => theme('file_icon', array('file' => (object) array('filemime' => $doc->ss_filemime)))));
}
else {
$file_type = t('@filemime', array('@filemime' => $doc->ss_filemime));
}
//print_r($snippets);echo "\n";
return implode(' ... ', $snippets) . '<span>' . $file_type . ' <em>attached to:</em>' . implode(', ', $parent_entity_links) . '</span>';
在此处输入代码
函数主题\u apachesolr\u搜索\u代码段\u文件($vars){
$doc=$vars['doc'];
$snippets=$vars['snippets'];
$parent_entity_links=array();
//检索父实体。它们已另存为
//小型序列化实体
foreach($doc->zm\u parent\u entity作为$parent\u entity\u编码){
$parent\u entity=(object)drupal\u json\u decode($parent\u entity\u encoded);
$parent\u entity\u uri=entity\u uri($parent\u entity->entity\u type,$parent\u entity);
$parent_entity_uri['options']['absolute']=TRUE;
$parent\u label=实体\u label($parent\u entity->entity\u type,$parent\u entity);
$parent_entity_links[]=l($parent_label,$parent_entity_uri['path'],$parent_entity_uri['options']);
}
如果(模块_存在('file')){
$file_type=t('!icon@filemime',array('@filemime'=>$doc->ss_filemime',!icon'=>主题('file_icon',array('file'=>(object)array('filemime'=>$doc->ss_filemime'));
}
否则{
$file_type=t('@filemime',数组('@filemime'=>$doc->ss_filemime));
}
//打印($snippets);回显“\n”;
返回内爆(“…”,$snippets)。“.$file_type.”附加到:“.内爆(“,”,$parent_entity_links)。”;
}
schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="name" type="string" stored="true" indexed="true"/>
<!-- entity_id is the numeric object ID, e.g. Node ID, File ID -->
<field name="entity_id" type="long" indexed="true" stored="true" />
<!-- entity_type is 'node', 'file', 'user', or some other Drupal object type -->
<field name="entity_type" type="string" indexed="true" stored="true" />
<!-- bundle is a node type, or as appropriate for other entity types -->
<field name="bundle" type="string" indexed="true" stored="true"/>
<field name="bundle_name" type="string" indexed="true" stored="true"/>
<field name="text" type="text" stored="true" indexed="true"/>
<field name="site" type="string" indexed="true" stored="true"/>
<field name="hash" type="string" indexed="true" stored="true"/>
<field name="url" type="string" indexed="true" stored="true"/>
<!-- label is the default field for a human-readable string for this entity (e.g. the title of a node) -->
<field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
<!-- The string version of the title is used for sorting -->
<copyField source="label" dest="sort_label"/>
<!-- content is the default field for full text search - dump crap here -->
<field name="content" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="content_type" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="teaser" type="text" indexed="false" stored="true"/>
<field name="language" type="text_en" stored="true" indexed="true"/>
<field name="path" type="string" indexed="true" stored="true"/>
<field name="path_alias" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
<field name="created" type="string" indexed="true" stored="true" termVectors="true"/>
<field name="Question" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Response" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Module" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Meets" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="cat" type="string" indexed="true" stored="true" termVectors="true"/>
有什么建议可以取消通知并显示代码片段吗?我将
返回内爆('..',$snippets)
替换为返回内爆('..',$snippets['content'])
,这对我很有效
我不能保证不会出现问题。
无论如何,值得一试