Skip to content

Commit

Permalink
Updates to CFSolrLib for Solr 4.0.0. Updated jar files for SolrJ, upd…
Browse files Browse the repository at this point in the history
…ated version of JavaLoader, included JQueryUI for JQuery AutoComplete and included Solr 4.0.0.
  • Loading branch information
Jim Leether committed Nov 7, 2012
1 parent 3d2a655 commit 4cdb92d
Show file tree
Hide file tree
Showing 712 changed files with 89,581 additions and 26,354 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/solr-server/solr/data/index/
/solr-server/solr/data/spellcheck/
/solr-server/solr/collection1/data/index/
/solr-server/solr/collection1/data/spellcheck/
/solr-server/solr/collection1/data/autosuggest/

.DS_Store
34 changes: 23 additions & 11 deletions Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@
<cfscript>
// load libraries needed for solrj
var paths = arrayNew(1);
arrayAppend(paths,expandPath("solrj-lib/commons-io-1.4.jar"));
arrayAppend(paths,expandPath("solrj-lib/commons-codec-1.4.jar"));
arrayAppend(paths,expandPath("solrj-lib/slf4j-api-1.5.5.jar"));
arrayAppend(paths,expandPath("solrj-lib/slf4j-jdk14-1.5.5.jar"));
arrayAppend(paths,expandPath("solrj-lib/commons-httpclient-3.1.jar"));
arrayAppend(paths,expandPath("solrj-lib/apache-solr-solrj-3.2.0.jar"));
arrayAppend(paths,expandPath("solrj-lib/geronimo-stax-api_1.0_spec-1.0.1.jar"));
arrayAppend(paths,expandPath("solrj-lib/wstx-asl-3.2.7.jar"));
arrayAppend(paths,expandPath("solrj-lib/jcl-over-slf4j-1.5.5.jar"));
arrayAppend(paths,expandPath("solrj-lib/solr-solrj-4.0.0-BETA.jar"));
arrayAppend(paths,expandPath("solrj-lib/commons-io-2.4.jar"));
arrayAppend(paths,expandPath("solrj-lib/commons-codec-1.7.jar"));
arrayAppend(paths,expandPath("solrj-lib/slf4j-api-1.6.6.jar"));
arrayAppend(paths,expandPath("solrj-lib/slf4j-jdk14-1.6.6.jar"));
arrayAppend(paths,expandPath("solrj-lib/jcl-over-slf4j-1.6.6.jar"));
arrayAppend(paths,expandPath("solrj-lib/log4j-over-slf4j-1.6.6.jar"));
arrayAppend(paths,expandPath("solrj-lib/httpclient-4.2.1.jar"));
arrayAppend(paths,expandPath("solrj-lib/httpcore-4.2.2.jar"));
arrayAppend(paths,expandPath("solrj-lib/httpmime-4.2.1.jar"));
arrayAppend(paths,expandPath("solrj-lib/stax-api-1.0.1.jar"));
arrayAppend(paths,expandPath("solrj-lib/wstx-asl-4.0.0.jar"));
arrayAppend(paths,expandPath("solrj-lib/tika-app-1.2.jar"));

// create an application instance of JavaLoader
APPLICATION.javaloader = createObject("component", "javaloader.JavaLoader").init(paths);

APPLICATION.javaloader = createObject("component", "javaloader.JavaLoader").init(loadpaths=paths, loadColdFusionClassPath=true);
// setup tika
APPLICATION.tika = APPLICATION.javaloader.create("org.apache.tika.Tika").init();

</cfscript>
</cffunction>

<cffunction name="onRequestStart">
<cfif structKeyExists(url, "reinit")>
<cfset onApplicationStart()>
</cfif>
</cffunction>
12 changes: 12 additions & 0 deletions autoSuggestExample.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script src="js/jquery-1.7.2.js"></script>
<script src="js/jqueryui/jqueryui-1.8.22.js"></script>
<link rel="stylesheet" href="css/jqueryui/jqueryui-1.8.22.css" type="text/css" />
<script type="text/javascript">
$(function() {
$("#keyword").autocomplete({
source: "components/cfsolrlib.cfc?method=getAutoSuggestResults&returnformat=json"
});
});
</script>

Keyword: <input id="keyword" />
66 changes: 59 additions & 7 deletions components/cfsolrlib.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

<cfscript>
// create an update server instance
THIS.solrUpdateServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer").init(THIS.solrURL,THIS.queueSize,THIS.threadCount);
THIS.solrUpdateServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer").init(THIS.solrURL,THIS.queueSize,THIS.threadCount);

// create a query server instance
THIS.solrQueryServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.CommonsHttpSolrServer").init(THIS.solrURL);
THIS.solrQueryServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.HttpSolrServer").init(THIS.solrURL);

// enable binary
if (ARGUMENTS.binaryEnabled) {
Expand Down Expand Up @@ -78,8 +78,10 @@

<!--- we do this instead of making the user call java functions, to work around a CF bug --->
<cfset response = THIS.solrQueryServer.query(thisQuery) />
<cfset ret.results = response.getResults() / >
<cfset ret.results = response.getResults() / >
<cfset ret.totalResults = response.getResults().getNumFound() / >

<!--- Spellchecker Response --->
<cfif NOT isNull(response.getSpellCheckResponse())>
<cfset suggestions = response.getSpellCheckResponse().getSuggestions() />
<cfset ret.collatedSuggestion = response.getSpellCheckResponse().getCollatedResult() />
Expand All @@ -96,8 +98,58 @@
<cfset arrayAppend(ret.spellCheck,thisSuggestion) />
</cfloop>
</cfif>

<cfreturn duplicate(ret) /> <!--- duplicate clears out the case-sensitive structure --->

<!--- Highlighting Response --->
<cfif NOT isNull(response.getHighlighting())>
<cfloop array="#ret.results#" index="currentResult">
<!--- ***"title" is used for the highlighting example. Change "title" to the field your highlighting result will be in for your use.--->
<cfset currentResult.highlightingResult = response.getHighlighting().get("#currentResult.get('id')#").get("title") />
</cfloop>
</cfif>
<cfreturn duplicate(ret) /> <!--- duplicate clears out the case-sensitive structure --->
</cffunction>

<cffunction name="getAutoSuggestResults" access="remote" returntype="any" output="false">
<cfargument name="term" type="string" required="no">
<cfif Len(trim(ARGUMENTS.term)) gt 0>
<!--- Remove any leading spaces in the search term --->
<cfset ARGUMENTS.term = "#trim(ARGUMENTS.term)#">
<cfscript>
h = new http();
h.setMethod("get");
h.setURL("#THIS.solrURL#/suggest?q=#ARGUMENTS.term#");
local.suggestResponse = h.send().getPrefix().Filecontent;
if (isXML(local.suggestResponse)){
local.XMLResponse = XMLParse(local.suggestResponse);
local.wordList = "";
if (ArrayLen(XMLResponse.response.lst) gt 1 AND structKeyExists(XMLResponse.response.lst[2].lst, "lst")){
local.wordCount = ArrayLen(XMLResponse.response.lst[2].lst.lst);
For (j=1;j LTE local.wordCount; j=j+1){
if(j eq local.wordCount){
local.resultCount = XMLResponse.response.lst[2].lst.lst[j].int[1].XmlText;
local.resultList = arrayNew(1);
For (i=1;i LTE local.resultCount; i=i+1){
arrayAppend(local.resultList, local.wordList & XMLResponse.response.lst[2].lst.lst[j].arr.str[i].XmlText);
}
}else{
local.wordList = local.wordList & XMLResponse.response.lst[2].lst.lst[j].XMLAttributes.name & " ";
}
}
//sort results aphabetically
if (ArrayLen(local.resultList)){
ArraySort(local.resultList,"textnocase","asc");
}
}else{
local.resultList = "";
}
}else{
local.resultList = "";
}
</cfscript>
<cfelse>
<cfset local.resultList = "">
</cfif>
<cfreturn local.resultList />
</cffunction>

<cffunction name="queryParam" access="public" output="false" returnType="array" hint="Creates a name/value pair and appends it to the array. This is a helper method for adding to your index.">
Expand Down Expand Up @@ -163,8 +215,8 @@
<cfargument name="boost" required="false" type="struct" hint="A struct of boost values. The struct key will be the field name to boost, and its value is the numeric boost value" />
<cfargument name="idFieldName" required="false" type="string" default="id" hint="The name of the unique id field in the Solr schema" />
<cfset var docRequest = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.request.ContentStreamUpdateRequest").init("/update/extract") />
<cfset var thisKey = "" />
<cfset docRequest.addFile(createObject("java","java.io.File").init(ARGUMENTS.file)) />
<cfset var thisKey = "" />
<cfset docRequest.addFile(createObject("java","java.io.File").init(ARGUMENTS.file),"application/octet-stream") />
<cfset docRequest.setParam("literal.#arguments.idFieldName#",ARGUMENTS.id) />
<cfif ARGUMENTS.saveMetadata>
<cfset docRequest.setParam("uprefix",metadataPrefix) />
Expand Down
Binary file added css/jqueryui/images/ui-bg_flat_0_aaaaaa_40x100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-bg_flat_75_ffffff_40x100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-bg_glass_55_fbf9ee_1x400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-icons_222222_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-icons_2e83ff_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-icons_454545_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-icons_888888_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/jqueryui/images/ui-icons_cd0a0a_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4cdb92d

Please sign in to comment.