欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal7 d7 apachesolr 搜不到 body 概要 摘要 summary teaser ,如何解决 有大用 有大大用

apachesolr.index.inc 文件中  

约 889 行  原代码

 // Adding the teaser

  if (isset($node->teaser)) {

    $document->teaser = apachesolr_clean_text($node->teaser);

  }

  else {

    // If there is no node teaser we will have to generate the teaser

    // ourselves. We have to be careful to not leak the author and other

    // information that is normally also not visible.

    if (isset($node->body[$language][0]['safe_summary'])) {

      $document->teaser = apachesolr_clean_text($node->body[$language][0]['safe_summary']);

    }

    else {


      $document->teaser = truncate_utf8($document->content, 300, TRUE);


    }

  }



改成  新代码


// Adding the teaser

  if (isset($node->teaser)) {

    $document->teaser = apachesolr_clean_text($node->teaser);

  }

  else {

    // If there is no node teaser we will have to generate the teaser

    // ourselves. We have to be careful to not leak the author and other

    // information that is normally also not visible.

   if (isset($node->body[$language][0]['safe_summary']) || isset($node->body['und'][0]['safe_summary'])) {

        $str_teaser  =  isset($node->body[$language][0]['safe_summary']) ? $node->body[$language][0]['safe_summary'] : $node->body['und'][0]['safe_summary'];   

      $document->teaser = apachesolr_clean_text($str_teaser);

    }

    else {


      $document->teaser = truncate_utf8($document->content, 300, TRUE);


    }

  }



原代码 处主要是关于不识别语言代码,可能有问题,,所以

可能不搜 内容概要  ($node->body[$language][0]['safe_summary']),

而只搜内容的截取    truncate_utf8($document->content, 300, TRUE);








下面 也是表达的同样的意思


image.png


image.png

来自 https://www.drupal.org/project/apachesolr/issues/2315173#comment-9091385

普通分类: