• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sqlalchemy_searchable.parse_search_query函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sqlalchemy_searchable.parse_search_query函数的典型用法代码示例。如果您正苦于以下问题:Python parse_search_query函数的具体用法?Python parse_search_query怎么用?Python parse_search_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_search_query函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_not_between_words

 def test_not_between_words(self):
     assert parse_search_query('wars -star') == (
         'wars:* & ! star:*'
     )
     assert parse_search_query(u'äää -ööö') == (
         u'äää:* & ! ööö:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:7,代码来源:test_parse_search_query.py


示例2: test_emails_with_email_tokens

 def test_emails_with_email_tokens(self):
     assert (
         parse_search_query(
             '[email protected]',
             parser=SearchQueryParser(emails_as_tokens=True)
         ) ==
         '[email protected]:*'
     )
开发者ID:deviba01,项目名称:SkillsConnect,代码行数:8,代码来源:test_parse_search_query.py


示例3: simple_search

    def simple_search(query):
        q1 = Article.query.filter(Article.search_vector.match_tsquery(parse_search_query(query)))
        #q2 = Article.query.filter(Article.authors.any(Author.lastname.ilike(query)))
        #q2 = Article.query.filter(Article.authors.any(func.lower(Author.lastname) == func.lower(query)))

        #q = q1.union(q2)

        return q1.order_by((Article.created + cast("0", Interval)).desc())
开发者ID:circuitqed,项目名称:arXiver,代码行数:8,代码来源:models.py


示例4: test_supports_custom_parsers

 def test_supports_custom_parsers(self):
     assert (
         parse_search_query(
             'star wars',
             parser=SearchQueryParser(wildcard='*')
         )
         ==
         'star* & wars*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:9,代码来源:test_parse_search_query.py


示例5: base_search

def base_search(query):
    filter_list = []
    remove_list = []
    
    #get list of category flags given
    #and remove them from the query
    if '-phd' in query.lower():
        remove_list.append(People.phd==None)
        query = query.replace('-phd','')
    elif 'phd' in query.lower():
        filter_list.append(People.phd)
        query = query.replace('phd','')
    if '-staff' in query.lower():
        remove_list.append(People.staff==None)
        query = query.replace('-staff','')
    elif 'staff' in query.lower():
        filter_list.append(People.staff)
        query = query.replace('staff','')
    if '-postdoc' in query.lower():
        remove_list.append(People.postdoc==None)
        query = query.replace('-postdoc','')
    elif 'postdoc' in query.lower():
        filter_list.append(People.postdoc)
        query = query.replace('postdoc','')
    if '-associate' in query.lower():
        remove_list.append(People.associate==None)
        query = query.replace('-associate','')
    elif 'associate' in query.lower():
        filter_list.append(People.associate)
        query = query.replace('associate','')

    #for a simple "query all" function
    if ('*' in query) or not query.strip(' '):
        all = People.query.filter(and_(*remove_list)).filter(or_(*filter_list))
        return all

    #for each category, query on the join using combined search vector
    phd_vec = People.search_vector | PhD.search_vector
    phd = db.session.query(People).join(PhD).filter(phd_vec.match(parse_search_query(query)))

    pos_vec = People.search_vector | Positions.search_vector
    staff = db.session.query(People).join(Staff).join(Positions).filter(pos_vec.match(parse_search_query(query)))
    associates = db.session.query(People).join(Associates).join(Positions).filter(pos_vec.match(parse_search_query(query)))
    
    staff_nopos = People.query.join(Staff).filter(~(Staff.position.any())).search(query)
    assoc_nopos = People.query.join(Associates).filter(~(Associates.position.any())).search(query)

    others = People.query.filter(People.staff==None, People.associate==None, People.phd==None).search(query)
    
    #union all categories, and filter by category tags
    union = phd.union(staff, staff_nopos, associates, assoc_nopos, others)
    union = union.filter(and_(*remove_list)).filter(or_(*filter_list))
    return union
开发者ID:AWilcke,项目名称:LFCS-History,代码行数:53,代码来源:func.py


示例6: feed_articles

 def feed_articles(self):
     # explain (analyze,buffers) select * from article INNER JOIN (select id from article as blah where search_vector @@ to_tsquery('circuit:* & qed:* | qubit:*') union select article_id from articlesauthors as blah where author_id in (54962, 55738, 85464, 85465, 125598, 55921)) on id=blah order by created desc;
     #select * from (select distinct on (id) * from (select articles.* from articles where search_vector @@ ... union all select a.* from articles a join articlesauthors aa on ... where author_id = any (...)) s1) s2 order by created_at desc;
     #explain (analyze,buffers) select article.*, (article.id+0) as dummy_article_id from article where search_vector @@ to_tsquery('circuit:* & qed:* | qubit:*') union select a.*, (a.id+0) as dummy_article_id from article a join articlesauthors aa on a.id=aa.article_id where author_id in (54962, 55738, 85464, 85465, 125598, 55921) order by created desc;search_query = parse_search_query(' or '.join([kw.keyword for kw in self.keywords]))
     #select article.*, (article.id+0) as dummy_article_id from article where search_vector @@ to_tsquery('circuit:* & qed:* | qubit:*') union select a.*, (a.id+0) as dummy_article_id from article a join articlesauthors aa on a.id=aa.article_id where author_id in (54962, 55738, 85464, 85465, 125598, 55921) order by created desc;search_query = parse_search_query(' or '.join([kw.keyword for kw in self.keywords]))
     search_query = parse_search_query(' or '.join([kw.keyword for kw in self.keywords]))
     alist = [a.id for a in self.authors]
     s1 = select([ArticleAuthor.article_id]).where(ArticleAuthor.author_id.in_(alist))
     s2 = select([Article.id]).where(Article.search_vector.match_tsquery(search_query))
     q = Article.query.filter(Article.id.in_(s1.union(s2))).order_by((Article.created + cast("0",
                                                                                             Interval)).desc())  #The addition of the extra interval is important because it changes the way the query plan is computed and makes it run 100x faster!
     return q
开发者ID:circuitqed,项目名称:arXiver,代码行数:12,代码来源:models.py


示例7: test_space_as_and

 def test_space_as_and(self):
     assert parse_search_query('star wars') == 'star:* & wars:*'
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例8: test_multiple_ors

 def test_multiple_ors(self):
     assert parse_search_query('star or or or wars') == 'star:* | wars:*'
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例9: test_or

 def test_or(self):
     assert parse_search_query('star or wars') == 'star:* | wars:*'
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例10: test_hyphen_between_words

 def test_hyphen_between_words(self):
     assert parse_search_query('star-wars') == 'star:* & wars:*'
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例11: test_or_within_a_token_preceded_by_space

 def test_or_within_a_token_preceded_by_space(self):
     assert parse_search_query('star organs') == (
         'star:* & organs:*'
     )
开发者ID:bjmc,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py


示例12: test_empty_parenthesis

 def test_empty_parenthesis(self):
     assert parse_search_query('()') == ''
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例13: test_and_within_a_token_preceded_by_space

 def test_and_within_a_token_preceded_by_space(self):
     assert parse_search_query('star andromeda') == (
         'star:* & andromeda:*'
     )
开发者ID:bjmc,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py


示例14: test_single_quotes

 def test_single_quotes(self):
     assert parse_search_query("'star") == (
         'star:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py


示例15: test_multiple_and

 def test_multiple_and(self):
     assert parse_search_query('star and and wars') == 'star:* & wars:*'
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:2,代码来源:test_parse_search_query.py


示例16: test_search_supports_non_english_characters

 def test_search_supports_non_english_characters(self):
     parse_search_query(u'ähtäri') == (
         u'ähtäri:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py


示例17: test_double_quotes

 def test_double_quotes(self):
     assert parse_search_query('"star') == (
         'star:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py


示例18: query_parsed

 def query_parsed(self):
     return searchable.parse_search_query(self.query)
开发者ID:vovapolu,项目名称:tm_navigator,代码行数:2,代码来源:routes.py


示例19: test_multiple_spaces_as_and

 def test_multiple_spaces_as_and(self):
     assert (
         parse_search_query('star   wars    luke') ==
         'star:* & wars:* & luke:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:5,代码来源:test_parse_search_query.py


示例20: test_not

 def test_not(self):
     assert parse_search_query('-star') == (
         '! star:*'
     )
开发者ID:astonm,项目名称:sqlalchemy-searchable,代码行数:4,代码来源:test_parse_search_query.py



注:本文中的sqlalchemy_searchable.parse_search_query函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sqlalchemy_utils.create_database函数代码示例发布时间:2022-05-27
下一篇:
Python context.store_context函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap