Example #1
0
 def query_es(self):
     is_simple, query = smart_query_string(self.query)
     default_fields = ["username.exact", "last_name", "first_name"]
     q = {
         "query": {"query_string": {
             "query": query,
             "default_operator": "AND",
             "fields": default_fields if is_simple else None
         }},
         "filter": {"and": ADD_TO_ES_FILTER["users"][:]},
         "sort": {'username.exact': 'asc'},
     }
     params = {
         "domain": self.domain,
         "is_active": not self.show_inactive,
     }
     self.es_results = es_query(params=params, q=q, es_url=ES_URLS["users"],
                        size=self.users_list_limit, start_at=self.users_list_skip)
Example #2
0
    def query_es(self, limit, skip, query=None):
        is_simple, query = smart_query_string(query or "")

        web_user_filter = [{"term": {"user.domain_memberships.domain": self.domain}}]
        web_user_filter.extend(ADD_TO_ES_FILTER["web_users"])

        default_fields = ["username", "last_name", "first_name"]
        q = {
            "query": {
                "query_string": {
                    "query": query,
                    "default_operator": "AND",
                    "fields": default_fields if is_simple else None,
                }
            },
            "filter": {"and": web_user_filter},
            "sort": {"username.exact": "asc"},
        }
        return es_query(params={}, q=q, es_url=ES_URLS["users"], size=limit, start_at=skip)