Hello, 

In our project, we use elaticsearch to index files. For these files, we 
want to store : 

   1. Text data like title, description, ...
   2. Date data

Each document don't have necessary a date, and a document can have multiple 
date data (it depends on user configuration).

I made some test regarding the date data in order to have a concrete 
example and to know how we can build a query with a date parameter (I've 
attached the CURL requests I did) . 

I've added a date like "post_date" = '2014-06-12" (with a string) and I was 
able to search with { "post_date" : {"gte": "now-1d" } }.

Is it the standard behaviour for date data (add it as string and be able to 
search it with date selector) ?

Thanks a lot, 

Yannis ROSSETTO.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/d4225e30-af13-4b63-84e9-79257c6656b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
localhost:9200/testdocdate -d '{ "settings": {
        "index.number_of_shards": 1,
        "index.number_of_replicas": 0
    },
    "mappings": {
        "test": {
            "_timestamp": {
                "enabled": "true"
            },
            "properties": {
                "post_date" : {
                    "type": "date",
                    "format": "yyyy-MM-dd"
                }
            }
        }
    }
}'

curl -XPUT 'http://localhost:9200/testdocdate/test/1' -d '{
    "user" : "test",
    "post_date" : "2014-06-12",
    "message" : "trying out Elasticsearch"
}'

curl -XGET 'http://localhost:9200/testdocdate/_search?pretty' -d '{ 
     "query": { 
          "filtered": { 
              "query": {
                  "match_all": {}
              },
              "filter": {
                  "range": { 
                      "post_date" : {
                          "gte": "now-1d" 
                      } 
                  }
              } 
          } 
     } 
}'

Reply via email to