Question: In the Site, product URL is like this: `http://www.test.com/product-url-key`

But when I searching the product then some product URLs are showing like this:

```
http://www.test.com/catalog/product/view/id/2221/product-url-key

```

This is not for all products.

i want to url like this type `http://www.test.com/product-url-key.html`

Answer: 
You can try/use [Regenerate a Url](https://github.com/olegkoval/magento2-regenerate_url_rewrites) rewrites extension.

The extension allows you to regenerate a Url rewrites of products and categories.

1 > Run command to re-generate Url rewrites for all categories/products for all stores:

```
php bin/magento ok:urlrewrites:regenerate

```

2 > To regenerate Url rewrites for specific store view (e.g.: store view id is "1"):

```
php bin/magento ok:urlrewrites:regenerate 1

```
Try this

Marketing > url rewrite > new url rewirte

Request Path "product-url-key"

Target Path "catalog/product/view/id/2221"

Redirect Type "no" 

Save and flush cache

Or

Marketing > url rewrite

search with the "product-url-key" in Request path 
there you will get some idea.

Hope it might help