Current time: 01-23-2021, 12:07 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Query Search Time
08-29-2010, 12:30 PM
Post: #48
RE: Database Query Search Time
Hey Guys,

It appears that CFINDEX may only delete one document at a time unless you pass a query to it like this:

Code:
<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:

Code:
<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.

Here is version 1.0 of my SOLR_INDEX function:

Code:
<cffunction name="SOLR_INDEX" returnType="void">

  <cfargument name="collection" type="string" required="true" default="">
  <cfargument name="action" type="string" required="true" default="">
  <cfargument name="criteria" type="string" required="false" default="">
  
  <cfif NOT IsDefined("criteria")>
    <cfset criteria = "*:*">
  </cfif>
  
  <cfif #action# EQ "delete">  
    <cfset myURL = 'http://#SOLR_SERVER_HOST#:#SOLR_SERVER_PORT#/solr/#collection#/update?stream.body='>
    <cfset myURL = '#myURL##URLEncodedFormat("<delete><query>#criteria#</query></delete>")#'>  
    <cfhttp method="Get" url="#myURL#" resolveurl="Yes" throwonerror="yes" />
    <cfset myURL = 'http://#SOLR_SERVER_HOST#:#SOLR_SERVER_PORT#/solr/#collection#/update?stream.body=%3Ccommit/%3E'>
    <cfhttp method="Get" url="#myURL#" resolveurl="Yes" throwonerror="yes" />  
  </cfif>

</cffunction>

<cfset args = StructNew()>
<cfset args.collection = "#prodCollectionName2#">
<cfset args.action = "delete">
<cfset args.criteria = 'category:78'>

<cfinvoke method="SOLR_INDEX" argumentCollection="#args#">

Sincerely,
Travis Walters
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Database Query Search Time - pmeenan - 07-04-2010, 12:03 PM
RE: Database Query Search Time - pmeenan - 07-05-2010, 04:35 AM
RE: Database Query Search Time - sajal - 07-05-2010, 05:03 AM
RE: Database Query Search Time - pmeenan - 07-08-2010, 08:47 PM
RE: Database Query Search Time - sajal - 08-13-2010, 10:06 PM
RE: Database Query Search Time - sajal - 08-14-2010, 03:38 AM
RE: Database Query Search Time - sajal - 08-14-2010, 06:50 AM
RE: Database Query Search Time - pmeenan - 08-16-2010, 02:55 AM
RE: Database Query Search Time - sajal - 08-17-2010, 01:14 AM
RE: Database Query Search Time - pmeenan - 08-23-2010, 01:22 AM
RE: Database Query Search Time - pmeenan - 08-23-2010, 08:45 PM
RE: Database Query Search Time - ringman57 - 08-24-2010, 11:52 PM
RE: Database Query Search Time - ringman57 - 08-25-2010, 02:54 AM
RE: Database Query Search Time - green-watch.org - 08-29-2010 12:30 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)