Hello everybody.. I have to index some data from a mysql query recordset and all works OK but..I added a keywordIndex to store (with the same url) multiple values related to the above recordset. It seems I cannot use brains (query results are strings). Probably a newbie question, but I really do not know how to update a keywordIndex starting from a list..Any help (+sample code pls :-)) ? Thanks, Stefano.
--On 25. Februar 2008 10:09:00 +0100 Stefano Guglia <sguglia@arrows.it> wrote:
Hello everybody..
I have to index some data from a mysql query recordset and all works OK but..I added a keywordIndex to store (with the same url) multiple values related to the above recordset. It seems I cannot use brains (query results are strings).
Probably a newbie question, but I really do not know how to update a keywordIndex starting from a list..Any help (+sample code pls :-)) ?
Unless you don't provide the related code, it is hard to guess what you're really doing. In general: ZCatalog/indexes are designed in the first place to deal with Zope objects, not with foreign data without a persistent object. -aj
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stefano Guglia wrote:
Hello everybody..
I have to index some data from a mysql query recordset and all works OK but..I added a keywordIndex to store (with the same url) multiple values related to the above recordset. It seems I cannot use brains (query results are strings).
Probably a newbie question, but I really do not know how to update a keywordIndex starting from a list..Any help (+sample code pls :-)) ?
If you have a KeywordIndex for the attribute 'foo', then you need to arrange that the reult objects in your recordset have sequences for the column / atrribute 'foo'. E.g., for a query like: select bar.id as 'bar, bar.name as 'name', foo.name as 'foo from bar, foo where foo.bar_id = bar.id you need to transform the result set: bars = {} for row in rows: bar_id= row['bar'] bar = bars.get(bar_id) if bar is None: bar = bars[bar_id[ = {'bar': bar_id, 'name': row['name'], 'foo': [], } bar['foo'].append(row['foo']) *Now* you can index the records you have transformed: for bar in bars.values(): catalog.indexObject(compute_uid(bar), make_record(bar)) Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFHxEcP+gerLs4ltQ4RAil1AKCnONzwX4/GKMQKx5WP6twE30p4rwCY4Q9X V2jWkrjSZcDbyXqk0JUgqA== =1zLd -----END PGP SIGNATURE-----
participants (3)
-
Andreas Jung -
Stefano Guglia -
Tres Seaver