Return a new :class:`Query` obtained form the intersection of this
:class:`Query` with one or more *queries*. Workds the same way as
the :meth:`union` method.
438191
def intersect(self, *queries):
        ''''''
        q = self._clone()
        q.intersections += queries
        return q
691898
def query(self, *args, **kwargs):
        
        clone = self._clone()
        queries = []
        from pyes.query import Query

        if args:
            for f in args:
                if isinstance(f, Query):
                    queries.append(f)
                else:
                    raise TypeError('Only Query objects can be passed as argument')

        for field, value in kwargs.items():
            if value == [None]:
                value = ["$$$$"]
            queries.append(self._build_inner_query(field, value))

        clone._queries.extend(queries)
        return clone
1190851
def query(self, query, **kwargs):
        
        params = {'q': query}
        response = requests.get(self._get_norm_query_url(),
                                headers=self._get_rest_headers(),
                                params=params,
                                **kwargs)
        if response.status_code != requests.codes.ok:
            raise Exception(response.content)

        return response.json()
315340
def intersection(self,other):
        
        if self.everything:
            if other.everything:
                return DiscreteSet()
            else:
                return DiscreteSet(other.elements)
        else:
            if other.everything:
                return DiscreteSet(self.elements)
            else:
                return DiscreteSet(self.elements.intersection(other.elements))
360316
def query_all(self):
        
        if DJANGO_20_PLUS:
            obj = self._clone()
        else:
            obj = self._clone(klass=SalesforceQuerySet)  # pylint: disable=unexpected-keyword-arg
        obj.query.set_query_all()
        return obj
143050
def query(self):
        
        query = self._builder_class(
            self,
            self._query_grammar,
            self._post_processor,
            **self._builder_default_kwargs
        )

        return query
883089
def _canonicalize_query(self, query):

        

        def transform_query(q):

            for encoder in self.query_encoders:
                q = encoder.encode(q,[])

            if isinstance(q, dict):
                nq = {}
                for key,value in q.items():
                    new_key = key
                    if isinstance(value,dict) and len(value) == 1 and list(value.keys())[0].startswith('$'):
                        if list(value.keys())[0] in ('$all','$in'):
                            if list(value.values())[0] and isinstance(list(value.values())[0][0],Document):
                                if self._use_pk_based_refs:
                                    new_key+='.pk'
                                else:
                                    new_key+='.__ref__'
                    elif isinstance(value,Document):
                        if self._use_pk_based_refs:
                            new_key+='.pk'
                        else:
                            new_key+='.__ref__'
                    nq[new_key] = transform_query(value)
                return nq
            elif isinstance(q, (list,QuerySet,tuple)):
                return [transform_query(x) for x in q]
            elif isinstance(q,Document):
                collection = self.get_collection_for_obj(q)
                if self._use_pk_based_refs:
                    return q.pk
                else:
                    return "%s:%s" % (collection,q.pk)
            else:
                return q

        return transform_query(query)
1006006
def query(self):
        
        if self._rawquery==True:
            return self.__query
        return flatten(self.__query)
431226
def match(self, query_dict=None, **query):
        
        if query_dict:
            self._q.append({'$match': query_dict})
        else:
            self._q.append({'$match': query})
        return self
394905
async def query_pathing(
        self, start: Union[Unit, Point2, Point3], end: Union[Point2, Point3]
    ) -> Optional[Union[int, float]]:
        
        assert isinstance(start, (Point2, Unit))
        assert isinstance(end, Point2)
        if isinstance(start, Point2):
            result = await self._execute(
                query=query_pb.RequestQuery(
                    pathing=[
                        query_pb.RequestQueryPathing(
                            start_pos=common_pb.Point2D(x=start.x, y=start.y),
                            end_pos=common_pb.Point2D(x=end.x, y=end.y),
                        )
                    ]
                )
            )
        else:
            result = await self._execute(
                query=query_pb.RequestQuery(
                    pathing=[
                        query_pb.RequestQueryPathing(unit_tag=start.tag, end_pos=common_pb.Point2D(x=end.x, y=end.y))
                    ]
                )
            )
        distance = float(result.query.pathing[0].distance)
        if distance <= 0.0:
            return None
        return distance
163417
def intersection(self, *others, **kwargs):
        
        return self._combine_variant_collections(
            combine_fn=set.intersection,
            variant_collections=(self,) + others,
            kwargs=kwargs)
930287
def distinct(self):
        
        new_query_set = self.clone()
        new_query_set.query.distinct = True
        return new_query_set
617961
def intersection(self, other):
        
        # if self or other is empty the intersection will be empty
        result = IntervalSet()
        for other_inter in other:
            for interval in self:
                this_intervals_intersection = other_inter.intersect(interval)
                if this_intervals_intersection is not None:
                    result._add(this_intervals_intersection)
        return result
822583
def _set_join(self, query=None):
        
        if not query:
            query = self._query

        base_table = self._related.get_table()

        key = '%s.%s' % (base_table, self._related.get_key_name())

        query.join(self._table, key, '=', self.get_other_key())

        return self
670434
public QueryBuilder unionAll() {
        this.firstQuery = query();
        this.firstQuerySetOperation = Operation.UNION;
        this.firstQueryAll = true;
        clear(false);
        return this;
    }
1301598
def query(self):
        
        queryWidget = self.queryWidget()
        
        # check to see if there is an active container for this widget
        container = queryWidget.containerFor(self)
        if container:
            return container.query()
        
        elif QueryCompound.typecheck(self._query):
            return self._query
        
        # generate a new query from the editor
        column = self.uiColumnDDL.currentSchemaPath()
        plugin = self.currentPlugin()
        editor = self.editor()
        op     = self.uiOperatorDDL.currentText()
        
        if column and plugin:
            query = Query(column)
            plugin.setupQuery(query, op, editor)
            return query
        else:
            return Query()
591527
public QueryBuilder union() {
        this.firstQuery = query();
        this.firstQuerySetOperation = Operation.UNION;
        this.firstQueryAll = false;
        clear(false);
        return this;
    }