Python sqlalchemy.func 模块,to_tsvector() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用sqlalchemy.func.to_tsvector()

项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def handle_info_json(self, model, info, fulltextsearch=None):
        """Handle info JSON query filter."""
        clauses = []
        headlines = []
        order_by_ranks = []
        if '::' in info:
            pairs = info.split('|')
            for pair in pairs:
                if pair != '':
                    k,v = pair.split("::")
                    if fulltextsearch == '1':
                        vector = _entity_descriptor(model, 'info')[k].astext
                        clause = func.to_tsvector(vector).match(v)
                        clauses.append(clause)
                        if len(headlines) == 0:
                            headline = func.ts_headline(self.language, vector, func.to_tsquery(v))
                            headlines.append(headline)
                            order = func.ts_rank_cd(func.to_tsvector(vector), func.to_tsquery(v), 4).label('rank')
                            order_by_ranks.append(order)
                    else:
                        clauses.append(_entity_descriptor(model,
                                                          'info')[k].astext == v)
        else:
            info = json.dumps(info)
            clauses.append(cast(_entity_descriptor(model, 'info'),
                                Text) == info)
        return clauses, headlines, order_by_ranks