我已經建立了從表中的SQL服務器Elasticsearch返回舊的SQL結果
{
"type":"jdbc",
"jdbc":
{
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url":"jdbc:sqlserver://[my_ip];databaseName=mega",
"user":"sa","password":"******",
"sql":"SELECT [OrderID],[CustomerName],[UserFullName],[Status] FROM [Orders_Table]",
"poll":"5s",
"index": "mega",
"type": "orders_search",
"schedule" : "0 0-59 0-23 ? * *"
}
}
中提取數據的索引的問題是,我收到unrelevant查詢結果。
例如:]是應僅作爲包含在一次數據庫返回的行密鑰。
{
"from" : 0, "size" : 5,
"query": {
"multi_match": {
"query": "5220668",
"fields": [ "_all" ]
}
}
}
結果:事情是錯誤的結果。 我期待在數據庫中看到只有一個命中。而不是查詢檢索該行的全壽命週期狀態
{
"took": 12,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 4,
"max_score": null,
"hits": [
{
"_index": "mega",
"_type": "handledorders_search",
"_id": "AU3OlBkh6JN7xIrOkzjm",
"_score": null,
"_source": {
"Status": "NEW",
"Date": "2015-06-07T03:00:12.110Z",
"UserFullName": "my name",
"CustomerName": "cust name",
"OrderID": 5220668
},
"sort": [
1433646012110
]
},
{
"_index": "mega",
"_type": "handledorders_search",
"_id": "AU3Ok0E-6JN7xIrOkvpF",
"_score": null,
"_source": {
"Status": "NEW",
"Date": "2015-06-07T03:00:12.110Z",
"UserFullName": "my name",
"CustomerName": "cust name",
"OrderID": 5220668
},
"sort": [
1433646012110
]
},
{
"_index": "mega",
"_type": "handledorders_search",
"_id": "AU3Ole0-6JN7xIrOk7Yo",
"_score": null,
"_source": {
"Status": "FIX",
"Date": "2015-06-07T03:00:12.110Z",
"UserFullName": "my name",
"CustomerName": "cust name",
"OrderID": 5220668
},
"sort": [
1433646012110
]
},
{
"_index": "mega",
"_type": "handledorders_search",
"_id": "AU3OlQL86JN7xIrOk3eH",
"_score": null,
"_source": {
"Status": "CLOSE",
"Date": "2015-06-07T03:00:12.110Z",
"UserFullName": "my name",
"CustomerName": "cust name",
"ExternalOrderID": 5220668
},
"sort": [
1433646012110
]
}
]
}
}
不同的狀態爲同一訂單ID保持這種命名法是很重要的 。那有什麼問題? –
看來你的訂單有兩次相同的狀態,你確定查詢只執行一次嗎?在數據中,OrderId也成爲最後一條記錄中的ExternalOrderId。我會先檢查數據並檢查查詢執行的次數。 –