E
E
Eugene2016-07-06 13:53:17
Yii
Eugene, 2016-07-06 13:53:17

Index search elasticsearch Yii2. How to select records containing text?

Good afternoon everyone! Can someone provide a sample code for index lookup. The index is there when I do:

$query = Article::find();
    var_dump($query->all());

The entire index is displayed. But to find part of the text, I just can not figure it out.
The example in the documentation is not working:
$query = Article::find()->query([
    "fuzzy_like_this" => [
        "fields" => ["title", "description"],
        "like_text" => "This query will return articles that are similar to this text :-)",
        "max_query_terms" => 12
    ]
]);

Yii 2.0.9
Elasticsearch 2.3.3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-07-06
@Elgorm

Sit down and figure it out :)

$query->query(['query_string'=>[
            'default_field'=>'_all',
            'query'=>"*".$q."*",
        ]]);

Seems to be working as it should.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question