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

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

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#" />

Related

cfinvoke with two different methods

I have two cfinvoke, I need to use them in one cfm
<cfinvoke component="cfc/queries" method="getProjects" searchString="#Session.Auth.pref_name#" view="#Session.Auth.view#" returnvariable="Projects">
<cfinvoke component="cfc/queries" method="projectDetails" searchString="#URL.id#" projectsuffix="#URL.suffix#" returnvariable="Details">
to return two queries, but when I coding like this way it's not working.
I'm still new to the ColdFusion and I don't know how to fix that.
Since both functions are in the same CFC, you wouldn't want to use cfinvoke since it recreates the object each time it's called. Instead, use a new or a createObject().
<cfset queries = new location.to.cfc.queriesCFC()>
Then you can just reference the functions.
<cfset Projects =
queries.getProjects(
searchString=session.Auth.pref_name,
view = session.Auth.view
)
>
<cfset Details =
queries.projectDetails(
searchString=url.id,
projectsuffix=url.suffix
)
>
You may want to sanitize url.id and url.suffix before you pass them through. This will help with injection issues.
What does getProjects() do?
We can write like as below,
<!--- Object creation --->
<cfset query = CreateObject("component", "cfc.queries")/>
<!--- Function call --->
<cfset Projects = query.getProjects( searchString = session.Auth.pref_name, view = session.Auth.view )>
<cfset Details = query.projectDetails( searchString = session.Auth.pref_name, view = session.Auth.view )>

Some Functions seems to be not exist when creating new bucket or checking if bucket exists using OpenBD

I am using OpenBD and trying to check whether bucket exists or not on my S3 server, if it is not exist then, to create new bucket. Here's my code:
index.cfm
<cfset request.awsaccess = "zzzzawsaccesszzzz">
<cfset request.awskey = "zzzzzzzzawskeyzzzzzzzz">
<cfset request.datasource="tcs">
<cfset request.region="us-west-2">
<cfscript>
AmazonRegisterdatasource(datasource=request.datasource,awsaccess=request.awsaccess,awskey=request.awskey,region=request.region );
result = AmazonS3listbuckets( datasource=request.datasource );
WriteDump(result);
WriteOutput(result.bucket[1]);
</cfscript>
For the above code I am getting this output:
Now I am adding one more function AmazonS3createbucket(),
<cfscript>
result = AmazonS3createbucket( datasource=request.datasource, bucket="anyBucket" );
</cfscript>
For the above script I am getting error: that No such function exists - amazons3createbucket.. Here's the screenshot:
I am referring the OpenBD Manual to filter these function.
Also faced the same problem while using this functions also:
<cfscript>
result = AmazonS3bucketexists( datasource=request.datasource, bucket="anyBucket" );
</cfscript>
Have you tried using an alternate syntax?
<cfscript>
result = AmazonS3bucketexists(ArgumentCollection = {
datasource : request.datasource,
bucket : "anyBucket"
});
</cfscript>

ColdFusion hash_hmac256 output format / encoding

I have this script to output an hash_hmac similar function in CFML:
<cfprocessingdirective pageencoding = "iso-8859-1">
<cfset msg = "AgostinoSqueglinPiccolinMonachin">
<cfset jMsg = JavaCast("string",msg).getBytes() />
<cfset jKey = JavaCast("string","cicciolin").getBytes() />
<cfset key = createObject("java","javax.crypto.spec.SecretKeySpec") />
<cfset mac = createObject("java","javax.crypto.Mac") />
<!--- this line had to be changed to the 256 version --->
<cfset key = key.init(jKey,"hmacSHA256") />
<cfset mac = mac.getInstance(key.getAlgorithm()) />
<cfset mac.init(key) />
<cfset mac.update(jMsg) />
<cfset cc = mac.doFinal()>
<cfset strBase64Value = ToString( cc,"Utf-8" ) />
<cfscript>
writeDump(msg);
writeDump(strBase64Value);
</cfscript>
This should output the same result as this php:
<?php
$uu = hash_hmac('sha256', "AgostinoSqueglinPiccolinMonachin", "cicciolin", true);
echo $uu;
?>
But I got this different result, due probably to an format error:
ColdFusion : �GK�襍}Ÿ�}��B�}9w�(���u�m�
PHP: ÐGKÒè¥}Ÿ»}©ì¬B§}9w´(«æüu§mÃ
Seems some characters does not output in the correct way.
How can I solve this?
UPDATE:
The solution works perfectly, but there are other problem if I try to encode new line:
for example
Php:
$sign = "GET\n" . "agostinsqueglin" . "". "piccolin";
$uu = base64_encode(hash_hmac('sha256', $sign, "cicciolin", true));
If I try with:
sign = "GET#chr(13)##chr(10)#" & "agostinsqueglin" & "" & "piccolin";
I got two different results.
This is due to the way coldfusion handling "\n" newline...
The code you've provided is a little more long-winded than it needs to be, and ... well, here's an improved version:
<cfscript>
msg = "AgostinoSqueglinPiccolinMonachin";
key = "cicciolin";
algorithm = "HmacSHA256";
encoding = "iso-8859-1";
secret = createObject('java',"javax.crypto.spec.SecretKeySpec").init( charsetDecode(key,encoding) , algorithm );
mac = createObject('java',"javax.crypto.Mac").getInstance(algorithm);
mac.init(secret);
digest = mac.doFinal( charsetDecode(msg,encoding) );
writeDump( msg );
writeDump( toString(digest,encoding) );
</cfscript>
This is based on the answer and comments here: Calculate HMAC-SHA256 digest in ColdFusion using Java
Obviously for regular use it should be wrapped up in a suitable function.
It looks like you're trying to output a UTF-8 string while your processingdirective is set to iso-8859-1. Try changing it:
<cfprocessingdirective pageencoding = "UTF-8">

ColdFusion 9 datasources defaulting to enterprise

I have a ColdFusion instance being run under enterprise, but for some reason it ignores the local data source. It will only connect if I put the data source at the enterprise level.
I've even tried the following code and it only returns the data sources that are declared at the instance manager, not the instance itself.
<cfset factory = createObject("java", "coldfusion.server.ServiceFactory")>
<cfset datasources = factory.getDataSourceService().getDatasources()>
<cfloop collection="#datasources#" item="dsnName">
#dsnName#<br>
</cfloop>
Any help would be greatly appreciated.
These should help you figure out which instance you are on:
<cfscript>
loc = {};
loc.machineName = createObject('java','java.net.InetAddress').localhost.getCanonicalHostName();
loc.machineName2 = createObject('java','java.net.InetAddress').localhost.getHostName();
loc.hostAddress = createObject('java','java.net.InetAddress').localhost.getHostAddress();
loc.instanceName = createObject('java','jrunx.kernel.JRun').getServerName();
writeDump( var: loc );
</cfscript>
If you are having problems getting the datasources you might need to authenticate first with your cf administrator password like so:
createObject('component','CFIDE.adminapi.administrator').login('your-password');
There is a datasourceExists(), verifyDatasource() and getDatasource() method on the data source service that you might find handy:
<cfscript>
loc = {};
loc.dss = createObject('java','coldfusion.server.ServiceFactory').getDataSourceService();
loc.datasources = loc.dss.getDatasources();
loc.exists = loc.dss.datasourceExists('your-dsn');
loc.verified = loc.dss.verifyDatasource('your-dsn');
loc.datasource = loc.dss.getDatasource('your-dsn');
writeDump( var: loc );
</cfscript>

How do I create Search Engine Safe URLs in Fusebox 5.1 noxml?

How do I create Search Engine Safe URLs in Fusebox 5.1 noxml?
For instance, I want this:
http://www.site.com/index.cfm/app.welcome/
Instead of this:
http://www.site.com/index.cfm?fuseaction=app.welcome
Fusebox 5.1 is suppose to be able to do this. I've read this article, but it only applies to the xml version. I know so little, I am not sure where to start. How do I do it with the noxml version of fusebox?
Update:
It looks like I need to add this to my Application.cfc file. Still not working though...
FUSEBOX_PARAMETERS.myself = "index.cfm/fuseaction/";
FUSEBOX_PARAMETERS.queryStringStart = "/";
FUSEBOX_PARAMETERS.queryStringSeparator = "/";
FUSEBOX_PARAMETERS.queryStringEqual = "/";
Fusebox 5.1 allows you to use SES URLs by allowing you to change ? & to /. You still need to provide your own rewriter. However, if you are able to upgrade to 5.5 it supposedly handles rewriting, too.
Example Rewriter
http://www.fusebox.org/forums/messageview.cfm?catid=31&threadid=6117&STARTPAGE=2
<cfscript>
// SES converter
qrystring = ArrayNew(1);
if ( Find("/",cgi.path_info) eq 1 and Find("/#self#",cgi.path_info) eq 0 ) {
qrystring = cgi.path_info;
} else if ( Len(Replace(cgi.path_info,"#self#/","")) gt 0 ) {
qrystring = ListRest(Replace(cgi.path_info,"#self#/","#self#|"),"|");
} else if ( FindNoCase("#self#/",cgi.script_name) gt 0 ) {
qrystring = ListRest(Replace(cgi.script_name,"#self#/","#self#|"),"|");
}
arQrystring = ListToArray(cgi.path_info,'/');
for ( q = 1 ; q lte ArrayLen(arQrystring) ; q = q + 2 ) {
if ( q lte ArrayLen(arQrystring) - 1 and not ( arQrystring[ Q ] is myFusebox.getApplication().fuseactionVariable and arQrystring[ q+1] is self ) ) {
attributes['#arQrystring[ Q ]#'] = arQrystring[ q+1];
}
}
</cfscript>
If you choose to use Coldcourse...
http://coldcourse.riaforge.com
Below will help you get started. You can ignore server-side rewriting (ISAPI for IIS) if you want /index.cfm/circuit/action/ formatted URLs. But if you want /circuit/action/ or /blah/ you'll need to make it server side.
application.cfc
Put on onApplicationStart (or onRequestStart for testing) to put in memory.
<cfset application.coldcourse = createObject("component","components.util.coldcourse").init("/config/coldcourse.config.cfm")>
index.cfm
Place this before the framework loads
<cfset application.coldcourse.dispatch(cgi.path_info, cgi.script_name) />
coldcourse.config.cfm (example config)
<cfset setEnabled(true)>
<cfset setFrameworkEvent("action")>
<cfset setFrameworkSeparator(".")>
<cfset setFrameworkActionDefault("")>
<cfset setUniqueURLs(true)>
<cfset setBaseURL("http://www.mysite.com/index.cfm")>
<!--- CUSTOM COURSES GO HERE (they will be checked in order) --->
<!--- for http://www.mysite.com/about/ pages --->
<cfset addCourse("components")>
<cfset addCourse(pattern="about",controller="main",action="about")>
<cfset addCourse(pattern="contact",controller="main",action="contact")>
<cfset addCourse(pattern="help",controller="main",action="help")>
<!--- If nothing else matches, fall back to the standard courses (you probably shouldn't edit these) --->
<cfset addCourse(":controller/:action/:id")>
<cfset addCourse(":controller/:action")>
<cfset addCourse(":controller")>
Install ISAPI Rewrite
Make sure you are using the correct rewrite regex because version 2.0 is different from 3.0.
Example for 2.0 script:
# Coldcourse URL Rewrite for CF
IterationLimit 0
RewriteRule ^(/.+/.+/.*\?.+\..*)$ /index.cfm/$1
RewriteRule ^(/[^.]*)$ /index.cfm/$1
Disable Check if File Exists on web server
Do this for IIS if you're getting a 404 error in your web logs.
Open the IIS manager
Right click on a site and choose Properties
Click the Home Directory tab
Click the Configuration button
(lower right of dialog)
Click the .cfm extension and choose
'Edit'
The lower left checkbox: "Check that
File Exists"
riaforge is your friend:
http://coldcourse.riaforge.org/