Integrating SearchBlox with ColdFusion
XML search results from SearchBlox can be integrated in ColdFusion using the SearchBlox CFML Custom Tag.
Download SearchBlox CFML Custom Tag
| JVM | Size | Download |
|---|---|---|
| 1.4 or 1.5 | 678 KB | searchblox_cfml.zip |
Deployment
To deploy and use the cfx_searchblox custom tag in ColdFusion:
- Download and install SearchBlox
- Install the SearchBlox Evaluation or Paid License ( Note: SearchBlox CFML Custom Tag uses SearchBlox XML search results. This is not available in the SearchBlox FREE Edition. You can use the SearchBlox Paid License or request a 30-day evaluation license from here)
- Start SearchBlox
- Download and unzip searchblox_cfml.zip to the directory C:\CFusionMX7\wwwroot\WEB-INF\classes\
- Start ColdFusion MX 7 Server
- Go to ColdFusion Administrative Console at http://machinename:port/CFIDE/administrator/index.cfm
- Login into ColdFusion Administrative Console
- On the left pane of the screen, click on Server Settings --> Java and JVM
- Add the following to the ColdFusion classpath setting and click "Submit":
C:\CFusionMX7\wwwroot\WEB-INF\classes\searchblox_cfx.jar,C:\CFusionMX7\wwwroot\WEB-INF\classes\xerces.jar - Restart ColdFusion Server. To restart the CFMX 7 server, go to Start->Settings->Control Panel->Administrative Tools->Services Select ColdFusion MX 7 Application Server service. Then click on Action->Restart.
- Login into the ColdFusion Administrative Console and Click on Extensions ->CFX Tags, on the left pane of the screen.
- Click on Register Java CFX, on the right pane of screen.
Set the following parameters and click "Submit"
Tag Name : cfx_sbsearch
Class Name : com.searchblox.tags.cfml.SBSearch - Restart the ColdFusion Server
- The cfx_sbsearch tag is now ready to use in any cfm file.
cfx_sbsearch Tag Reference
Description:
Searches one or more SearchBlox collections.
A collection must be created and indexed before this tag can return search results.
A collection must be created using the SearchBlox Admin Console
Syntax
<cfx_sbsearch
name = "search_name"
query = "search_expression"
sburl = "http://www.searchblox.com/searchblox/servlet/SearchServlet"
cname = "collection_name"
sort = "date"
page = "1"
pagesize = "25"
fe = "UTF-8"
filter = "language:en">
Attributes
| Attribute | Req/Opt | Default | Description |
|---|---|---|---|
| name | Required | Name of the search query |
|
| query | Required | Search query |
|
| sburl | Required | SearchBlox Search Service URL |
|
| page | Optional | 1 |
Search results page number |
| cname | Optional | All |
Valid collection names used by SearchBlox multiple cname must be separated by comma (,)
e.g. : cnn, amazon, news, searchblox |
| pagesize | Optional | Value set using SearchBlox Admin Console |
Number of results per page |
| fe | Optional | UTF-8 |
Encoding of search form |
| filter | Optional | Search criteria to be used as filter |
|
| sort | Optional | relevance |
Search results sorting. The possible values for this attribute are relevance, date and alpha |
Result Columns
| Variable | Description |
|---|---|
| no | Hit number of search result |
| url | Search result document URL |
| lastmodified | Last Modified date of document |
| size | Document size in bytes |
| indexdate | Date the document was indexed |
| title | Title of document |
| alpha | The text used for alphabetical sorting |
| keywords | Keywords contained in document |
| contenttype | The format type of document |
| context | This is the fragment of the content where the search query appears. This is available only when the documents have been indexed with the Keyword-In-Context feature enabled |
| description | The description contained in the document |
| language | Language setting for the document |
| score | The relevance score for the document for this query |
Status Keys
| Variable | Description |
|---|---|
| hits | Number of hits or matches for the query |
| hits | taken to return the results of the search query in seconds |
| query | search query that was used |
| suggest | Spelling suggestions if available |
| filter | Filter that was used |
| sort | indicates how the search results are sorted. The possible values for this attribute are relevance, date and alpha |
| start | The hit or match number of the first search result in this page |
| end | The hit or match number of the last search result in this page |
| currentpage | This indicates the current page number for this set of search results |
| lastpage | This indicates the last possible page number for this set of search results |
| pagesize | Number of search results per page |
Example
<cfx_sbsearch
name = "latestnews"
query = "technology"
sburl = "http://www.searchblox.com/searchblox/servlet/SearchServlet"
cname = "cnn,amazon">
<cfoutput>
Search Results <br>
total : #hits# <br>
time : #time#<br>
query : #query#<br>
suggest : #suggest#<br>
filter : #filter#<br>
sort : #sort#<br>
start : #start#<br>
end : #end#<br>
currentpage : #currentpage#<br>
lastpage : #lastpage#<br>
pagesize : #pagesize#<br>
<hr>
</cfoutput><cfoutput query="latestnews">
url=#url#<br>
title=#title#<br>
score=#score#<br>
context=#context#<br>
size=#size#<br>
<hr>
</cfoutput>
