搜索 API Solr 与五星级(或类似)评级系统集成(fascet 和排序)

发布于 2024-12-06 20:23:40 字数 209 浏览 0 评论 0原文

我正在尝试使用搜索 API 分面搜索和 Solr 集成按评级对节点进行排序。我已经设置了五星级评级(每个节点大约 9 个,它是一个大型多轴评级系统。)但我无法对这些评级进行索引!

有人可以帮助我了解如何更改此设置,以便我可以使用方面搜索进行评级吗?

否则,是否有关于其他模块(五星级除外)的任何建议可以允许对选票进行索引?

谢谢你!

贾斯汀

I'm attempting to sort nodes by ratings using the Search API faceted search with Solr integration. I've already set up fivestar ratings (about 9 per node, its a large multi-axis rating system.) but i'm unable to index these ratings!

Can someone help me understand how to change this so I can use a facet search for ratings?

Otherwise, are there any recommendations on other modules (aside from fivestar) which would allow the votes to be indexed?

Thank you!

Justin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2024-12-13 20:23:40

首先你需要安装facetapi模块——这是用于facets的。
其次,在 hook_update_index 上,您需要向 apachesolr 索引添加评级

<?php function module_apachesolr_update_index(&$document, $node) {
    //add additional offers;
    if (count($node->field_add_offers)) {
      $field = $node->field_add_offers;
      foreach ($field as $lang => $values) {
        foreach ($values as $value) {
          if (isset($value['value'])) {
            $document->setMultiValue('sm_offers', $value['value']);
          }
        }
      }
    }
} ?>

请注意,这只是一个示例。由于多语言站点以及字段数组中“und”键的问题,我运行了 2 个循环。在这里,您也不能添加所有评级,但可以计算每个节点的一个修饰符,该修饰符将用于排序(如果评级中没有该修饰符)

第三,使用 hook_facetapi_facet_info 添加方面

<?php function module_facetapi_facet_info(array $searcher_info) {
  return array(
    'sm_games_facet' => array(
      'name' => 'sm_games_facet',
      'label' => t('games'),
      'description' => t('Filter games'),
      'field' => 'sm_games',
      'field alias' => 'game',
      'query type' => 'term',
      'default widget' => 'facetapi_links',
      'allowed operators' => array(FACETAPI_OPERATOR_OR => TRUE, FACETAPI_OPERATOR_AND => TRUE),
      'default sorts' => array(
        array('display', SORT_ASC),
      ),
    )
);
} ?>

更多有关方面的信息,您可以在facetapi.api.php文件中找到;

第四 - 重新索引内容并在 apachesolr 设置中启用 Facet。

问候,斯拉瓦

first you need install facetapi module -that's for facets.
second, on hook_update_index, you need to add rating to apachesolr index

<?php function module_apachesolr_update_index(&$document, $node) {
    //add additional offers;
    if (count($node->field_add_offers)) {
      $field = $node->field_add_offers;
      foreach ($field as $lang => $values) {
        foreach ($values as $value) {
          if (isset($value['value'])) {
            $document->setMultiValue('sm_offers', $value['value']);
          }
        }
      }
    }
} ?>

Please note, it's just an example. I run 2 loops because of multilingual site and problem with this "und" key in field array. Here also you can not add all ratings, but calculate, for instance,one modifier per node, which will be used for sorting (if you don't have that one in ratings)

Third, add facets with using hook_facetapi_facet_info

<?php function module_facetapi_facet_info(array $searcher_info) {
  return array(
    'sm_games_facet' => array(
      'name' => 'sm_games_facet',
      'label' => t('games'),
      'description' => t('Filter games'),
      'field' => 'sm_games',
      'field alias' => 'game',
      'query type' => 'term',
      'default widget' => 'facetapi_links',
      'allowed operators' => array(FACETAPI_OPERATOR_OR => TRUE, FACETAPI_OPERATOR_AND => TRUE),
      'default sorts' => array(
        array('display', SORT_ASC),
      ),
    )
);
} ?>

more about facets you can find at facetapi.api.php file;

Forth - reindex content and enable facet in apachesolr settings.

Regards, Slava

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文