def test_solr_to_pelias_params(self):
     solr_params = {}
     solr_params['q'] = 'val'
     solr_params['rows'] = '6'
     pelias_params_str = PeliasToSolr.solr_to_pelias_param_str(solr_params)
     self.assertTrue("text=val" in pelias_params_str)
     self.assertTrue("size=6" in pelias_params_str)
 def test_call_live_pelias_server(self):
     """
     https://ws-st.trimet.org/pelias/v1/autocomplete?text=888%20SE%20Lambert%20St
     :return:
     """
     solr_params = {}
     solr_params['q'] = 'val'
     solr_params['rows'] = '6'
     pelias_params_str = PeliasToSolr.solr_to_pelias_param_str(solr_params)
     self.assertTrue("text=val" in pelias_params_str)
     self.assertTrue("size=6" in pelias_params_str)
    def test_switch_autocomplete_to_search_service(self):
        """
        send an interpolated address to the query, and expect that

        https://ws-st.trimet.org/pelias/v1/autocomplete?text=888%20SE%20Lambert%20St
        https://ws-st.trimet.org/pelias/v1/search?text=888%20SE%20Lambert%20St
        """
        solr_params = {}
        solr_params['q'] = '888 SE Lambert St'
        res = PeliasToSolr.call_pelias(solr_params, self.auto_url,
                                       self.search_url)
        self.assertTrue(res.num_records() > 0)
        self.assertTrue("888 SE Lambert" in res.response.docs[0].name)
Beispiel #4
0
    def solr_api(request, def_rows=10):
        """ will handle SOLR api params, then call pelias """
        solr_params = {}

        # step 1: SOLR params
        query = request.params.get('q')
        if not query:
            query = request.params.get('text')
        solr_params['q'] = query

        rows = request.params.get('rows')
        solr_params['rows'] = object_utils.safe_int(rows, def_rows)

        fq = request.params.get('fq')
        if fq:
            solr_params['fq'] = fq

        wt = request.params.get('wt', 'json')
        solr_params['wt'] = wt

        # step 2: wrap call to Pelias and get SOLR response
        ret_val = PeliasToSolr.call_pelias(solr_params, pelias_autocomplete_url, pelias_search_url)
        return ret_val
 def parse(self, file_name):
     file_path = file_utils.path_join(self.base_path, file_name)
     json = json_utils.file_to_json(file_path)
     p = PeliasToSolr.parse_json(json)
     return p