<commit_before>Search Bundle
=============


Installation
------------

1. First install the bundle via composer: 

    ```bash
    composer require becklyn/search-bundle
    ```
    
2. Load the bundle in your `AppKernel`


Configuration
-------------

### Entity annotations


#### Marking a class for indexing

For regular entities just mark the class with the annotation and implement the `SearchableEntityInterface` interface:

```php
use Becklyn\SearchBundle\Entity\SearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;

/**
 * @Search\Item()
 */
class SomeEntity implements SearchableEntityInterface
{
}
```

For localized entities, mark the class and implement the `LocalizedSearchableEntityInterface` interface:

```php
use Becklyn\SearchBundle\Entity\LocalizedSearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;

/**
 * @Search\Item(
 *   index="custom-index-name",
 *   loader="some.service:method",
 * )
 */
class LocalizedSomeEntity implements LocalizedSearchableEntityInterface
{
    /**
     * @return LanguageInterface
     */
    public function getLanguage ()
    {
        
    }
}
```

#### `@Search\Item()` annotation

```php
/**
 * @Search\Item(
 *   index="custom-index-name",
 *   loader="some.service:method",
 * )
 */
```

| Property | Description |
| -------- | ----------- |
| `index`  | The name of the index. If none is given, the name is automatically generated from the FQCN of the class. |
| `loader` | The custom entity loader. Please refer to the chapter about entity loaders to learn more. |


### Marking a field / getter for indexing

```php
use Becklyn\SearchBundle\Mapping as Search;

class SomeEntity
{
    /**
     * @Search\Field()
     */<commit_msg>Add note about language interface<commit_after>Search Bundle
=============


Installation
------------

1. First install the bundle via composer: 

    ```bash
    composer require becklyn/search-bundle
    ```
    
2. Load the bundle in your `AppKernel`


Configuration
-------------

### Entity annotations


#### Marking a class for indexing

For regular entities just mark the class with the annotation and implement the `SearchableEntityInterface` interface:

```php
use Becklyn\SearchBundle\Entity\SearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;

/**
 * @Search\Item()
 */
class SomeEntity implements SearchableEntityInterface
{
}
```

For localized entities, mark the class and implement the `LocalizedSearchableEntityInterface` interface:

```php
use Becklyn\Interfaces\LanguageInterface;
use Becklyn\SearchBundle\Entity\LocalizedSearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;

/**
 * @Search\Item(
 *   index="custom-index-name",
 *   loader="some.service:method",
 * )
 */
class LocalizedSomeEntity implements LocalizedSearchableEntityInterface
{
    /**
     * @return LanguageInterface
     */
    public function getLanguage ()
    {
        
    }
}
```

Note: you will need the `LanguageInterface` from the [`becklyn/interfaces`](https://github.com/Becklyn/Interfaces) package.

#### `@Search\Item()` annotation

```php
/**
 * @Search\Item(
 *   index="custom-index-name",
 *   loader="some.service:method",
 * )
 */
```

| Property | Description |
| -------- | ----------- |
| `index`  | The name of the index. If none is given, the name is automatically generated from the FQCN of the class. |
| `loader` | The custom entity loader. Please refer to the chapter about entity loaders to learn more. |


### Marking a field / getter for indexing

```php
use Becklyn\SearchBundle\Mapping as Search;

class SomeEntity
{
    /**
     * @Search\Field()
     */
{'fraction_non_alphanumeric': 0.1403893611187277, 'fraction_numerical': 0.0010967918837400603, 'mean_word_length': 3.443361753958587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2571998', 'n_tokens_mistral': 1045, 'n_tokens_neox': 997, 'n_words': 306}