Search code examples
coldfusionsolrrailocfml

Can you create a Solr collection in Railo with script?


ColdFusion 10 now supports this syntax for creating a Solr collection:

cfcollection supports script style syntax:

new collection().CREATE(collection="<collection_name>", engine="solr", path="<path to the solr directory>"); 

Is some sort of syntax like this available in Railo 4?

I keep getting an error saying:

invalid component definition, can't find collection

If not, can this be set up as a UDF so that I can call it from a script-based component?


Solution

  • The latest beta of Railo 4.0 currently implements the following objects:

    • Feed
    • Ftp
    • Http
    • Mail
    • Query

    So, the answer is no - there is no "collection" object.
    (You can of course raise a feature request for adding that.)

    However, there is an alternative - in Railo pretty much all the tags can be reproduced in script form.

    You can write:

    <cftagname attributes />
    

    as

    <cfscript>
        tagname attributes ;
    </cfscript>
    

    Or for tags with bodies:

    <cftagname attributes >
        ...
    </cftagname>
    

    becomes

    <cfscript>
        tagname attributes
        {
            ...
        }
    </cfscript>
    

    So simply factor your cfcollection tag in this form and it should work fine.