You can perform zone searches on markup language documents. The Verity zone filter includes built-in support for HTML and several file formats; for a list of supported file formats, see Building a Search Interface. Verity searches XML files by treating the XML tags as zones. When you use the zone filter, the Verity engine builds zone information into the collection's full-word index. This index, enhanced with zone information, permits quick and efficient searches over zones. The zone filter can automatically define a zone, or you can define it yourself in the style.zon file. You can use zone searching to limit your search to a particular zone. This can produce more accurate, but not necessarily faster, search results than searching an entire file.
Note: The contents of a zone cannot be returned in the results list of an application.
The following examples perform zone searching on XML files. In a list of rock bands, you could have XML files with tags for the instruments and for comments. In the following XML file, the word Pete appears in a comment field:
<band.xml> <Lead_Guitar>Dan</Lead_Guitar> <Rhythm_Guitar>Jake</Rhythm_Guitar> <Bass_Guitar>Mike</Bass_Guitar> <Drums>Chris</Drums> <COMMENT_A>Dan plays guitar, better than Pete.</COMMENT_A> <COMMENT_B>Jake plays rhythm guitar.</COMMENT_B> </band.xml>
The following CFML code shows a search for the word Pete:
<cfsearch name = "band_search" collection="my_collection" type = "simple" criteria="Pete">
The above search for Pete returns this XML file because this search target is in the COMMENT_A field. In contrast, Pete is the lead guitarist in the following XML file:
<band.xml> <Lead_Guitar>Pete</Lead_Guitar> <Rhythm_Guitar>Roger</Rhythm_Guitar> <Bass_Guitar>John</Bass_Guitar> <Drums>Kenny</Drums> <COMMENT_A>Who knows who's better than this band?</COMMENT_A> <COMMENT_B>Ticket prices correlated with decibels.</COMMENT_B> </band.xml>
To retrieve only the files in which Pete is the lead guitarist, perform a zone search using the IN operator according to the following syntax:
(query) <IN> (zone1, zone2, ...)
Note: As with other operators, IN might be uppercase or lowercase. Unlike AND, OR, or NOT, you must enclose IN within brackets.
Thus, the following explicit search retrieves files in which Pete is the lead guitarist:
(Pete) <in> Lead_Guitar
This is expressed in CFML as follows:
<cfsearch name = "band_search" collection="my_collection" type = "explicit" criteria="(Pete) <in> Lead_Guitar">
To retrieve files in which Pete plays either lead or rhythm guitar, use the following explicit search:
(Pete) <in> (Lead_Guitar,Rhythm_Guitar)
This is expressed in CFML as follows:
<cfsearch name = "band_search" collection="bbb" type = "explicit" criteria="(Pete) <in> (Lead_Guitar,Rhythm_Guitar)">