简体   繁体   English

“plugin.tx_solr.query.fields”是如何工作的?

[英]How does "plugin.tx_solr.query.fields " work?

I need to be able to search by the News Tags property.我需要能够通过新闻标签属性进行搜索。

This typoscript is working fine, but when I input a tag (exact same string) from a News into Solr's search box I don't get any results.这个拼写错误工作正常,但是当我将新闻中的标签(完全相同的字符串)输入到 Solr 的搜索框中时,我没有得到任何结果。

According to "lorenz" in this answer I neede to add my dynamic fields (I believe) to "plugin.tx_solr.query.fields" but this poor documentation doesn't help me.根据这个答案中的“lorenz”,我需要将我的动态字段(我相信)添加到“plugin.tx_solr.query.fields”,但是这个糟糕的文档对我没有帮助。

I added the following to that typoscript but when I use the searchbox to look for exactly the name of my tag I get no results.我在该拼写错误中添加了以下内容,但是当我使用搜索框准确查找我的标签名称时,我没有得到任何结果。

(plugin.tx_solr.query.fields = tags_stringM) (plugin.tx_solr.query.fields = tags_stringM)

Does anybody have any code that I can use as an example?有人有任何代码可以用作示例吗?

plugin.tx_solr{
    search {
        initializeWithEmptyQuery = 1
        showResultsOfInitialEmptyQuery = 1
        showEmptyFacets = 1
        faceting = 1
        faceting {
            facets {
                mediatype {
                    label = Facet dos
                    field = categorytitle_stringS
                }
            }
        }
    }
    index.queue {

        custom_news = 1
        custom_news {
            table = tx_news_domain_model_news

            fields {
                abstract = teaser

                author = author
                authorEmail_stringS = author_email

                title = title

                datetime_stringS = TEXT
                datetime_stringS {
                    field = datetime
                    date = d.m.Y H:i
                }

                titlehr_stringS = TEXT
                titlehr_stringS {
                    field = title_hr
                }

                teaser_stringS = TEXT
                teaser_stringS {
                    field = teaser
                }
                
                datetime_dateS = TEXT
                datetime_dateS {
                    field = datetime
                    date = Y-m-d\TH:i:s\Z
                }

                content = SOLR_CONTENT
                content {
                    cObject = COA
                    cObject {
                        10 = TEXT
                        10 {
                            field = bodytext
                            noTrimWrap = || |
                        }
                        20 = TEXT
                        20 {
                            field = tags_stringM
                            noTrimWrap = || |
                        }
                    }
                }

                categorytitle_stringS = SOLR_RELATION
                categorytitle_stringS {
                    localField = categories
                    multiValue = 1
                }

                categoryuid_stringS = SOLR_RELATION
                categoryuid_stringS {
                    localField = categories
                    foreignLabelField = uid
                    multiValue = 1
                }
                
                keywords = SOLR_MULTIVALUE
                keywords {
                    field = keywords
                }

                tags_stringM = SOLR_RELATION
                tags_stringM {
                    localField = tags
                    label = Tags
                    multiValue = 1
                }

                tagshr_stringM = SOLR_RELATION
                tagshr_stringM {
                    localField = tags
                    label = Tags hr
                    foreignLabelField = title_hr
                    multiValue = 1
                }

                mediatypehr_intS = TEXT
                mediatypehr_intS {
                    field = media_type_hr
                }

                mediatypede_intS = TEXT
                mediatypede_intS {
                    field = media_type_de
                }

                image_stringS = FILES
                image_stringS {
                    references {
                        table = tx_news_domain_model_news
                        uid.field = uid
                        fieldName = fal_media
                    }

                    begin = 0
                    maxItems = 1

                    renderObj = IMG_RESOURCE
                    renderObj {
                        file.import.data = file:current:publicUrl
                        file.maxW = 330
                        #wrap = |
                    }
                }

                url = CASE
                url {
                    key.field = type

                    # Internal
                    1 = TEXT
                    1 {
                        if.isTrue.field = internalurl
                        typolink.parameter.field = internalurl
                        typolink.useCacheHash = 1
                        typolink.returnLast = url
                    }

                    # External
                    2 = TEXT
                    2 {
                        if.isTrue.field = externalurl
                        field = externalurl
                    }

                    default = TEXT
                    default {
                        typolink.parameter = {$plugin.tx_news.settings.detailPid}
                        typolink.additionalParams = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]={field:uid}&L={field:__solr_index_language}
                        typolink.additionalParams.insertData = 1
                        typolink.useCacheHash = 1
                        typolink.returnLast = url
                    }
                }
            }

            attachments = 1
            attachments {
                fields = fal_related_files
                fileExtensions = *
            }
        }
    }
}

plugin.tx_solr.logging.indexing.queue.news = 1

Aside from defining the fields for indexing you also need to declare these fields as relevant for search.除了定义用于索引的字段之外,您还需要将这些字段声明为与搜索相关。 (and with a weight how important they are for searching) (以及它们对搜索的重要性)

One possible solution could be like in this part of typoscript:一种可能的解决方案可能类似于这部分打字稿:

plugin {
   tx_solr {
      search {
         query {
            queryFields := addToList(categorytitle_stringS^2.0,keywords2.0,tags_stringM^2.0, tagshr_stringM^2.0)
         }
      }
   }
}

see manual手册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM