# How do I give split listings names generated from their attributes?

This code example extends the `Aero\Search\Elastic\Documents\ListingDocument`document to generate names for split listings from the attributes that the variant is made up of. You can [learn more about extending the listing document here](../../../developer-documentation/listings-and-search/4409603907857-how-do-i-extend-the-document-structure-for-listings-and-seach/index.md)

It’s important to note that you need to reindex for changes to the listing document to take effect. You can reindex using the php artisan `aero:search:reindex`command. [You can learn more about reindexing here](../../../developer-documentation/listings-and-search/4409596076561-how-do-i-re-index-listing-and-search-documents/index.md)

```
<?php

namespace Acme\MyModule;

use Aero\Common\Providers\ModuleServiceProvider;
use Aero\Search\Elastic\Documents\ListingDocument;

class ServiceProvider extends ModuleServiceProvider
{
   public function setup()
   {
       ListingDocument::add('search-result', function ($document) {
           if (! $name = $document->getData()['search-result']['name'] ?? null) return [];
           if (! $variant = $document->getModel()->variants->first()) return [];
           if (! $attributeGroups = $document->getModel()->product->attribute_groups_to_split_by ?? []) return [];

           $attributes = $variant->attributes->whereIn('attribute_group_id', $attributeGroups);

           if ($attributes->isEmpty()) return [];

           $attributeNames = $attributes->map->getTranslation('name', $document->getLanguage())->join(' ');

           return ['name' => "$attributeNames $name"];
       });
   }
}
```