Using Lucene Query Syntax


(Flavio Tom) #1

Currently i storage dates in strict_date_time_no_millis ( yyyy-MM-dd'T'HH:mm:ssZZ eg.: 2018-09-27T14:13:41-0300).

When i try use Lucene Query to find data a error occurs:

{
	"from": 0,
	"size": 30,
	"query": {
		"query_string": {
			"query": "creation:'2018-09-27T14:13:41-0300'"
		}
	}
}

Error:

{
	"error": {
		"root_cause": [
			{
				"type": "query_shard_exception",
				"reason": "Failed to parse query [creation:'2018-09-27T14:13:41-0300']",
				"index_uuid": "KvCPLylCS6KCszKqgEtVBg",
				"index": "tickets"
			}
		],
...
}

What is wrong? I tried search using only the date and date/hour, and the same errors occurs (eg.: '2018-09-27', '2018-09-27 14:13:14')

By the way, is possible search just for the day and exclude the hour? Like: 'creation:>='2018-09-27''

Another question, i can use script_fields and scripts created with Painless to search data with Lucene?


(Flavio Tom) #2

Solved, just replace : to \\:

{
	"from": 0,
	"size": 30,
	"query": {
		"query_string": {
			"query": "creation:2018-09-27T14\\:13\\:41-0300"
		}
	}
}

(system) #3

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