예제 #1
0
파일: api.py 프로젝트: jgrocha/ckan
                        if field in search.DEFAULT_OPTIONS.keys() or field in IGNORE_FIELDS:
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
                            query_fields.add(field, v)

                    results = query.run(query=params.get("q"), fields=query_fields, options=options)
                else:
                    # For package searches in API v3 and higher, we can pass
                    # parameters straight to Solr.
                    if ver in [1, 2]:
                        # Otherwise, put all unrecognised ones into the q
                        # parameter
                        params = search.convert_legacy_parameters_to_solr(params)
                    query = search.query_for(model.Package)

                    # Remove any existing fq param and set the capacity to
                    # public
                    if "fq" in params:
                        del params["fq"]
                    params["fq"] = "+capacity:public"
                    # if callback is specified we do not want to send that to
                    # the search
                    if "callback" in params:
                        del params["callback"]
                    results = query.run(params)
                return self._finish_ok(results)
            except search.SearchError, e:
                log.exception(e)
예제 #2
0
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
                            query_fields.add(field, v)

                    results = query.run(
                        query=params.get('q'), fields=query_fields, options=options
                    )
                else:
                    # For package searches in API v3 and higher, we can pass
                    # parameters straight to Solr.
                    if ver in u'12':
                        # Otherwise, put all unrecognised ones into the q parameter
                        params = convert_legacy_parameters_to_solr(params)
                    query = query_for(model.Package)
                    results = query.run(params)
                return self._finish_ok(results)
            except SearchError, e:
                log.exception(e)
                return self._finish_bad_request(
                    gettext('Bad search option: %s') % e)
        else:
            return self._finish_not_found(
                gettext('Unknown register: %s') % register)

    @classmethod
    def _get_search_params(cls, request_params):
        if request_params.has_key('qjson'):
            try:
예제 #3
0
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
                            query_fields.add(field, v)

                    results = query.run(query=params.get('q'),
                                        fields=query_fields,
                                        options=options)
                else:
                    # For package searches in API v3 and higher, we can pass
                    # parameters straight to Solr.
                    if ver in u'12':
                        # Otherwise, put all unrecognised ones into the q parameter
                        params = convert_legacy_parameters_to_solr(params)
                    query = query_for(model.Package)
                    results = query.run(params)
                return self._finish_ok(results)
            except SearchError, e:
                log.exception(e)
                return self._finish_bad_request(
                    gettext('Bad search option: %s') % e)
        else:
            return self._finish_not_found(
                gettext('Unknown register: %s') % register)

    @classmethod
    def _get_search_params(cls, request_params):
        if request_params.has_key('qjson'):
            try:
예제 #4
0
파일: api.py 프로젝트: gitter-badger/ckan
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
                            query_fields.add(field, v)

                    results = query.run(
                        query=params.get('q'), fields=query_fields, options=options
                    )
                else:
                    # For package searches in API v3 and higher, we can pass
                    # parameters straight to Solr.
                    if ver in [1, 2]:
                        # Otherwise, put all unrecognised ones into the q parameter
                        params = search.convert_legacy_parameters_to_solr(params)
                    query = search.query_for(model.Package)
                    results = query.run(params)
                return self._finish_ok(results)
            except search.SearchError, e:
                log.exception(e)
                return self._finish_bad_request(
                    gettext('Bad search option: %s') % e)
        else:
            return self._finish_not_found(
                gettext('Unknown register: %s') % register)

    @classmethod
    def _get_search_params(cls, request_params):
        if request_params.has_key('qjson'):
            try: