Searching a FieldIndex for prefix or OR
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
"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 :)
Yes, it is lame. And no, it's not possible with a FieldIndex. ;-) There's a proposal floating around verbally at DC to create a "PathIndex" that has this behavior. I think Tres actually sent me some code for it at some point. You want that I should look it up and send it to you? - C
"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 `------------------>
Tres' PathIndex proposal asserts a similar mechanism... ----- Original Message ----- From: "Casey Duncan" <cduncan@kaivo.com> To: "Randall F. Kern" <randy@spoke.net> Cc: <zope@zope.org> Sent: Tuesday, April 03, 2001 10:33 AM Subject: Re: [Zope] Searching a FieldIndex for prefix or OR
"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 `------------------>
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi all, Zope time is wrong, it is (1)one hour ahead of (Windows 2000) Server time. Windows time is correct and daylight savings is unchecked. Jamaica is (GMT -5). How do I correct ZopeTime???? Mohan.
Mohan Baro wrote:
Hi all,
Zope time is wrong, it is (1)one hour ahead of (Windows 2000) Server time. Windows time is correct and daylight savings is unchecked.
Jamaica is (GMT -5).
How do I correct ZopeTime????
Mohan.
You might check /lib/python/DateTime/DateTime.py The TZ, cdt was set to GMT-2 and when we went to DST in the US/Central TZ many of us lost a couple of hours. <s> Maybe that was 'supposed' to be another TZ??? But it was detected as US Central Daylight Time. HTH, -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
Here is what I found out. Aparently Jamaica is not timezone for Windows 2000 Server, so the server has -5:00 GMT/US/Eastern(No Daylight Savings Time) <dtml-var "ZopeTime()"> gives me 2001/04/04 21:00:00.765 US/Eastern <dtml-var "ZopeTime().strftime('%H:%M')"> gives me say 22:00 <dtml-var "ZopeTime().toZone('Jamaica').strftime('%H:%M')"> also gives me 22:00 In my forms I use the .strftime() function. Any idea what's happening here. Why does using .strftime() give an extra hour?? Mohan. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Tim Cook Sent: Tuesday, April 03, 2001 10:52 PM To: Mohan Baro; zope@zope.org Subject: Re: [Zope] Zope Time Problem Mohan Baro wrote:
Hi all,
Zope time is wrong, it is (1)one hour ahead of (Windows 2000) Server time. Windows time is correct and daylight savings is unchecked.
Jamaica is (GMT -5).
How do I correct ZopeTime????
Mohan.
You might check /lib/python/DateTime/DateTime.py The TZ, cdt was set to GMT-2 and when we went to DST in the US/Central TZ many of us lost a couple of hours. <s> Maybe that was 'supposed' to be another TZ??? But it was detected as US Central Daylight Time. HTH, -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Casey Duncan -
Chris McDonough -
Mohan Baro -
Randall F. Kern -
Tim Cook