Searching across multiple indexes
I've been looking through various documents which suggest that searching across multiple indexed in a ZCatalog is possible, and it seems to be so, but I've only had partial success. I'm hoping someone can shed some light on why I can't get the following to work properly! (Using Zope 2.6.2) I have a catalog which contains two indexed: description_idx; notes_idx Both indexes can be searched in isolation; the lexicon shows content, and so there appears to be nothing wrong with the indexes. The following code works OK (ie it returns objects as I would expect), doing an 'and' search of the two indexes - with the search term appearing in both indexes: <tal:block tal:define="term request/form/search_term; results python: here.Catalog({'description_idx':term,'notes_idx':term});"> However, if I change this code to read: results python: here.Catalog({'description_idx':term},{'notes_idx':term}); which I have read should produce an 'or' search, I only get results where the first index (description_idx) matches. If I reverse the order, thus: results python: here.Catalog({'notes_idx':term},{'description_idx':term}); I get matches for the first index (notes_idx) but not the second (description_idx) as before. I took this syntax from a document at: http://www.zope.org/Members/k/ZCatalog_searchResults_note Can anyone tell me if this is supposed to work, and if so, why it's not; or if it's not supposed to work, how I can do an 'or' search in similar fashion. Thanks in advance, Paul ------------------------------------------------------------------------------------------ Paul.Smith@bristol.ac.uk Senior Technical Officer (Web Development), Internet Development Group | RDN Virtual Training Suite <http://www.ilrt.bris.ac.uk/id/>http://www.ilrt.bris.ac.uk/id/ | http://www.vts.rdn.ac.uk/ Institute for Learning and Research Technology, University of Bristol, 8-10 Berkeley Square, Bristol BS8 1HH, UK Tel: +44 (0)117 928 7192, Fax: +44 (0)117 928 7112
I had the same problem, only my code was in dtml not tal.... here is the solution in case you decide you'd like to implement it in dtml.... this does a correct 'or' search on multiple indexes... <dtml-in expr="Catalog(notes_idx=term) + Catalog(description_idx=term)"> ... do what you want with the results </dtml-in> Cheers Ruth ----- Original Message ----- From: "Paul Smith" <paul.smith@bristol.ac.uk> To: <zope@zope.org> Sent: Tuesday, October 28, 2003 2:44 PM Subject: [Zope] Searching across multiple indexes
I've been looking through various documents which suggest that searching across multiple indexed in a ZCatalog is possible, and it seems to be so, but I've only had partial success. I'm hoping someone can shed some light on why I can't get the following to work properly!
(Using Zope 2.6.2)
I have a catalog which contains two indexed: description_idx; notes_idx
Both indexes can be searched in isolation; the lexicon shows content, and so there appears to be nothing wrong with the indexes.
The following code works OK (ie it returns objects as I would expect), doing an 'and' search of the two indexes - with the search term appearing in both indexes:
<tal:block tal:define="term request/form/search_term; results python: here.Catalog({'description_idx':term,'notes_idx':term});">
However, if I change this code to read:
results python: here.Catalog({'description_idx':term},{'notes_idx':term});
which I have read should produce an 'or' search, I only get results where the first index (description_idx) matches. If I reverse the order, thus:
results python: here.Catalog({'notes_idx':term},{'description_idx':term});
I get matches for the first index (notes_idx) but not the second (description_idx) as before.
I took this syntax from a document at:
http://www.zope.org/Members/k/ZCatalog_searchResults_note
Can anyone tell me if this is supposed to work, and if so, why it's not; or if it's not supposed to work, how I can do an 'or' search in similar fashion.
Thanks in advance,
Paul
--------------------------------------------------------------------------
Paul.Smith@bristol.ac.uk Senior Technical Officer (Web Development), Internet Development Group | RDN Virtual Training Suite <http://www.ilrt.bris.ac.uk/id/>http://www.ilrt.bris.ac.uk/id/ | http://www.vts.rdn.ac.uk/ Institute for Learning and Research Technology, University of Bristol, 8-10 Berkeley Square, Bristol BS8 1HH, UK Tel: +44 (0)117 928 7192, Fax: +44 (0)117 928 7112
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Hi, I would like to generate a list of the names of the months (Jan, Feb, etc). I have looked through the Calendar, DateTime and time modules but do not see any methods that will do this. What am I missing? Thanks, Mike
take a look at calendar module it has a property named month_name - a list with all months, or month_abbr - a lsit with all months short names dragos ----- Original Message ----- From: <mlong@datalong.com> To: <zope@zope.org> Sent: Tuesday, October 28, 2003 4:04 PM Subject: [Zope] Generate list of months
Hi,
I would like to generate a list of the names of the months (Jan, Feb, etc). I have looked through the Calendar, DateTime and time modules but do not see any methods that will do this. What am I missing?
Thanks, Mike
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Paul Smith wrote at 2003-10-28 13:44 +0000:
... I have a catalog which contains two indexed: description_idx; notes_idx
Both indexes can be searched in isolation; the lexicon shows content, and so there appears to be nothing wrong with the indexes.
The following code works OK (ie it returns objects as I would expect), doing an 'and' search of the two indexes - with the search term appearing in both indexes:
<tal:block tal:define="term request/form/search_term; results python: here.Catalog({'description_idx':term,'notes_idx':term});">
However, if I change this code to read:
results python: here.Catalog({'description_idx':term},{'notes_idx':term});
which I have read should produce an 'or' search,
Mark the source of this reading as untrustworthy. The "Catalog" does not support to combine subqueries against different indexes by "or". There is an extension by Casey Duncan (something like "CatalogQuery") that provides this feature. Have a look at it... -- Dieter
From one Paul to another Paul, To achieve boolean 'or' searches in ZCatalog, try something like this: 1. make a python script named description_notes, with the following one line that concatenates your description and notes attributes. place this script down low in your zope so that it can be acquired from your catalog and objects to be indexed. no parameters are passed, only the context is needed. return context.description + '/n' + context.notes 2. create a new index in your ZCatalog called 'description_notes'. Thanks to acquisition, ZCatalog will find the description_notes script and run it for each new object being cataloged. Now the index will capture any term that is in the concatenated description and notes field, which is perfectly equivalent to the boolean "or". It works for me. Almost needless to say, don't bother keeping this combined index term in your metadata :-) =Paul At 01:44 PM 10/28/2003 +0000, Paul Smith wrote:
<snip> However, if I change this code to read:
results python: here.Catalog({'description_idx':term},{'notes_idx':term});
which I have read should produce an 'or' search, I only get results where the first index (description_idx) matches. If I reverse the order, thus:
results python: here.Catalog({'notes_idx':term},{'description_idx':term});
I get matches for the first index (notes_idx) but not the second (description_idx) as before.
I took this syntax from a document at:
http://www.zope.org/Members/k/ZCatalog_searchResults_note
Can anyone tell me if this is supposed to work, and if so, why it's not; or if it's not supposed to work, how I can do an 'or' search in similar fashion.
Thanks in advance,
Paul
------------------------------------------------------------------------------------------
Paul.Smith@bristol.ac.uk Senior Technical Officer (Web Development), Internet Development Group | RDN Virtual Training Suite <http://www.ilrt.bris.ac.uk/id/>http://www.ilrt.bris.ac.uk/id/ | http://www.vts.rdn.ac.uk/ Institute for Learning and Research Technology, University of Bristol, 8-10 Berkeley Square, Bristol BS8 1HH, UK Tel: +44 (0)117 928 7192, Fax: +44 (0)117 928 7112
participants (6)
-
Dieter Maurer -
Dragos Chirila -
mlong@datalong.com -
Paul Howell -
Paul Smith -
Ruth Mizzi