<div dir="ltr"><div>There are actually very few queries so far. I have yet to optimize the preview section, that still uses the gateway, but I will follow up this email with those optimizations, plus any I make in webtagging to optimize that.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Douglas</div><div><br></div><div>In the subquery, take a list of tag IDs and find which images have all of these present. Use the list of imageIds that the subquery generates to find the list of all other tags which are present on those images. These are the potential criteria for refinements to the tag search space.</div>
<div><br></div><div> selected_tags = [1L,2L,3L,4L] # e.g.</div><div><br></div><div> sub_hql = "select <a href="http://link.parent.id">link.parent.id</a> from ImageAnnotationLink link " \</div>
<div> "where <a href="http://link.child.id">link.child.id</a> in (:oids) " \</div><div> "group by <a href="http://link.parent.id">link.parent.id</a> " \</div><div> "having count (link.parent) = %s" % len(selected_tags)</div>
<div><br></div><div> hql = "select distinct <a href="http://link.child.id">link.child.id</a> from ImageAnnotationLink link " \</div><div> "where <a href="http://link.parent.id">link.parent.id</a> in (%s)" % sub_hql</div>
<div><br></div><div><div> params = Parameters()</div><div> params.map = {}</div><div> params.map["oids"] = rlist([rlong(o) for o in set(selected_tags)])</div><div><br></div><div>
qs = conn.getQueryService()</div><div> results = qs.projection(hql, params)</div></div><div><br></div><div><br></div><div>Get the Ids and text values of all the tags, excluding any tags which are not applied to anything as those do not make sense in the context of navigation.</div>
<div><div><br></div><div> hql = "select distinct <a href="http://link.child.id">link.child.id</a>, link.child.textValue " \</div><div> "from ImageAnnotationLink link " \</div><div>
"where link.child.class is TagAnnotation " \</div>
<div> "order by link.child.textValue"</div><div><br></div><div><div> params = Parameters()</div><div> qs = self.conn.getQueryService()</div></div><div> tags = [(result[0].val, result[1].val) for result in qs.projection(hql, params)]</div>
</div></div>