Beispiel #1
0
    def search_query(cls, username, q, fields=[], sanitize=True, **kwargs):
        """Search the Elasticsearch index using a query string

        Use a query string to search the ES index. This method will search
        on the fields **name**, and **keywords**

        :param str username: username making the request
        :param str q: string to query the ES index
        :param list fields: list of strings

        .. note:: In order to make this method scalable more fields can be
            searched by passing a **fields** keyword argument. You can add
            the **systemTags** field like so:
            >>> Object.search('username', 'txt', fields = ['systemTags'])
        """
        if isinstance(fields, basestring):
            fields = fields.split(',')

        search_fields = ['name', 'name._exact', 'keywords']

        if fields:
            search_fields += fields

        sq = Q('bool',
               must=query_utils.files_wildcard_query(q, search_fields),
               filter=query_utils.files_access_filter(username))
        s = cls.search()
        s.query = sq
        s = s.sort('path._exact', 'name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)
        #logger.debug('limit: %s. offset: %s' % (limit, offset))
        return res, s[offset:limit]
Beispiel #2
0
    def search_query(cls, system_id, username, qs, fields = None):
        query_fields = ["description",
                  "facility.country"
                  "facility.name",
                  "facility.state",
                  "name._exact",
                  "name",
                  "project",
                  "startDate",
                  "title"]
        if fields is not None:
            query_fields += fields

        q = query_utils.files_wildcard_query(q, query_fields)
        s = cls.search()
        s.query = q
        if fields is not None:
            s = s.fields(fields)

        s = s.sort('name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        return res, s[offset:limit]
Beispiel #3
0
    def search_query(cls, system_id, username, qs, fields = [], **kwargs):
        query_fields = ["description",
                  "endDate",
                  "equipment.component",
                  "equipment.equipmentClass",
                  "equipment.facility",
                  "fundorg"
                  "fundorgprojid",
                  "name",
                  "organization.name",
                  "pis.firstName",
                  "pis.lastName",
                  "title"]
        if fields is not None:
            query_fields += fields

        q = query_utils.files_wildcard_query(qs, query_fields)

        s = cls.search()
        s.query = q
        s = s.sort('name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        return res, s[offset:limit]
Beispiel #4
0
    def search_query(cls, username, q, fields = [], sanitize = True, **kwargs):
        """Search the Elasticsearch index using a query string

        Use a query string to search the ES index. This method will search 
        on the fields **name**, and **keywords**

        :param str username: username making the request
        :param str q: string to query the ES index
        :param list fields: list of strings

        .. note:: In order to make this method scalable more fields can be
            searched by passing a **fields** keyword argument. You can add
            the **systemTags** field like so:
            >>> Object.search('username', 'txt', fields = ['systemTags'])
        """
        if isinstance(fields, basestring):
            fields = fields.split(',')

        search_fields = ['name', 'name._exact', 'keywords']

        if fields:
            search_fields += fields

        sq = Q('filtered',
                query = query_utils.files_wildcard_query(q, search_fields),
                filter = query_utils.files_access_filter(username)
                )
        s = cls.search()
        s.query = sq
        s = s.sort('path._exact', 'name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)
        #logger.debug('limit: %s. offset: %s' % (limit, offset))
        return res, s[offset:limit]
Beispiel #5
0
    def search_query(cls, system_id, username, qs, fields=[], **kwargs):
        query_fields = [
            "description", "endDate", "equipment.component",
            "equipment.equipmentClass", "equipment.facility", "fundorg"
            "fundorgprojid", "name", "organization.name", "pis.firstName",
            "pis.lastName", "title"
        ]
        if fields is not None:
            query_fields += fields

        q = query_utils.files_wildcard_query(qs, query_fields)

        s = cls.search()
        s.query = q
        s = s.sort('name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        return res, s[offset:limit]
Beispiel #6
0
    def search_query(cls, system_id, username, q, fields=[], **kwargs):
        if isinstance(fields, basestring):
            fields = fields.split(',')

        query_fields = ["name", "name._exact"]

        if fields is not None:
            query_fields += fields

        s = cls.search()
        s.query = query_utils.files_wildcard_query(q, query_fields)

        s = s.sort('type', 'path._exact', 'name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        #logger.debug('files offset: {}, files limit: {}'.format(offset, limit))

        return res, s[offset:limit]
Beispiel #7
0
    def search_query(cls, system_id, username, q, fields = [], **kwargs):
        if isinstance(fields, basestring):
            fields = fields.split(',')

        query_fields = ["name", "name._exact"]
        
        if fields is not None:
            query_fields += fields

        s = cls.search()
        s.query = query_utils.files_wildcard_query(q, query_fields)

        s = s.sort('type', 'path._exact', 'name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        #logger.debug('files offset: {}, files limit: {}'.format(offset, limit))

        return res, s[offset:limit]
Beispiel #8
0
    def search_query(cls, system_id, username, qs, fields=None):
        query_fields = [
            "description", "facility.country"
            "facility.name", "facility.state", "name._exact", "name",
            "project", "startDate", "title"
        ]
        if fields is not None:
            query_fields += fields

        q = query_utils.files_wildcard_query(q, query_fields)
        s = cls.search()
        s.query = q
        if fields is not None:
            s = s.fields(fields)

        s = s.sort('name._exact')

        res, s = cls._execute_search(s)
        offset, limit = cls.get_paginate_limits(res, **kwargs)

        return res, s[offset:limit]