Joda date time

{
  "from": 0,
  "size": 10000,
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {
            "boost": 1
          }
        },
        {
          "bool": {
            "must": [
              {
                "script": {
                  "script": {
                    "source": "def v1,id; if( ((DateTime.now().millis-doc[108].value)/(1000.0 * 3600 * 24 * 30.5)) < 9 && doc[2515].value == 'yes') {v1 = 1} else {v1 = 0} if(doc['ctrycode'].value == 1 && v1 ==1 && doc[61].value >= 5) {id = 1} else if (v1 == 1 && doc['ctrycode'].value != 1) {id = 1} else {id = 0} id== 1",
                    "lang": "painless"
                  },
                  "boost": 1
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "msid"
    ],
    "excludes": []
  }
}

DateTime (Joda DateTime)is not working and throwing error  


"caused_by": {
            "type": "script_exception",
            "reason": "compile error",
            "script_stack": [
                "def v1,id; if( ((DateTime.now().millis-doc ...",
                "                 ^---- HERE"
            ],
            "script": "def v1,id; if( ((DateTime.now().millis-doc[108].value)/(1000.0 * 3600 * 24 * 30.5)) < 9 && doc[2515].value == 'yes') {v1 = 1} else {v1 = 0} if(doc['ctrycode'].value == 1 && v1 ==1 && doc[61].value >= 5) {id = 1} else if (v1 == 1 && doc['ctrycode'].value != 1) {id = 1} else {id = 0} id== 1",
            "lang": "painless",
            "caused_by": {
                "type": "illegal_argument_exception",
                "reason": "Variable [DateTime] is not defined."
            }
        }
    },

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Probably you need to use the fully qualified name for DateTime class (including its package name). But that's a guess.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.