this query works and shows results from 1771-01-07:
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
"query": {
"range" : {
"time_from" : {
"gte" : "1771",
"lt" : "1772",
"format" : "yyyy"
}
}
}'
but when I add MM-dd to the format, I get no results:
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d' "query": {
"range" : {
"time_from" : {
"gte" : "1771-01-01",
"lt" : "1772-12-10",
"format" : "yyyy-MM-dd"
}
}
}'
same (no results) when I try this:
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
"query": {
"range" : {
"time_from" : {
"gte" : "1771-01",
"lt" : "1772-12",
"format" : "yyyy-MM"
}
}
}'
This one however shows the 1771-01-07 result as expected (and it shows the date format seems to work but does not explain why searching from 1771-01-01 shows nothing):
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
"query": {
"range" : {
"time_from" : {
"gte" : "1770-01",
"lt" : "1772-12",
"format" : "yyyy-MM"
}
}
}'
Edited question, added the following:
Model in Django:
class Text(models.Model):
time_from = models.DateField(null=True, blank=True)
def indexing(self):
obj = TextIndexingNew(
meta={'id': self.id},
time_from=self.time_from,
)
obj.save(index='text-index')
return obj.to_dict(include_meta=True)
DocType:
class TextIndexingNew(DocType):
time_from = Text(fielddata=True)
Indexing method:
def bulk_indexing():
TextIndexingNew.init(index='text-index')
es = Elasticsearch()
bulk(client=es, actions=(b.indexing()
for b in models.Text.objects.all().iterator()))
Any idea what is going on?