本文整理汇总了Python中adsabs.core.solr.QueryBuilderSearch类的典型用法代码示例。如果您正苦于以下问题:Python QueryBuilderSearch类的具体用法?Python QueryBuilderSearch怎么用?Python QueryBuilderSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QueryBuilderSearch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: facets
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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)