{"issue":{"milestone":null,"user":{"id":718437,"login":"jappievw","url":"https://api.github.com/users/jappievw","avatar_url":"https://secure.gravatar.com/avatar/14931a813378180316d17d2a71e9e2fb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"14931a813378180316d17d2a71e9e2fb"},"title":"Allow filters to be cacheable","created_at":"2011-08-25T08:32:55Z","updated_at":"2011-12-19T10:56:47Z","labels":[],"state":"open","id":1481093,"html_url":"https://github.com/ruflin/Elastica/issues/76","closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"Filters can become cacheable by setting the _cache parameter to true.\r\nSome filters require a different format for the filter in order to supply the _cache attribute. Shay just updated the documentation about the longer format for the [and-filter](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html). Copied below as an example:\r\n\r\n**Short notation**\r\n\r\n```javascript\r\n{\r\n    \"filtered\" : {\r\n        \"query\" : {\r\n            \"term\" : { \"name.first\" : \"shay\" }\r\n        },\r\n        \"filter\" : {\r\n            \"and\" : [\r\n                {\r\n                    \"range\" : { \r\n                        \"postDate\" : { \r\n                            \"from\" : \"2010-03-01\",\r\n                            \"to\" : \"2010-04-01\"\r\n                        }\r\n                    }\r\n                },\r\n                {\r\n                    \"prefix\" : { \"name.second\" : \"ba\" }\r\n                }\r\n            ]\r\n        }\r\n    }\r\n}\r\n```\r\n**Long notation**\r\n\r\n```javascript\r\n{\r\n    \"filtered\" : {\r\n        \"query\" : {\r\n            \"term\" : { \"name.first\" : \"shay\" }\r\n        },\r\n        \"filter\" : {\r\n            \"and\" : \r\n                \"filters\": [\r\n                    {\r\n                        \"range\" : { \r\n                            \"postDate\" : { \r\n                                \"from\" : \"2010-03-01\",\r\n                                \"to\" : \"2010-04-01\"\r\n                            }\r\n                        }\r\n                    },\r\n                    {\r\n                        \"prefix\" : { \"name.second\" : \"ba\" }\r\n                    }\r\n                ],\r\n                \"_cache\" : true\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nShay advised to use the longer format for use in libraries on the mailing list.\r\n\r\n**Proposed changes**\r\n1. Use the long notation for all filters.\r\n2. Rename the current setCached function to setCache(bool).\r\n3. Only implement the setCache on those filters which support caching.","number":76,"url":"https://api.github.com/repos/ruflin/Elastica/issues/76","comments":3,"assignee":null},"comment":{"user":{"id":244900,"login":"ruflin","url":"https://api.github.com/users/ruflin","avatar_url":"https://secure.gravatar.com/avatar/1dba3a98bab675f9e075d1719d2ddf72?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"1dba3a98bab675f9e075d1719d2ddf72"},"created_at":"2011-12-19T10:56:47Z","updated_at":"2011-12-19T10:56:47Z","id":3201790,"body":"Any updates?","url":"https://api.github.com/repos/ruflin/Elastica/issues/comments/3201790"},"action":"created"}