Search code examples
indexingroutessolrtypo3

TYPO3 12 with SOLR - readable URL


One of my IndexQueues looks like this

plugin.tx_solr.index.queue {
    pressphotos = 1
    pressphotos {
        type = tx_company_z_pressphotos
        label = myPressphotosLabel
        fields {
            title = title
            datetime_stringS = TEXT
            datetime_stringS {
                field = record_date
                date = Y-m-d
            }
            content = SOLR_CONTENT
            content {
                cObject = COA
                cObject {
                    10 = TEXT
                    10 {
                        field = text
                        noTrimWrap = || |
                    }
                }
            }
            url = TEXT
            url {
                typolink.parameter = {$pid.detail.pressphotos}
                typolink.additionalParams.insertData = 1
                typolink.useCacheHash = 1
                typolink.returnLast = url
                typolink.linkAccessRestrictedPages = 1
            }
        }
    }
}

and it's all well and good. I can search stuff, works like a charm. Only thing "missing" is a nice URL.
I cannot change the name of the table and TYPO3 / SOLR takes it as the value. That's why I got the search result URL:

https://www.my-dev-site.company.com/search/?tx_solr[q]=JohnDoe&photofilter=tx_company_z_pressphotos

and I want there to be a readable variant like &photofilter=myPressphotosLabel instead of the tablename "tx_company_z_pressphotos".

I tried using renderingInstruction but that only changes the output on the frontend, URL still is the same.

plugin {
    tx_solr {
        search {
            faceting = 1
            faceting {
                facets {
                    myfilter{
                        label = Filter
                        field = type

                        renderingInstruction = CASE
                        renderingInstruction {
                            key.field = optionValue

                            tx_company_z_pressphotos= TEXT
                            tx_company_z_pressphotos.value = photofilter
                    
                        }
                    }
                }
            }
        }
    }
}

and I add my filters with this

<input type="checkbox" class="activated" value="">
    <a class="facet solr-ajaxified" href="{s:uri.facet.addFacetItem(facet: facet, facetItem: option)}">
        <f:translate key="solr.content-type.plural.{option.label}" extensionName="myExtension"/> 
    </a>
</input>

I have the TYPO3 documentation for SOLR, IndexQueue and Routing at hand but I don't get what I'm missing. I thought that's what the Indexqueue Label was for but he keeps using the table name. And I couldn't solve it using routing either. In other TYPO3-Routings this was implemented via "aspects", but this doesn't seem to be the working with SOLR.

And on a sidenote: is it possible to replace the "tx_solr[q]" as well? That would be the cherry on top. :)

Thanks.
TZP


Solution

  • queue.[indexConfig].type is a predefined field and can't be modified. A good practice for your use case is defining an additional field typeName or so.

    Then, you only have to reconfigure the filter not using type but typeName

    Example

    plugin.tx_solr {
        search {
            faceting {
                facets {
                    myfilter{
                        field = type_stringS
                    }
                }
            }
        }
        index {
            queue {
                pages {
                    fields {
                        type_stringS = TEXT
                        type_stringS.value = page
                    }
                }
                tx_company_z_pressphotos {
                    fields {
                        type_stringS = TEXT
                        type_stringS.value = myPressphotosLabel
                    }
                }
            }
        }
    }