# \</\> what is wrong with my search?

**URL:** <https://discuss.elastic.co/t/what-is-wrong-with-my-search/200447>\
**Category:** Elasticsearch\
**Created:** [September 20, 2019, 2:40pm UTC](https://discuss.elastic.co/t/what-is-wrong-with-my-search/200447 "2019-09-20T14:40:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohammadamin\_gheibi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammadamin_gheibi/32/48327_2.png) [@Mohammadamin\_gheibi](https://discuss.elastic.co/u/Mohammadamin_gheibi)\
**Post date:** [September 20, 2019, 2:40pm UTC](https://discuss.elastic.co/t/what-is-wrong-with-my-search/200447/1 "2019-09-20T14:40:17Z")

</div>

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'
        ]);
    }
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 18, 2019, 2:40pm UTC](https://discuss.elastic.co/t/what-is-wrong-with-my-search/200447/2 "2019-10-18T14:40:21Z")

</div>

Closed on October 18, 2019, 2:40pm UTC

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