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) */;
}
}
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\IndexIfmethod annotation. When instance ofFoois about to being indexed, we're checking for the existence of the@Search\IndexIfannotation. When the underlying method returnstruethe entity is indexed, otherwise it's skipped.Like this: