Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

Sorting in Elasticsearch not working on different indexes

Below is my query dsl. Index number is unique integer. I want to sort the fetch datas. The query below sorts of documents in same index, but not sorting via different indexes. I mean if i select the date of today, it sorts all documents in today but not all days.

   "size": 1,
    "sort": [
        {
            "index_number.keyword": {
                "order": "asc"
            }
        },
        {
            "_score": {
                "order": "asc"
            }
        }
    ],
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "city_name": {
                            "value": "maribor"
                        }
                    }
                },
                {
                    "term": {
                        "username": {
                            "value": "marko"
                        }
                    }
                },
                {
                    "range": {
                        "@timestamp": {
                            "gte": "2017-02-05T00:00:00.000Z",
                            "lt": "2018-02-05T23:59:59.000Z"
                        }
                    }
                }

            ]
        }
    }

When I delete "_score" on sorting mapping, it gives me

for doc in eval(json.dumps(resp['hits']['hits'])):
  File "<string>", line 1, in <module>
NameError: name 'null' is not defined

Thanks for answering


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...