V
V
v7sila2019-03-05 11:28:33
elasticsearch
v7sila, 2019-03-05 11:28:33

How to make the search work correctly and get a hint when a query is partially entered?

When you enter a rub - a fur coat is displayed. When searching for a sapo - displays a sabot. Although the index contains products Shirt, Boots.

protected function prepareSuggestParams(array $arParams) {
        $params = [
            'index' => $this->index,
            'body' => [
                'my_suggest' => [
                        'text' => $arParams['text'],
                        'phrase' => [
                            'field' => 'FIELDS.SUGGEST_COMBINED',
                            'size' => 2,
                            'gram_size' => 1,
                            'real_word_error_likelihood' => 0.5,
                            'separator' => ' ',
                            'max_errors' => 2,
                            "direct_generator" => [ 
                                [
                                    "field" => "FIELDS.SUGGEST_COMBINED",
                                    'prefix_len' => 0,
                                    'max_edits' => 1
                                ] 
                            ],
                            "collate" => [
                                "query" =>  [
                                    "match" =>  [
                                        "{{field_name}}" =>  [
                                            "query" =>  "{{suggestion}}",
                                            "operator" =>  "and"
                                        ]
                                    ]
                                ],
                                "params" =>  [
                                    "field_name" =>  "FIELDS.SUGGEST_COMBINED"
                                ],
                                "prune" => true
                            ]
                        ]
                ]
            ]
        ];

        return $params;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question