def test_faceting(): from datastructures import Facet from query import Query import connection import config config.set_config('dev', '0.0.0.0', 8983) config.load_config('dev') # set up addresses and stuff response = connection.search(Query(Facet('regions', mincount=1)))
def test_searchables(): from datastructures import Searchable class CategorySearchable(Searchable): multivalued = True field_name = 'category' solf_field = 'category' solr_query_param = 'fq' connection.search(Query(CategorySearchable(category_value)))
def find(*args, **kwargs): """ Wrapper around the API: - loads default config (check config module) - builds query from *args and **kwargs - passes that query into connection for searching """ config.load_config(config.DEFAULT_CONFIG) connection_kwargs = {} if 'wt' in kwargs: connection_kwargs['wt'] = kwargs.pop('wt') return connection.search(query.Query(*args, **kwargs), **connection_kwargs)
def test_connection(): from datastructures import Searchable, Facet from query import Query import connection import config # # define all , will be rewritten to set_up/tear_down when i find some time for cleanup # class CategorySearchable(Searchable): multivalued = True solr_query_field = 'categories' solr_query_param = 'fq' class RegionSearchable(Searchable): multivalued = True solr_query_field = 'regions' solr_query_param = 'fq' reg1 = RegionSearchable(1) cat1 = CategorySearchable(1) OR_searchable = Searchable(reg1, cat1, operator='OR') config.set_config('dev', '0.0.0.0', 8983) config.load_config('dev') # set up addresses and stuff connection.search(Query(OR_searchable, Facet('regions', mincount=1)))
def search(): search_turn = request.form['search'] results = connection.search(search_turn) # return f"{results[0]}" return render_template('search.html', results=results)