Skip to content

Add IndexIf annotation to conditionally index an entity #8

Description

@keichinger

In real world applications it's not uncommon to conditionally index entities. To automate the entire process a good solution to this scenario would be to introduce a new @Search\IndexIf method annotation. When instance of Foo is about to being indexed, we're checking for the existence of the @Search\IndexIf annotation. When the underlying method returns true the entity is indexed, otherwise it's skipped.

Like this:

use Becklyn\SearchBundle\Mapping as Search;
// ...

/**
 * @Search\Item()
 */
class Foo implements SearchableEntityInterface
{
    // ...

    /**
     * @Search\IndexIf()
     */
    public function getWhetherThisEntityShouldBeIndexedOrNot () : bool
    {
        return /* condition(s) */;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions