- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion Tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Populates a search engine collection with metadata and creates indexes for searching it. The engine (Solr) can search physical files of various types or a database query. Indexing database columns that result from a query lets users search the query data much faster than they could if you used multiple SQL queries to return the same data. You must define a collection using the ColdFusion Administrator or the cfcollection tag before creating indexes for the collection.
You also can index a collection using the ColdFusion Administrator. For more information on creating, indexing, and searching a collection, see Solr search examples in Developing ColdFusion Applications.
Category
Syntax
cfindex supports script style syntax: new index(collection="<collection_name>"); <cfindex action = "update|delete|purge|refresh|fullimport|deltaimport|status|abort|optimize" autoCommit = "yes|no" collection = "collection name" collectionNames= "comma-separated values of collection names" body = "body" category = "category name" categoryTree = "category tree" custom1 = "custom value" custom2 = "custom value" custom3 = "custom value" custom4 = "custom value" extensions = "file extensions" key = "ID" language = "{{language}}" prefix = "location of documents" query = "query name" recurse = "yes|no" status = "status" throwOnError="true|false" title = "title" type = "type" URLpath = "URL">
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
History
ColdFusion (2016 release): Added the parameter throwOnError.
ColdFusion 10:
- Added new actions fullimport , deltaimport , status, abort.
- Added the attributes autoCommit, fieldBoost , docBoost.
- Added support for dynamic custom fields.
ColdFusion 9: Added Solr search engine support.
ColdFusion MX 7.0.1: Added the prefix attribute.
ColdFusion MX 7:
- Added the category, categoryTree , custom3, and custom4 attributes for the update and refresh actions.
- Added the status attribute for the update, refresh, delete, and purge actions.
- Removed reference to external collections.
- Removed suggested cflock usage.
ColdFusion MX:
- Changed the external attribute behavior: it is not necessary to specify the external attribute. (ColdFusion automatically detects whether a collection is internal or external.)
- Changed Verity operations behavior: ColdFusion supports Verity operations on Acrobat PDF files.
- Changed thrown exceptions: this tag can throw the SEARCHENGINE exception.
- Changed acceptable collection naming: this tag accepts collection names that include spaces.
- Changed query result behavior: the cfindex tag can index the query results from a cfsearch tag.
Attributes
Attribute |
Req/Opt |
Default |
Description |
---|---|---|---|
action |
Required |
Null |
|
autoCommit |
Optional |
True |
If yes, automatically commit the changes to the search server. |
collection |
Required |
Null |
Name of a collection that is registered by ColdFusion; for example, " personnel ". |
collectionNames | Optional | Null | Comma-separated values of collection names. Note: This attribute is required when action="merge". |
body |
Required if type=custom |
Null |
|
category |
Optional |
(empty string) |
A string value that specifies one or more search categories for which to index the data. You can define multiple categories, separated by commas, for a single index. If you use a query for your indexed data, this value can be the name of a column. |
categoryTree |
Optional |
(empty string) |
A string value that specifies a hierarchical category or category tree for searching. It is a series of categories separated by forward slashes ("/"). You can specify only one category tree. |
custom1 |
Optional |
Null |
Use to index discrete values in collection records, which lets you search for specific records. By contrast, values specified in the body attribute are concatenated and searched as a body of text using the specified criteria. If type = custom, a query column name. If type is file or path, a string. Additionally, ColdFusion 10 added support for dynamic custom fields. |
custom2 |
Optional |
Null |
Usage is the same as for custom1. |
custom3 |
Optional |
Null |
Usage is the same as for custom1. |
custom4 |
Optional |
Null |
Usage is the same as for custom1. |
extensions |
Optional |
htm , html , cfm , cfml , dbm , dbml |
Delimited list of file extensions that ColdFusion uses to index files, if type = "Path". "." returns files with no extension. "." returns all files. |
fieldBoost |
Optional |
htm , html , cfm , cfml , dbm , dbml |
Boost specific fields while indexing. fieldBoost enhances the score of the fields and thereby the ranking in the search results. Multiple fields can be boosted by specifying the values as a comma-separated list. |
key |
Required |
(empty string) |
The value specified for key depends on the type attribute:
|
language |
Optional |
Null |
For options, see cfcollection . |
prefix |
Optional |
Null |
Specifies the location of files to index when the computer that contains the K2 Search Service is not the computer on which you installed ColdFusion, and when you index files with the type attribute set to path . |
query |
Optional. |
Null |
The name of the query against which the collection is generated. |
recurse |
Optional |
no |
|
status |
Optional |
Null |
The name of the structure into which ColdFusion returns status information. |
throwOnError | Oprtional | false | If true, then cfindex tag throws an error while indexing documents. |
title |
Optional |
(empty string) |
Provides a title for the document if one cannot be extracted from the document. |
type |
Optional |
custom, if query attribute is specified. Otherwise, file. |
When type=" dih ", these actions are used:
|
URLpath |
Optional |
(empty string) |
If type is file or path, specifies the URL path. During indexing, this pathname is prefixed to filenames and returned from a search as the url . |
Usage
The attributes settings that the cfindex tag requires depend on whether you set the query attribute. If you set the query attribute to a valid query name, it specifies that cfindex is to index the data in the query rather than indexing documents on a disk. If you do not set the query attribute, cfindex assumes that it is indexing a file (type = file), a set of files in a directory path (type = path), or text that you provide in the body attribute (type = custom). If you set the query attribute to a valid query name, the cfindex tag creates indexes as specified by the following attributes and their values:
Type |
Attribute values |
---|---|
File |
The key attribute is the name of a column in the query that contains a full filename (including path). |
Path |
The key attribute is the name of a column in the query that contains a directory pathname. |
|
The extensions and recurse attributes, if specified, elaborate on which files are included. If the action is delete, cfindex deletes keys for the collection. |
Custom |
The key attribute specifies a column name that contains anything you want; for example, the primary key value in the database. It must be unique because this is the primary key in the collection. If the action is delete, the key attribute is the name of a column in the query that contains the keys to delete. |
|
The body attribute is required and is a comma-delimited list of the names of the columns that contain the text data to be indexed. |
If you do not set the query attribute, the cfindex tag creates indexes as specified by the following attributes and their values:
Type |
Attribute values |
---|---|
File |
The key attribute is required and is a full pathname to a file. |
Path |
The key attribute is required and it is a directory pathname. |
|
The extensions and recurse attributes, if specified, designate which types of files are included. If the action is delete, both the keys and the document files are deleted. |
Custom |
The key attribute is an identifier that specifies the key. If the action is delete, the key attribute is the document key to delete. |
|
The body attribute is required and is the text to be indexed. |
If type is not specified but query is set, ColdFusion sets the type to the default value of custom. If neither type nor query is set, ColdFusion sets type to the default value of file. If type equals custom, all attributes except for key and body can specify a literal value, not only a column name. This allows you to change a field to empty in the collection.
Status attribute
The status attribute provides the following information and diagnostics about the result of a cfindex operation:
Key |
Type |
Description |
---|---|---|
BADKEYS |
Struct |
A structure of keys with diagnostic messages about the indexing of these keys. If there are no bad keys, this key does not exist. |
DELETED |
Number |
The number of keys deleted. |
MESSAGES |
Array |
An array of diagnostic messages, including nonfatal errors and warnings. If there are no messages, this key does not exist. |
INSERTED |
Number |
The number of keys inserted into the collection. |
UPDATED |
Number |
The number of keys updated in the collection. |
Example
<!--- EXAMPLE #1 Index a file, type = "file". ----------------------------> <!--- Example dumps content of status variable (info). -------------------> <cfindex collection="CodeColl" action="refresh" type="file" key="C:\ColdFusion\wwwroot\vw_files\cfindex.htm" urlpath="http://localhost:8500/vw_files/" language="English" title="Cfindex Reference page" status="info"> <!--- Search for Attributes. ---> <cfsearch name = "mySearch" collection = "CodeColl" criteria = "Attributes" contextpassages = "1" maxrows = "100"> <cfoutput> key=#mySearch.key#<br /> title=#mySearch.title#<br /> context=#mySearch.context#<br /> url=#mySearch.url#<br /> </cfoutput> <cfdump var="#info#"> <!--- EXAMPLE #2 Index a path (type = "path"). ------------------------------> <cfindex collection="CodeColl" action="refresh" type="path" key="C:\inetpub\wwwroot\vw_files\newspaper\sports" urlpath="http://localhost/vw_files/newspaper/sports" extensions = ".htm, .html" recurse="no" language="English" categoryTree="vw_files/newspaper/sports" category="Giants"> <!--- Search for any references to criteria. ---> <cfsearch name = "mySearch" collection = "CodeColl" categoryTree="vw_files/newspaper/sports" category="Giants" criteria = "Williams" contextpassages = "1" maxrows = "100"> <cfoutput> key=#mySearch.key#<br /> title=#mySearch.title#<br /> context=#mySearch.context#<br /> url=#mySearch.url#<br /> </cfoutput> <!---EXAMPLE #3: Index a QUERY (type = "custom") using custom1. ------------> <!--- Retrieve data from the table. ---> <cfquery name="getCourses" datasource="cfdocexamples"> SELECT * FROM COURSES </cfquery> <!--- Update the collection with the above query results. ---> <!--- key is Course_ID in the Courses table. ----> <!--- body specifies the columns to be indexed for searching. ---> <!--- custom1 specifies the value of the Course_Number column. ---> <cfindex query="getCourses" collection="CodeColl" action="Update" type="Custom" key="Course_ID" title="Courses" body="Course_ID,Descript" custom1="Course_Number" > <h2>Indexing Complete</h2> <!--- cno supplies value for searching custom1; could be form input instead. ---> <cfset cno = "540"> <cfsearch name = "mySearch" collection = "CodeColl" criteria = "CF_CUSTOM1 <MATCHES> #cno#" contextpassages = "1" maxrows = "100"> <!--- Returns indexed values (Course_ID and Descript) for Course_Number 540. ---> <cfoutput> key=#mySearch.key#<br /> title=#mySearch.title#<br /> context=#mySearch.context#<br /> url=#mySearch.url#<br /> </cfoutput> <!--- EXAMPLE #4 Index a FILE within a QUERY (type= "file"). ---------------> <!--- Retrieve row with a column that contains a filename (Contract_File). ---> <cfquery name="getEmps" datasource="cfdocexamples"> SELECT * FROM EMPLOYEE WHERE EMP_ID = 1 </cfquery> <!--- Update the collection with the above query results. ---> <!--- key specifies the column that contains a complete filename. ---> <!--- file is indexed in same way as if no query involved. ---> <cfindex query="getEmps" collection="CodeColl" action="Update" type="file" key="Contract_File" title="Contract_File" body="Emp_ID,FirstName,LastName,Contract_File"> <h2>Indexing Complete</h2> <cfsearch name = "mySearch" collection = "CodeColl" criteria = "vacation" contextpassages = "1" maxrows = "100"> <cfoutput> key=#mySearch.key#<br /> title=#mySearch.title#<br /> context=#mySearch.context#<br /> url=#mySearch.url#<br /> </cfoutput> <!--- EXAMPLE # 5 Index a PATH within a QUERY. ----------------------------> <!--- Retrieve a row with a column that contains a path (Project_Docs). ---> <cfquery name="getEmps" datasource="cfdocexamples"> SELECT * FROM EMPLOYEE WHERE Emp_ID = 15 </cfquery> <!--- Update the collection with the above query results. ---> <!--- key specifies a column that contains a directory path. ---> <!--- path is indexed in same way as if no query involved. ---> <cfindex query="getEmps" collection="CodeColl" action="update" type="path" key="Project_Docs" title="Project_Docs" body="Emp_ID,FirstName,LastName,Project_Docs"> <h2>Indexing Complete</h2> <cfsearch name = "getEmps" collection = "CodeColl" criteria = "cfsetting" contextpassages = "1" maxrows = "100"> <cfoutput> key=#getEmps.key#<br /> title=#getEmps.title#<br /> context=#getEmps.context#<br /> url=#getEmps.url#<br /> </cfoutput> <!--- EXAMPLE #6 Deletes keys in the CodeColl collection for html files ---> <!--- in the specified directory (but not in subdirectories). -------------> <cfindex collection="CodeColl" action="delete" type="path" key="C:\ColdFusion\wwwroot\vw_files\newspaper" urlpath="http://localhost:8500/vw_files/newspaper" extensions = ".htm, .html" recurse="no"> <!--- EXAMPLE #7 Purges all keys in the CodeColl collection ---> <!--- with recursion. -------------------------------------------------------> <cfindex collection="CodeColl" action="purge" type="path" key="C:\ColdFusion\wwwroot\vw_files\newspaper">