简体   繁体   中英

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.

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.

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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