Title:
Bug 83970:It appears that CFINDEX may only delete one document at a time unless you pass a query to it like this:<CFSEARCH COLLECTION="training" NAME="DeleteCertainKeys" CRITERIA=""><CFINDEX QUERY="DeleteCertai
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Travis Walters / Travis Walters (Travis Walters)
Created: 08/28/2010
Components: Text Search, Solr
Versions: 9.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 / 275714
Priority/Frequency: Minor / Unknown
Locale/System: English / Platforms All
Vote Count: 1
Problem:
It appears that CFINDEX may only delete one document at a time unless you pass a query to it like this:<CFSEARCH COLLECTION="training" NAME="DeleteCertainKeys" CRITERIA=""><CFINDEX QUERY="DeleteCertainKeys" ACTION="DELETE" COLLECTION="training" KEY="KEY">Why should you have to do a CFSEARCH just to delete the documents when you can do something like this:<cfset myURL = 'http://#SOLR_SERVER_HOST#:#SOLR_SERVER_PORT#/solr/#collectionName#/update?stream.body='><cfset myURL = '#myURL##URLEncodedFormat("<delete><query>custom2:54</query></delete>")#'><cfhttp method="Get" url="#myURL#" resolveurl="Yes" throwonerror="yes" /><cfset myURL = 'http://#SOLR_SERVER_HOST#:#SOLR_SERVER_PORT#/solr/#collectionName#/update?stream.body=%3Ccommit/%3E'><cfhttp method="Get" url="#myURL#" resolveurl="Yes" throwonerror="yes" />I think when the CFINDEX action parameter is set to delete, you should be able to pass in a query instead of just a key. If you do this, you can avoid the extra CFSEARCH altogether.
Method:
<cflock type="EXCLUSIVE" name="solr" timeout="120">
<cfif collectionexists("solr4","solr")>
<cfindex action="purge" collection="solr4" >
<cfelse>
<cfcollection action="CREATE" collection="solr4" engine="solr" path="#solrdirectory#" >
</cfif>
<!--- recurse=NO---->
<CFINDEX COLLECTION = "solr4" action="refresh" TYPE = "path" key="#datadir#/text" extensions =".htm,.txt"
recurse="no" status="status1" >
<cfset sleep(300)>
<cfsearch collection="solr4" criteria="" name="n">
<cfdump var="#n#">
<cfindex collection="solr4" action="delete" criteria="test">
<cfset sleep(1300)>
<cfindex action="commit" collection="solr4">
<cfsearch collection="solr4" criteria="test" name="n1">
<cfdump var="#n1#">
</cflock>
Result:
This is an enhancement for CFINDEX
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3041959
External Customer Info:
External Company:
External Customer Name: Travis Walters
External Customer Email: 163148AE447DEBE799201549
External Test Config: 08/28/2010
Attachments:
Comments: