tracker issue : CF-3186302

select a category, or use search below
(searches all categories and all time range)
Title:

problem deleting keys from Solr collection

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Robert Munn / Robert Munn (CFMunster)

Created: 05/09/2012

Components: Text Search

Versions: 9.0.1

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 7

Vote Count: 0

Problem Description: The Solr server does not properly delete keys for file-based index entries using cfindex action=;delete. 

Steps to Reproduce: 

1.Create a Solr collection. 

<cfparam name='collection' default='mycollection'/>
<cfparam name='collectionPath' default='c:\ColdFusion9\solr\multicore'/>
<cfcollection action='create' collection='#collection#' engine='solr' path='#collectionPath#'/>

2. Populate the collection with some documents on the server using cfindex action=update type=path or type=file. I used this PDF for the test:

http://www.flex-tutorial.fr/wp-content/uploads/2009/01/data-push-in-flex-using-blaze-ds.pdf

<cfparam name='collection' default='mycollection'/>
<cfparam name='filename' default='c:\docs\data-push-in-flex-using-blaze-ds.pdf'/>
<cfparam name='folderAlias' default='\docs'/>

<cfindex action='update' collection='#collection#' type='file' key='#filename#' urlpath='#folderAlias#' />

3. Check the Solr collection to verify that the documents are present. You can check using cfsearch or by going to the Solr admin directly at <server>:<port>/solr/<collection>/admin and looking at the Statistics link for the number of documents in the collection.

http://localhost:8983/solr/mycollection/admin/

4. Use cfindex action=delete key=<filename> to delete the entry from the index. 

<cfparam name='collection' default='mycollection'/>
<cfparam name='filename' default='c:\docs\data-push-in-flex-using-blaze-ds.pdf'/>
<!--- this code fails to delete the key --->
<!---
<cfindex action='delete' collection='#collection#' key='#filename#' status='c' />
<cfdump var='#c#'/>--->

5. Check the Solr collection again for the number of documents.

Actual Result:

The document is not removed from the index, and the number of documents in the Solr Statistics remains the same. 

Expected Result:

The document should be deleted and the number of documents in the Solr Statistics should be reduced by one.

Any Workarounds:

1. Change schema.xml for the collection - make indexed='true' for the key field (line 444 in CF9.01). Restart Solr.
2. Use the SolColdFusion component found on RIAForge to search for the index entry by key, then delete the entry from the index by id.

http://solcoldfusion.riaforge.org/

Example code to delete the key entry using theSolColdFusion component:


<cfparam name='collection' default='mycollection'/>
<cfparam name='filename' default='c:\docs\data-push-in-flex-using-blaze-ds.pdf'/>

<cfset solr = createObject("component", "org.apache.solr.client.SolColdfusion").init("http://localhost", "8983", "/solr/#collection#") />

<cfset params = arrayNew(1) />
<cfset params[1][1] = "fl" />
<cfset params[1][2] = "uid" />
<!--- filename should be fully qualified path to file --->
<cfset result = xmlparse(solr.search('key:#solrformat(filename)#',0,1,params))/>
<cfset uid = xmlsearch(result,"/response/result//doc[1]/str[@name='uid']")[1].XmlText/>

<cfset solr.deleteById(id=uid)/>
<cfset solr.commit()/>

<cffunction name='solrFormat' access='private' returntype='string'>
	<cfargument name="str" type='string' required='true' />
	<cfset local.mystr = arguments.str />
	<cfset local.charList = '\,+,-,&&,||,!,(,),{,},[,],^,",~,*,?,:'/>
	<cfloop list='#local.charList#' index='c'>
		<cfset local.mystr = replace(local.mystr,c,'\' & c,'all')/>
	</cfloop>
	<cfreturn local.mystr />
</cffunction>

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3186302

External Customer Info:
External Company:  
External Customer Name: CFMunster
External Customer Email:  
External Test Config: HP Envy, Core-I7 quad core 

16 GB RAM

Windows 7 SP1 64 bit

CF 9.01 HF 2

Attachments:

Comments:

I also ran into this problem on CF 10 beta.
Comment by External U.
19496 | May 09, 2012 11:15:02 AM GMT
unable to observe the issue with CF 9,0,1,274712 on Windows 7x64. @ CFMunster, can you please try introducing some lag between indexing the collection and deleting the keys and let us know if you still run into the issue. Thanks. Here's the code snippet I used: <cfset col_name = "test_coll"> <cfcollection action="list" name="lst_col" engine="solr"> <cfset col_lst = ValueList(lst_col.NAME, ",")> <cfif ListContains( col_lst, "#col_name#") EQ 0> <cfcollection action = "create" collection = "#col_name#" engine = "solr" path = "#expandpath(".")#"> </cfif> <cfset filename = "C:\ColdFusion9\wwwroot\col_solr\some.pdf"> <cfindex action='update' collection='#col_name#' type='file' key='#filename#' urlpath='http://localhost:8501/col_solr' /> <cfset sleep(2000)> <cfsearch name="srch_test" collection="#col_name#" criteria= "sometext"> search result... <cfdump var="#srch_test#"> <cfindex action='delete' collection='#col_name#' key='#filename#' status='del_stat' /> <cfdump var='#del_stat#'/>
Comment by Piyush K.
19497 | December 23, 2013 11:43:19 PM GMT