|
33 | 33 |
|
34 | 34 | <cfscript>
|
35 | 35 | // create an update server instance
|
36 |
| - THIS.solrUpdateServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer").init(THIS.solrURL,THIS.queueSize,THIS.threadCount); |
| 36 | + THIS.solrUpdateServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer").init(THIS.solrURL,THIS.queueSize,THIS.threadCount); |
37 | 37 |
|
38 | 38 | // create a query server instance
|
39 |
| - THIS.solrQueryServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.CommonsHttpSolrServer").init(THIS.solrURL); |
| 39 | + THIS.solrQueryServer = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.impl.HttpSolrServer").init(THIS.solrURL); |
40 | 40 |
|
41 | 41 | // enable binary
|
42 | 42 | if (ARGUMENTS.binaryEnabled) {
|
|
78 | 78 |
|
79 | 79 | <!--- we do this instead of making the user call java functions, to work around a CF bug --->
|
80 | 80 | <cfset response = THIS.solrQueryServer.query(thisQuery) />
|
81 |
| - <cfset ret.results = response.getResults() / > |
| 81 | + <cfset ret.results = response.getResults() / > |
82 | 82 | <cfset ret.totalResults = response.getResults().getNumFound() / >
|
| 83 | + |
| 84 | + <!--- Spellchecker Response ---> |
83 | 85 | <cfif NOT isNull(response.getSpellCheckResponse())>
|
84 | 86 | <cfset suggestions = response.getSpellCheckResponse().getSuggestions() />
|
85 | 87 | <cfset ret.collatedSuggestion = response.getSpellCheckResponse().getCollatedResult() />
|
|
96 | 98 | <cfset arrayAppend(ret.spellCheck,thisSuggestion) />
|
97 | 99 | </cfloop>
|
98 | 100 | </cfif>
|
99 |
| - |
100 |
| - <cfreturn duplicate(ret) /> <!--- duplicate clears out the case-sensitive structure ---> |
| 101 | + |
| 102 | + <!--- Highlighting Response ---> |
| 103 | + <cfif NOT isNull(response.getHighlighting())> |
| 104 | + <cfloop array="#ret.results#" index="currentResult"> |
| 105 | + <!--- ***"title" is used for the highlighting example. Change "title" to the field your highlighting result will be in for your use.---> |
| 106 | + <cfset currentResult.highlightingResult = response.getHighlighting().get("#currentResult.get('id')#").get("title") /> |
| 107 | + </cfloop> |
| 108 | + </cfif> |
| 109 | + <cfreturn duplicate(ret) /> <!--- duplicate clears out the case-sensitive structure ---> |
| 110 | +</cffunction> |
| 111 | + |
| 112 | +<cffunction name="getAutoSuggestResults" access="remote" returntype="any" output="false"> |
| 113 | + <cfargument name="term" type="string" required="no"> |
| 114 | + <cfif Len(trim(ARGUMENTS.term)) gt 0> |
| 115 | + <!--- Remove any leading spaces in the search term ---> |
| 116 | + <cfset ARGUMENTS.term = "#trim(ARGUMENTS.term)#"> |
| 117 | + <cfscript> |
| 118 | + h = new http(); |
| 119 | + h.setMethod("get"); |
| 120 | + h.setURL("#THIS.solrURL#/suggest?q=#ARGUMENTS.term#"); |
| 121 | + local.suggestResponse = h.send().getPrefix().Filecontent; |
| 122 | + if (isXML(local.suggestResponse)){ |
| 123 | + local.XMLResponse = XMLParse(local.suggestResponse); |
| 124 | + local.wordList = ""; |
| 125 | + if (ArrayLen(XMLResponse.response.lst) gt 1 AND structKeyExists(XMLResponse.response.lst[2].lst, "lst")){ |
| 126 | + local.wordCount = ArrayLen(XMLResponse.response.lst[2].lst.lst); |
| 127 | + For (j=1;j LTE local.wordCount; j=j+1){ |
| 128 | + if(j eq local.wordCount){ |
| 129 | + local.resultCount = XMLResponse.response.lst[2].lst.lst[j].int[1].XmlText; |
| 130 | + local.resultList = arrayNew(1); |
| 131 | + For (i=1;i LTE local.resultCount; i=i+1){ |
| 132 | + arrayAppend(local.resultList, local.wordList & XMLResponse.response.lst[2].lst.lst[j].arr.str[i].XmlText); |
| 133 | + } |
| 134 | + }else{ |
| 135 | + local.wordList = local.wordList & XMLResponse.response.lst[2].lst.lst[j].XMLAttributes.name & " "; |
| 136 | + } |
| 137 | + } |
| 138 | + //sort results aphabetically |
| 139 | + if (ArrayLen(local.resultList)){ |
| 140 | + ArraySort(local.resultList,"textnocase","asc"); |
| 141 | + } |
| 142 | + }else{ |
| 143 | + local.resultList = ""; |
| 144 | + } |
| 145 | + }else{ |
| 146 | + local.resultList = ""; |
| 147 | + } |
| 148 | + </cfscript> |
| 149 | + <cfelse> |
| 150 | + <cfset local.resultList = ""> |
| 151 | + </cfif> |
| 152 | + <cfreturn local.resultList /> |
101 | 153 | </cffunction>
|
102 | 154 |
|
103 | 155 | <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.">
|
|
163 | 215 | <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" />
|
164 | 216 | <cfargument name="idFieldName" required="false" type="string" default="id" hint="The name of the unique id field in the Solr schema" />
|
165 | 217 | <cfset var docRequest = THIS.javaLoaderInstance.create("org.apache.solr.client.solrj.request.ContentStreamUpdateRequest").init("/update/extract") />
|
166 |
| - <cfset var thisKey = "" /> |
167 |
| - <cfset docRequest.addFile(createObject("java","java.io.File").init(ARGUMENTS.file)) /> |
| 218 | + <cfset var thisKey = "" /> |
| 219 | + <cfset docRequest.addFile(createObject("java","java.io.File").init(ARGUMENTS.file),"application/octet-stream") /> |
168 | 220 | <cfset docRequest.setParam("literal.#arguments.idFieldName#",ARGUMENTS.id) />
|
169 | 221 | <cfif ARGUMENTS.saveMetadata>
|
170 | 222 | <cfset docRequest.setParam("uprefix",metadataPrefix) />
|
|
0 commit comments