FOSElasticaBundle
FOSElasticaBundle copied to clipboard
Filter data by datetime
Hi!
How can i remove from indexing data that not published yet on symfony 4?(pubdate less than now) Nothing found in documentation
//fos_elastica.yaml
fos_elastica:
clients:
default: { host: 127.0.0.1, port: 9200 }
indexes:
app:
index_name: app
types:
articles:
properties:
id: { type : "integer"}
kz_title: ~
ru_title: ~
kz_active: { type : "boolean"}
ru_active: { type : "boolean"}
kz_pubdate: { type : "date"}
ru_pubdate: { type : "date"}
kz_fulltext: ~
ru_fulltext: ~
moduletype: ~
moduleid: ~
kz_meta_title: ~
ru_meta_title: ~
kz_meta_desc: ~
ru_meta_desc: ~
persistence:
driver: orm
model: App\Entity\Articles
provider: ~
finder: ~
You can try using the indexable_callback
On your entity, put a function like this:
public function shouldIndex()
{
return true; # do your date comparison here.
}
In the config:
fos_elastica:
indexes:
app:
types:
articles:
indexable_callback: 'shouldIndex'