本文整理汇总了Python中adsabs.core.solr.QueryBuilderSearch.build方法的典型用法代码示例。如果您正苦于以下问题:Python QueryBuilderSearch.build方法的具体用法?Python QueryBuilderSearch.build怎么用?Python QueryBuilderSearch.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adsabs.core.solr.QueryBuilderSearch
的用法示例。
在下文中一共展示了QueryBuilderSearch.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: facets
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def facets():
"""
returns facet sets for a search query
"""
form = QueryForm.init_with_defaults(request.values)
if form.validate():
query_components = QueryBuilderSearch.build(form, request.values, facets_components=True)
resp = solr.query(**query_components)
return render_template('facets_sublevel.html', resp=resp, facet_field_interf_id=query_components['facet_field_interf_id'] )
示例2: test_only_query
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_only_query(self):
"""basic case"""
with self.app.test_request_context('/search/?q=+author%3A"civano"'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano")'
expected['ui_q'] = u' author:"civano"'
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例3: test_query_with_default_params_13
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_13(self):
"""with article only property"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&article=y'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND NOT property:NONARTICLE AND database:"astronomy"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'database:"astronomy"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例4: test_query_with_default_params_02
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_02(self):
"""including database filter (uppercase)"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=ASTRONOMY'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND database:"ASTRONOMY"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'database:"ASTRONOMY"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例5: test_query_with_default_params_11
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_11(self):
"""with journal abbr fitler (wrong syntax)"""
with self.app.test_request_context('/search/?q=+author%3A"civano"+bibstem%3A"ApJ%3B+AJ"&db_f=astronomy'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano" bibstem:"ApJ; AJ") AND database:"astronomy"'
expected['ui_q'] = u' author:"civano" bibstem:"ApJ; AJ"'
expected['ui_filters'] = [u'database:"astronomy"',]
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例6: test_query_with_default_params_12
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_12(self):
"""with refereed property"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&prop_f=refereed'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND property:"refereed" AND database:"astronomy"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'property:"refereed"', u'database:"astronomy"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例7: test_query_with_default_params_08
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_08(self):
"""with date range"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&month_from=09&year_from=2009&year_to=2010'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND pubdate:[2009-09-00 TO 2010-12-00] AND database:"astronomy"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'pubdate:[2009-09-00 TO 2010-12-00]', u'database:"astronomy"',]
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例8: test_query_with_default_params_04
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_04(self):
"""2nd order query"""
with self.app.test_request_context('/search/?q=hot(galaxy+clusters)&db_f=astronomy'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'(hot(galaxy clusters)) AND database:"astronomy"'
expected['ui_q'] = u'hot(galaxy clusters)'
expected['ui_filters'] = [u'database:"astronomy"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例9: test_query_with_default_params_03
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_03(self):
"""non-default database filter"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=physics'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND database:"physics"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'database:"physics"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例10: test_query_with_default_params_19
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_19(self):
"""with facet selection"""
with self.app.test_request_context('/search/?q=*&db_f=astronomy&year_f=[2000 TO 2010]'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'(*) AND year:[2000 TO 2010] AND database:"astronomy"'
expected['ui_q'] = u'*'
expected['ui_filters'] = [u'year:[2000 TO 2010]',
u'database:"astronomy"',]
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例11: test_query_with_default_params_16
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_16(self):
"""with facet selection"""
with self.app.test_request_context('/search/?q=author%3A"Civano"&db_f=astronomy&aut_f=-("1%2FCivano%2C+F%2FCivano%2C Francesca M."+OR+"1%2FElvis%2C M%2FElvis%2C Martin")'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'(author:"Civano") AND NOT author_facet_hier:("1/Civano, F/Civano, Francesca M." OR "1/Elvis, M/Elvis, Martin") AND database:"astronomy"'
expected['ui_q'] = u'author:"Civano"'
expected['ui_filters'] = [u'-author_facet_hier:("1/Civano, F/Civano, Francesca M." OR "1/Elvis, M/Elvis, Martin")',
u'database:"astronomy"',]
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
示例12: test_query_with_default_params_26
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_26(self):
"""test no fulltext"""
with self.app.test_request_context('/search/?q=civano&no_ft=1'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'(civano)'
expected['ui_q'] = u'civano'
expected['ui_filters'] = []
expected['query_fields'] = config.SOLR_SEARCH_DEFAULT_QUERY_FIELDS_METADATA_ONLY
form = QueryForm.init_with_defaults(request.values)
actual = QueryBuilderSearch.build(form, request.values)
self.assertEqual(actual, expected)
示例13: test_query_with_default_params_25
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_25(self):
"""test topn operator"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&re_sort_type=POPULARITY&re_sort_dir=asc&topn=1000'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'topn(1000, (( author:"civano") AND database:"astronomy"), "read_count asc")'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'database:"astronomy"']
expected['sort'] = None
form = QueryForm.init_with_defaults(request.values)
actual = QueryBuilderSearch.build(form, request.values)
self.assertEqual(actual, expected)
示例14: test_query_with_default_params_22
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_22(self):
"""with different row count"""
with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&nr=33'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'( author:"civano") AND database:"astronomy"'
expected['ui_q'] = u' author:"civano"'
expected['ui_filters'] = [u'database:"astronomy"']
expected['rows'] = "33"
form = QueryForm.init_with_defaults(request.values)
actual = QueryBuilderSearch.build(form, request.values)
self.assertEqual(actual, expected)
示例15: test_query_with_default_params_14
# 需要导入模块: from adsabs.core.solr import QueryBuilderSearch [as 别名]
# 或者: from adsabs.core.solr.QueryBuilderSearch import build [as 别名]
def test_query_with_default_params_14(self):
"""with facet selection"""
with self.app.test_request_context('/search/?q=author%3A"Civano"&aut_f=0%2FComastri%2C+A&db_f=astronomy&grant_f=0%2FNASA-HQ'):
expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
expected['q'] = u'(author:"Civano") AND grant_facet_hier:"0/NASA-HQ" AND author_facet_hier:"0/Comastri, A" AND database:"astronomy"'
expected['ui_q'] = u'author:"Civano"'
expected['ui_filters'] = [u'grant_facet_hier:"0/NASA-HQ"',
u'author_facet_hier:"0/Comastri, A"',
u'database:"astronomy"']
form = QueryForm.init_with_defaults(request.values)
self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)