--- cdli/cdli_files.py 2010/03/19 14:01:41 1.115 +++ cdli/cdli_files.py 2010/03/23 16:20:40 1.116 @@ -888,8 +888,9 @@ class CDLIRoot(Folder): - def searchText(self, query, index='graphemes'): - """searches query in the fulltext index and returns a list of file ids/P-numbers""" + def searchText(self, query, index='graphemes', resultFilter=None): + """searches query in the fulltext index and returns a list of file IDs/P-numbers + resultFilter is matched against the beginning of the file ID""" # see also: http://www.plope.com/Books/2_7Edition/SearchingZCatalog.stx#2-13 logging.debug("searchtext for '%s' in index %s"%(query,index)) #import Products.ZCTextIndex.QueryParser @@ -899,8 +900,11 @@ class CDLIRoot(Folder): idx = getattr(self, self.file_catalog) # do search resultset = idx.search(query_request=idxQuery,sort_index='textid') - # put only the P-Number in the result - results = [res.getId[:7] for res in resultset] + # put only the P-Number in the result + if resultFilter is None: + results = [res.getId[:7] for res in resultset] + else: + results = [res.getId[:7] for res in resultset if res.getId.startswith(resultFilter)] logging.debug("searchtext: found %d texts"%len(results)) return results