floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 73 forks source link

DateTime field not indexed #123

Closed Martin1982 closed 8 years ago

Martin1982 commented 8 years ago

Looking into the bundle while running a solr:index:populate certain entities do not get indexed. While doing some debugging I ended up with a \DateTime object which was trying to be used as an entity/document.

    /**
     * @var \DateTime
     *
     * @Solr\Field(type="date")
     *
     * @ORM\Column(name="timestamp_start", type="datetime", nullable=true)
     */
    private $timestampStart;

So because it is not a string representation it's skipping the indexing for the entity with this property entirely. When I remove this field definition (only text-type fields are left then), the indexing runs smoothly.

floriansemm commented 8 years ago

it is now possible to specify the getter property with parameters. In your case:

    /**
     * @var \DateTime
     *
     * @Solr\Field(type="datetime", getter="format('d.m.Y')")
     *
     * @ORM\Column(name="timestamp_start", type="datetime", nullable=true)
     */
    private $timestampStart;