Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support like query #37

Open
asoqa opened this issue Dec 2, 2015 · 3 comments
Open

Support like query #37

asoqa opened this issue Dec 2, 2015 · 3 comments
Labels
type:enhancement Enhancement

Comments

@asoqa
Copy link

asoqa commented Dec 2, 2015

es support wildcard query, something like this:

    private function buildLikeCondition($operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }

        if( $operator == 'like') {
            $like_text = "*" . $operands[1] . "*";
            $query = ['wildcard' => [$operands[0]=>$like_text]];
        }
        return $query;
//         throw new NotSupportedException('like conditions are not supported by elasticsearch.');
    }
@cebe cebe added this to the 2.0.x milestone Dec 3, 2015
@cebe cebe added the type:enhancement Enhancement label Dec 3, 2015
lunaticusz pushed a commit to lunaticusz/yii2-elasticsearch that referenced this issue Jun 6, 2017
@samdark samdark removed this from the 2.0.x milestone Apr 30, 2019
@lubosdz
Copy link

lubosdz commented Aug 3, 2021

I know this is old issue - but is there mentioned somewhere why LIKE condition cannot be supported out of the box for column type keyword / text ?
Currently throws Exception.

@samdark
Copy link
Member

samdark commented Aug 3, 2021

I think it wasn't initially implemented. Efficient wildcard-fields were introduced fairly recently and before that wildcard queries were super-inefficient and even required a special option to be allowed.

@lubosdz
Copy link

lubosdz commented Aug 3, 2021

@samdark Thank you, I wasn't sure, if I missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants