From: <ssk...@vh...> - 2005-11-30 16:04:00
|
Author: sskracic Date: 2005-11-30 17:01:55 +0100 (Wed, 30 Nov 2005) New Revision: 1019 Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java Log: Adding support for querying membership of any category in the tree. Further, merged one of Chris' patches for IntermediaQueryEngine so that result set consists of both the rows from cms_items which have parents categorised, and rows from acs_objects that are categorised themselves. While it sounds weird at a first glance, b/c the filter would actually match items *and* their bundles, there's no harm done since bundles are not present in search_content table to which an inner join is performed. This functionality enables the content outside of cms_items to be searched if such is properly indexed in search_content. Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl =================================================================== --- trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-11-30 13:26:18 UTC (rev 1018) +++ trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-11-30 16:01:55 UTC (rev 1019) @@ -21,16 +21,43 @@ -query searchCategoryItems { +query searchCategoryObjects { BigDecimal id; do { + select m.object_id + from cat_object_category_map m + where m.category_id in :ids + union select i.item_id + from cat_object_category_map cm, + cms_items i + where cm.category_id in :ids + and cm.object_id = i.parent_id + } map { + id = m.object_id; + } +} + +query searchCategoryObjectsDescend { + BigDecimal id; + + do { + select m.object_id from cat_object_category_map m, + cat_cat_subcat_trans_index cc + where m.category_id = cc.subcategory_id + and cc.category_id in :ids + union + select i.item_id + from cat_object_category_map cm, + cat_cat_subcat_trans_index cc2, cms_items i - where m.category_id in :ids - and m.object_id = i.parent_id + where cc2.category_id in :ids + and cc2.subcategory_id = cm.category_id + and cm.object_id = i.parent_id } map { - id = i.item_id; + id = m.object_id; } } + Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-11-30 13:26:18 UTC (rev 1018) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-11-30 16:01:55 UTC (rev 1019) @@ -222,7 +222,6 @@ f.set("types", l); } - // Override to use query that takes account of bundles :-( protected void addCategoryFilter(DataQuery query, CategoryFilterSpecification filter) { Category[] categories = filter.getCategories(); @@ -232,10 +231,18 @@ ids.add(categories[i].getID()); } - Filter f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.cms.searchCategoryItems"); + Filter f = null; + if (filter.shouldDescend()) { + f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.cms.searchCategoryObjectsDescend"); + } else { + f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.cms.searchCategoryObjects"); + } f.set("ids", ids); } |