We're using the internals of ZCatalog to do searching stuff in our Python Product. I've managed to get it working at a basic level by constructing a Catalog instance and adding indexes and calling searchResults(). Only now I need to get into more advanced features, like partial word matches and multiple or'ed search fields. I tried just passing a GlobbingLexicon() to Catalog instantiation, but that completely failed to work. As far as I can tell, it's not using the GlobbingLexicon at all (I put a print statements in all the methods and nothing is printed). I then tried using ZCatalog.Vocabulary(globbing=1) and that didn't seem to work either (still no hits on the GlobbingLexicon methods). Also, any hints as to how to have a "match any" multiple field "or" search would be greatly appreciated. I _think_ I can somehow pass a list of the fields to searchResults() as some sort of argument, but I'm really not sure how. Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)
richard@bizarsoftware.com.au wrote:
We're using the internals of ZCatalog to do searching stuff in our Python Product. I've managed to get it working at a basic level by constructing a Catalog instance and adding indexes and calling searchResults(). Only now I need to get into more advanced features, like partial word matches and multiple or'ed search fields.
I tried just passing a GlobbingLexicon() to Catalog instantiation, but that completely failed to work. As far as I can tell, it's not using the GlobbingLexicon at all (I put a print statements in all the methods and nothing is printed).
I then tried using ZCatalog.Vocabulary(globbing=1) and that didn't seem to work either (still no hits on the GlobbingLexicon methods).
Also, any hints as to how to have a "match any" multiple field "or" search would be greatly appreciated. I _think_ I can somehow pass a list of the fields to searchResults() as some sort of argument, but I'm really not sure how.
Richard
-- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)
Globbing support is part of the Vocabulary object which must be turned on when it is instanciated AFAIK. Are you passing the Catalog an existing Vocabulary when you create it or are you having it create one for you? -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
Casey Duncan wrote:
richard@bizarsoftware.com.au wrote:
We're using the internals of ZCatalog to do searching stuff in our Python Product. I've managed to get it working at a basic level by constructing a Catalog instance and adding indexes and calling searchResults(). Only now I need to get into more advanced features, like partial word matches and multiple or'ed search fields.
I tried just passing a GlobbingLexicon() to Catalog instantiation, but that completely failed to work. As far as I can tell, it's not using the GlobbingLexicon at all (I put a print statements in all the methods and nothing is printed).
I then tried using ZCatalog.Vocabulary(globbing=1) and that didn't seem to work either (still no hits on the GlobbingLexicon methods).
Also, any hints as to how to have a "match any" multiple field "or" search would be greatly appreciated. I _think_ I can somehow pass a list of the fields to searchResults() as some sort of argument, but I'm really not sure how.
Globbing support is part of the Vocabulary object which must be turned on when it is instanciated AFAIK. Are you passing the Catalog an existing Vocabulary when you create it or are you having it create one for you?
I tried both my_catalog = Catalog(GlobbingLexicon()) and my_catalog = Catalog(Vocabulary(globbing=1)) and neither resulted in any calls to any GlobbingLexicon methods! Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)
richard@bizarsoftware.com.au wrote:
I tried both
my_catalog = Catalog(GlobbingLexicon())
and
my_catalog = Catalog(Vocabulary(globbing=1))
and neither resulted in any calls to any GlobbingLexicon methods!
Richard
Catalog doesn't take the Vocabulary object itself as an argument. It takes the (string) id of an acquirable Vocabulary. If you don't specify a string, it creates a standard non-globbing lexicon (Although a ZCatalog creates a globbing lexicon, go figure). Something like this should work (Assuming your product is an acquisition wrapper e.g. by subclassing Acquisition.Implicit): my_vocab = Vocabulary(globbing=1) my_cat = Catalog(vocabulary='my_vocab') I'm completely unsure why it was implemented this way. I can kinda understand for ZCatalog, but not really for Catalog. Anyone care to explain?? or you could do this without using acquistion, but you wind up creating the vocabulary twice: my_cat = Catalog() my_cat.lexicon = Vocabulary(globbing=1) -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
Catalog doesn't take the Vocabulary object itself as an argument. It takes the (string) id of an acquirable Vocabulary. If you don't specify a string, it creates a standard non-globbing lexicon (Although a ZCatalog creates a globbing lexicon, go figure). Something like this should work (Assuming your product is an acquisition wrapper e.g. by subclassing Acquisition.Implicit):
my_vocab = Vocabulary(globbing=1) my_cat = Catalog(vocabulary='my_vocab')
I'm completely unsure why it was implemented this way. I can kinda understand for ZCatalog, but not really for Catalog. Anyone care to explain??
I'd like to explain, but I can't. I think the intent was to allow vocabularies to be shared between Catalog instances, but the implementation of the idea isn't ideal.
Casey Duncan wrote:
richard@bizarsoftware.com.au wrote:
I tried both
my_catalog = Catalog(GlobbingLexicon())
and
my_catalog = Catalog(Vocabulary(globbing=1))
and neither resulted in any calls to any GlobbingLexicon methods!
Richard
Catalog doesn't take the Vocabulary object itself as an argument. It takes the (string) id of an acquirable Vocabulary. If you don't specify a string, it creates a standard non-globbing lexicon (Although a ZCatalog creates a globbing lexicon, go figure).
Ack, you're quite right. I completely missed the "if type(vocabulary) is type(''):" clause. Thanks for pointing that out.
I'm completely unsure why it was implemented this way. I can kinda understand for ZCatalog, but not really for Catalog. Anyone care to explain??
Does seem a little odd to me.
or you could do this without using acquistion, but you wind up creating the vocabulary twice:
my_cat = Catalog() my_cat.lexicon = Vocabulary(globbing=1)
I used: my_cat = Catalog() my_cat.lexicon = GlobbingLexicon() since the Vocabulary class appears to be a wrapper for the Lexicon allowing management, and I don't need that. The lexicon now works fine. Thanks for your help - now to work on the 'or' searching :) Richard -- Richard Jones richard@bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)
participants (3)
-
Casey Duncan -
Chris McDonough -
richard@bizarsoftware.com.au