Exemplo n.º 1
0
    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)
Exemplo n.º 2
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