src/Builder/ElasticaQueryBuilder.php
protected function addTermToQuery(string $method, Node $node, ?Field $field = null, bool $cacheable = false): void
    {
        if ($node instanceof Emoji && $this->ignoreEmojis) {
            return;
        }

        if ($node instanceof Emoticon && $this->ignoreEmoticons) {
            return;
        }

        $value = $this->lowerCaseTerms && !$node instanceof Numbr ? strtolower((string)$node->getValue()) : $node->getValue();
        $fieldName = $this->inField() ? $field->getName() : $this->defaultFieldName;

        if ($this->inField() && !$this->inSubquery()) {
            $useBoost = $field->useBoost();
            $boost = $field->getBoost();
        } else {
            $useBoost = $node->useBoost();
            $boost = $node->getBoost();
        }

        if ('_exists_' === $fieldName) {
            $term = new Exists($value);
            $method = 'addMust';
            $cacheable = true;
        } elseif ('_missing_' === $fieldName) {
            $term = new Exists($value);
            $method = 'addMustNot';
            $cacheable = true;
        } elseif ($node instanceof Date) {
            $term = $this->createDateRangeForSingleNode(
                $fieldName,
                $node,
                $cacheable,
                $useBoost ? $boost : Date::DEFAULT_BOOST
            );
        } elseif ($node instanceof Numbr && $node->useComparisonOperator()) {
            $data = [$node->getComparisonOperator()->getValue() => $value];
            if ($useBoost) {
                $data['boost'] = $boost;
            }
            $term = $this->qb->query()->range($fieldName, $data);
        } else {
            $term = $this->qb->query()->term();
            $term->setTerm($fieldName, $value, $boost);
        }

        if ($cacheable) {
            if ('addMustNot' === $method) {
                $this->addToBoolQuery($method, $fieldName, $term);
            } else {
                $this->addToBoolQuery('addFilter', $fieldName, $term);
            }
        } else {
            $this->addToBoolQuery($method, $fieldName, $term);
        }
    }
protected function addTermToQuery(string $method, Node $node, ?Field $field = null, bool $cacheable = false): void
    {
        if ($node instanceof Emoji && $this->ignoreEmojis) {
            return;
        }

        if ($node instanceof Emoticon && $this->ignoreEmoticons) {
            return;
        }

        $value = $this->lowerCaseTerms && !$node instanceof Numbr ? strtolower((string)$node->getValue()) : $node->getValue();
        $fieldName = $this->inField() ? $field->getName() : $this->defaultFieldName;

        if ($this->inField() && !$this->inSubquery()) {
            $useBoost = $field->useBoost();
            $boost = $field->getBoost();
        } else {
            $useBoost = $node->useBoost();
            $boost = $node->getBoost();
        }

        if ('_exists_' === $fieldName) {
            $term = new Exists($value);
            $method = 'addMust';
            $cacheable = true;
        } elseif ('_missing_' === $fieldName) {
            $term = new Exists($value);
            $method = 'addMustNot';
            $cacheable = true;
        } elseif ($node instanceof Date) {
            $term = $this->createDateRangeForSingleNode(
                $fieldName,
                $node,
                $cacheable,
                $useBoost ? $boost : Date::DEFAULT_BOOST
            );
        } elseif ($node instanceof Numbr && $node->useComparisonOperator()) {
            $data = [$node->getComparisonOperator()->getValue() => $value];
            if ($useBoost) {
                $data['boost'] = $boost;
            }
            $term = $this->qb->query()->range($fieldName, $data);
        } else {
            $term = $this->qb->query()->term();
            $term->setTerm($fieldName, $value, $boost);
        }

        if ($cacheable) {
            if ('addMustNot' === $method) {
                $this->addToBoolQuery($method, $fieldName, $term);
            } else {
                $this->addToBoolQuery('addFilter', $fieldName, $term);
            }
        } else {
            $this->addToBoolQuery($method, $fieldName, $term);
        }
    }
protected function addTermToQuery ( string $ method , Node $ node , ? Field $ field = null , bool $ cacheable = false ) : void { if ( $ node instanceof Emoji && $ this -> ignoreEmojis ) { return ; } if ( $ node instanceof Emoticon && $ this -> ignoreEmoticons ) { return ; } $ value = $ this -> lowerCaseTerms && ! $ node instanceof Numbr ? strtolower ( ( string ) $ node -> getValue ( ) ) : $ node -> getValue ( ) ; $ fieldName = $ this -> inField ( ) ? $ field -> getName ( ) : $ this -> defaultFieldName ; if ( $ this -> inField ( ) && ! $ this -> inSubquery ( ) ) { $ useBoost = $ field -> useBoost ( ) ; $ boost = $ field -> getBoost ( ) ; } else { $ useBoost = $ node -> useBoost ( ) ; $ boost = $ node -> getBoost ( ) ; } if ( '_exists_' === $ fieldName ) { $ term = new Exists ( $ value ) ; $ method = 'addMust' ; $ cacheable = true ; } elseif ( '_missing_' === $ fieldName ) { $ term = new Exists ( $ value ) ; $ method = 'addMustNot' ; $ cacheable = true ; } elseif ( $ node instanceof Date ) { $ term = $ this -> createDateRangeForSingleNode ( $ fieldName , $ node , $ cacheable , $ useBoost ? $ boost : Date :: DEFAULT_BOOST ) ; } elseif ( $ node instanceof Numbr && $ node -> useComparisonOperator ( ) ) { $ data = [ $ node -> getComparisonOperator ( ) -> getValue ( ) => $ value ] ; if ( $ useBoost ) { $ data [ 'boost' ] = $ boost ; } $ term = $ this -> qb -> query ( ) -> range ( $ fieldName , $ data ) ; } else { $ term = $ this -> qb -> query ( ) -> term ( ) ; $ term -> setTerm ( $ fieldName , $ value , $ boost ) ; } if ( $ cacheable ) { if ( 'addMustNot' === $ method ) { $ this -> addToBoolQuery ( $ method , $ fieldName , $ term ) ; } else { $ this -> addToBoolQuery ( 'addFilter' , $ fieldName , $ term ) ; } } else { $ this -> addToBoolQuery ( $ method , $ fieldName , $ term ) ; } }
Adds a term to the bool query or filter context.  Filter context is used when the
request for that item could be cached, like documents with hashtag of cats.

@param string $method
@param Node   $node
@param Field  $field
@param bool   $cacheable
Adds a term to the bool query or filter context . Filter context is used when the request for that item could be cached like documents with hashtag of cats .