coldfusionsolrcoldfusion-9cfsearch

How to use custom1,custom2,custom3,custom4 in <cfsearch> w/ Solr?


do custom1, custom2, custom3, custom4 attribute of <cfsearch> work with Solr? The documentation said they're only for Verity MATCHES operator. How to use customX with Solr in <cfsearch>?

Thanks


Solution

  • Yes, they do. Here is an example:

    Building the collection The strings are column names. For example 'keywords' is a valid column in the query "qIndex".

    <cfindex collection = "#arguments.collectionName#"
            action      = "REFRESH"
            type        = "CUSTOM"
            body        = "Show_Name, Title"
            key         = "theKey"
            custom1     = "Show_Description"
            custom2     = "keywords"
            custom3     = "Show_ID"
            custom4     = "Asset_ID"
            title       = "Title"
            query       = "qIndex"
            URLPath     = "theURL" />
    

    Searching the Collection

        <!--- Populate the remaining attributes of the cfsearch tag --->
        <cfif !structKeyExists(arguments, 'searchArgs')>
            <cfset arguments.searchArgs = {
                 collection         = arguments.collectionName
                ,criteria           = "#arguments.term#"
                ,contextPassages    = "1"
                ,contextBytes       = "1024"
                ,suggestions        = "always"
                ,status             = "searchStatus" } />
        </cfif>
        <!--- Force the name of the result as its referenced only internally --->
        <cfset arguments.searchArgs.name = 'qSearchResults' />
    
        <!--- Try to search our collection using Solr --->
        <cfsearch attributecollection="#arguments.searchArgs#" />