"Randall F. Kern" wrote:
Is it possible to search a catalog on a field index for either a given prefix, or any of a list of values?
Maybe I'm going about this wrong; I want to add the ability to only show objects found below a specific place on my site, and to do that I created a field index on the path to each object. Then at query time I would like to search for /foo/bar/*, or failing that create a list of all paths below /foo/bar and create an OR query.
The solution I'm using now is to post-process the search results, but that seems lame :)
Thanks, -Randy
Just a stab, but I think using a Catalog for this might be the wrong approach. I would think it would be easier just to recursively iterate through the folders to accomplish this. However, if you are bent on using ZCatalog I think I might have an idea how to do it: Create a keyword index called getPhysicalPath in your Catalog. All traversable objects have a getPhysicalPath method that returns a tuple of strings which are the ids of the objects. The index will then contain all of the object's paths. To search for your example you would use: Catalog(getPhysicalPath=['foo','bar']) Some caveats: The ids of the objects themselves will be in the keyword index, as well as the root. You might want to write a python script that strips these off and returns the result such as: return list(context.getPhysicalPath())[1:-1] Then create the index on this python script. Also, if you have alot of folders at different levels with the same ids, it will return ambiguous results. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>