【问题标题】:Solr Indexing - Manipulating the search resultSolr 索引 - 操纵搜索结果
【发布时间】:2015-04-29 10:26:59
【问题描述】:

我正在使用 TYPO3 Solr 扩展,我对 solr 结果集的操作有一些疑问。

我添加了一个特殊的配置来索引我的页面树中的一些特定页面。即以标签“Expertise%”开头的页面。我已经成功添加了这个。并且索引正在成功地解决我们的任何问题。但我想要实现的是,我想在搜索结果中添加父页面标题。即

这是页面树

|---- 1.00.100 (parent page)
|--Subpage 1
|--Subpage 2
|--Expertise
|--Test page`

而且在solr的搜索结果中应该是

1.00.100 - 专业知识

这在 TYPO3 Solr 中是否可行。是否有任何钩子或信号槽可用于实现这一点?

试过这个,但似乎不适合我?

  plugin.tx_solr.index.queue.expertise_offered = 1
  plugin.tx_solr.index.queue.expertise_offered {
    table = pages
          additionalWhereClause = doktype = 1 AND no_search = 0 AND title LIKE '%Expertise offered%'
            fields {
            title = title
            content = CONTENT
            parentPageTitle_stringS = CONTENT
            parentPageTitle_stringS {
                    table = pages
                    select {
                    selectFields = title
                    where = uid = ###pid###
                    }
                    markers {
                           pid.data = field:pid
                    }
        }
        content {
            table = tt_content
            select {
                selectFields = header, bodytext
            }
            renderObj = COA
            renderObj {
                10 = TEXT
                10.field = header
                # This removes HTML tags
                11 = SOLR_CONTENT
                11.field = bodytext
            }
        }
        url = TEXT
        url.typolink.parameter = TEXT
        url.typolink.parameter.field = uid
    }
  }

【问题讨论】:

    标签: typo3 typoscript typo3-6.2.x


    【解决方案1】:

    您可能不需要任何挂钩或信号槽。你可以这样做:

    1. 将父页面的标题添加到您的索引配置中。它没有字段,但您可以向 SOLR 文档动态添加字段。这是通过在具有特定后缀的字段中发送数据来完成的,该后缀确定字段类型。

      例如:在索引配置中将字段 parentPageTitle_stringS 设置为父页面标题会在索引文档中创建一个类型为 string 的新存储单值字段。

      填写此字段可能如下所示:

      plugin.tx_solr {
          index {
              queue {
                  <yourindexconfigname> = 1
                  <yourindexconfigname> {
                      table = pages
      
                      fields {
                          parentPageTitle_stringS = CONTENT
                          parentPageTitle_stringS {
                              # Build a query here to retrieve
                              # the parent page title.
                          }
                      }
                  }
              }
          }
      }
      
    2. 在您的搜索结果模板中,您可以使用标记###RESULT_DOCUMENT.parentPageTitle_stringS### 来检索字段。

    可以在EXT:solr/Resources/Solr/typo3cores/conf/general_schema_fields.conf 中找到可用的字段类型,从第 157 行开始(此处参考版本 3.0.0)。

    如果你想让结果被很好地索引,你当然应该使用string以外的类型。

    【讨论】:

    • plugin.tx_solr.index.queue.expertise_offered = 1 plugin.tx_solr.index.queue.expertise_offered { table = pages fields { title = title content = CONTENT parentPageTitle_stringS = CONTENT parentPageTitle_stringS { table = pages select { selectFields = title where = uid = ###pid### } markers { pid.data = field:pid } } content { table = tt_content select { selectFields = header, bodytext } renderObj = COA renderObj { } } } }这个我试过了,好像不行??
    • 不确定到底是什么问题,但可能是内容对象中缺少pidInList-设置。尝试在 solr 配置之外构建该对象并在前端打印它以进行调试或类似的事情。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 2012-06-20
    • 1970-01-01
    相关资源
    最近更新 更多