</> what is wrong with my search?

hello, everyone.
I'm new in elastic search. I have a database with almost 100000 rows (each row is one product with name) I need to check if we have the same product in our database or not. I know that I indexed all row in my database and I'm using scroll I get one product and check its name with all the indexed product but it finds nothing at the list it must find the product itself because the indexed name and searched name are completely same I think my scroll code has a problem. please help me to fix it:

$products = Product::where('merged', false)->get();

    $client = ClientBuilder::create()->build();
    foreach ($products as $product) {

            $params = [
                'scroll' => '30s',
                'index' => 'products',
                'size' => 10000,
                'body' => [
                    'query' => [
                        "bool" => [
                            "must" => [
                                'multi_match' => [
                                    'query' => $product->name,
                                    'type' => 'phrase',
                                    'fields' => ['name'],
                                ]
                            ],
                        ]
                    ]
                ]
            ];


            $response = $client->search($params);
            $scroll_id = $response['_scroll_id'];

            while (true) {

                $response = $client->scroll([
                        "scroll_id" => $scroll_id,
                        "scroll" => "30s",
                    ]
                );

                if (count($response['hits']['hits']) > 0) {
                    $scroll_id = $response['_scroll_id'];

                } else {
                    break;
                }


                dump($response['hits']['hits']);
                if (count($response['hits']['hits']) != 0) {
                    if (!PSimilarity::where('merge_name', $product->name)->first()) {
                       if (!PSimilarity::where('product_id', $product->id)->first()) {
                            PSimilarity::Create([
                                'product_id' => $product->id,
                                'merge_name' => $product->name,
                            ]);
                        }
                        foreach ($response['hits']['hits'] as $item) {
                            if (!PSimilarity::where('product_id', $item['_source']['id'])->first()) {
                                PSimilarity::Create([
                                    'product_id' => $item['_source']['id'],
                                    'merge_name' => $product->name,
                                ]);
                            }
                        }
                    }
                }
            }
        $product->Update([
            'elastic' => '3'
        ]);
    }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.