[Zope3-dev] Zope's PathIndex 'level' argument
seb bacon
seb@jamkit.com
Mon, 25 Nov 2002 21:35:43 +0000
Tres Seaver wrote:
> On Mon, 2002-11-25 at 14:27, Steve Alexander wrote:
>=20
>>I'm implementing the functionality of a PathIndex for Zope 3.
>>
>>In Zope 2, when querying a PathIndex, you can give it an optional=20
>>'level' argument in addition to the base-path that you're interested in=
=2E
>>
>>Does anyone use this 'level' argument? What are its use-cases?
> That's good, because it doesn't do anything I can describe, much less
> find a good use for. What would be much more useful is a 'depth'
> argument (or perhaps 'maxdepth' and 'mindepth', =E0 la the Unix 'find'
> command). ('level' is something like 'mindepth', I think).
A use case for maxdepth:
If you have a hierarchical keyword taxonomy which you are using for a=20
metadata attribute on objects, you could use it to do a 'related items'=20
query.
The following example is not particularly correct, but should give you=20
the idea:
Root
|
+ Animal
| |
| +- Canine
| | +- Dog
| | +- Wolf
| +- Feline
|
+ Vegetable
query({'classification':{'query':'/Animal'}
=2E..might get all animals, including dogs and wolves
query({'classification':{'query':'/Animal', 'maxdepth':1}}
=2E..might get all canines and felines but not specifically dogs or wolve=
s
query({'classification':{'query':'/Animal/Canine/Dog', 'maxdepth':-1}}=
=2E..might get all dogs and wolves
Of course, this may be a candidate for a different type of index - I've=20
been having a stab at a FuzzyPathIndex (Z2) along these lines. BTW,=20
it's surprisingly difficult to optimise.
seb