Sorting by two fields (Date & Time)


(PennyWise83) #1

Hi,
I have an index with the following mapping:

{
    "mappings": {
        "testtype": {
            "properties": {
                "DATE": {
                    "format": "yyyy-MM-dd-HH.mm.ss",
                    "type": "date"
                },
                "TIME": {
                    "format": "HHmmss",
                    "type": "date"
                }
            }
        }
    }
}

I need to do a query_string ordered by DATE and TIME combined, so I've tried to make the request with the following query:

{
    "from": 0,
    "size": 50,
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "testField:testValue"
                    }
                }
            ]
        }
    },
    "sort": [
        {
            "DATE": {
                "order": "desc"
            }
        },
        {
            "TIME": {
                "order": "desc"
            }
        }
    ]
}

Unfortunately that doesn't seems to work, for example if i use pagination (i.e.: FROM=2) I get only the current result ordered. How can I sort the entire result?


(system) #2