本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用下列程序將資料從 Neptune 複製到 OpenSearch:
-
如果有問題欄位的對應已存在於 OpenSearch 中:
如果可以使用資料驗證規則,將資料安全地轉換為現有的對應,請將欄位儲存在 OpenSearch 中。
如果沒有,請捨棄相應的串流更新記錄。
-
如果有問題的欄位中沒有現有的對應,請尋找與 Neptune 中欄位資料類型對應的 OpenSearch 資料類型。
如果可以使用資料驗證規則,將欄位資料安全地轉換為 OpenSearch 資料類型,請將新對應和欄位資料儲存在 OpenSearch 中。
如果沒有,請捨棄相應的串流更新記錄。
這些值是根據對等的 OpenSearch 類型或現有的 OpenSearch 對應 (而非 Neptune 類型) 進行驗證。例如,"123"^^xsd:int
中 "123"
值的驗證是針對 long
類型而非 int
類型執行的。
雖然 Neptune 嘗試將所有資料複製到 OpenSearch,但有些情況,OpenSearch 中的資料類型與 Neptune 中的資料類型完全不同,在這類情況下,會略過記錄,而不是在 OpenSearch 中編製索引。
例如,在 Neptune 中,一個屬性可以具有不同類型的多個值,而在 OpenSearch 中,一個欄位必須跨索引具有相同的類型。
透過啟用偵錯日誌,您可以檢視從 Neptune 匯出至 OpenSearch 期間已捨棄哪些記錄。除錯日誌項目的範例如下:
Dropping Record : Data type not a valid Gremlin type <Record>
資料類型的驗證方式如下:
-
text
– Neptune 中的所有值都可以安全地對應到 OpenSearch 中的文字。 -
long
– OpenSearch 對應類型很長時,適用 Neptune 資料類型的下列規則 (在以下範例中,假設"testLong"
具有long
對應類型):-
boolean
– 無效、無法轉換,並會捨棄對應的串流更新記錄。無效的 Gremlin 範例如下:
"testLong" : true. "testLong" : false.
無效的 SPARQL 範例如下:
":testLong" : "true"^^xsd:boolean ":testLong" : "false"^^xsd:boolean
-
datetime
– 無效、無法轉換,並會捨棄對應的串流更新記錄。無效的 Gremlin 範例如下:
":testLong" : datetime('2018-11-04T00:00:00').
無效的 SPARQL 範例如下:
":testLong" : "2016-01-01"^^xsd:date
-
float
、double
、或decimal
– 如果 Neptune 中的值是可以容納 64 位元的整數,則該值有效且會長時間儲存在 OpenSearch 中,但如果它具有小數部分,或是NaN
或INF
,或是大於 9,223,372,036,854,775,807 或小於 -9,223,372,036,854,775,808,則它是無效的,且對應的串流更新記錄會遭到捨棄。有效的 Gremlin 範例如下:
"testLong" : 145.0. ":testLong" : 123 ":testLong" : -9223372036854775807
有效的 SPARQL 範例如下:
":testLong" : "145.0"^^xsd:float ":testLong" : 145.0 ":testLong" : "145.0"^^xsd:double ":testLong" : "145.0"^^xsd:decimal ":testLong" : "-9223372036854775807"
無效的 Gremlin 範例如下:
"testLong" : 123.45 ":testLong" : 9223372036854775900
無效的 SPARQL 範例如下:
":testLong" : 123.45 ":testLong" : 9223372036854775900 ":testLong" : "123.45"^^xsd:float ":testLong" : "123.45"^^xsd:double ":testLong" : "123.45"^^xsd:decimal
-
string
– 如果 Neptune 中的值是可以包含在 64 位元整數中的整數的字串表示法,則它是有效的,且會轉換為 OpenSearch 中的long
。對於 Elasticseearchlong
對應,任何其他字串值都是無效的,且相應的串流更新記錄會遭到捨棄。有效的 Gremlin 範例如下:
"testLong" : "123". ":testLong" : "145.0" ":testLong" : "-9223372036854775807"
有效的 SPARQL 範例如下:
":testLong" : "145.0"^^xsd:string ":testLong" : "-9223372036854775807"^^xsd:string
無效的 Gremlin 範例如下:
"testLong" : "123.45" ":testLong" : "9223372036854775900" ":testLong" : "abc"
無效的 SPARQL 範例如下:
":testLong" : "123.45"^^xsd:string ":testLong" : "abc" ":testLong" : "9223372036854775900"^^xsd:string
-
-
double
– 如果 OpenSearch 對應類型為double
,則會套用下列規則 (此處假設「testDouble」欄位在 OpenSearch 中具有double
對應):-
boolean
– 無效、無法轉換,並會捨棄對應的串流更新記錄。無效的 Gremlin 範例如下:
"testDouble" : true. "testDouble" : false.
無效的 SPARQL 範例如下:
":testDouble" : "true"^^xsd:boolean ":testDouble" : "false"^^xsd:boolean
-
datetime
– 無效、無法轉換,並會捨棄對應的串流更新記錄。無效的 Gremlin 範例如下:
":testDouble" : datetime('2018-11-04T00:00:00').
無效的 SPARQL 範例如下:
":testDouble" : "2016-01-01"^^xsd:date
-
浮點
NaN
或INF
– 如果 SPARQL 中的值是浮點NaN
或INF
,則它是無效的,且對應的串流更新記錄會遭到捨棄。無效的 SPARQL 範例如下:
" :testDouble" : "NaN"^^xsd:float ":testDouble" : "NaN"^^double ":testDouble" : "INF"^^double ":testDouble" : "-INF"^^double
-
數字或數值字串 – 如果 Neptune 中的值是任何其他數字,或是可以安全地表示為
double
之數字的數值字串表示法,則它是有效的,且會在 OpenSearch 中轉換為double
。對於 OpenSearchdouble
對應,任何其他字串值都是無效的,且相應的串流更新記錄會遭到捨棄。有效的 Gremlin 範例如下:
"testDouble" : 123 ":testDouble" : "123" ":testDouble" : 145.67 ":testDouble" : "145.67"
有效的 SPARQL 範例如下:
":testDouble" : 123.45 ":testDouble" : 145.0 ":testDouble" : "123.45"^^xsd:float ":testDouble" : "123.45"^^xsd:double ":testDouble" : "123.45"^^xsd:decimal ":testDouble" : "123.45"^^xsd:string
無效的 Gremlin 範例如下:
":testDouble" : "abc"
無效的 SPARQL 範例如下:
":testDouble" : "abc"
-
-
date
– 如果 OpenSearch 對應類型為date
,Neptunedate
和dateTime
值都是有效的,任何可以成功剖析為dateTime
格式的字串值也一樣有效。Gremlin 或 SPARQL 中的有效範例如下:
Date(2016-01-01) "2016-01-01" " 2003-09-25T10:49:41" "2003-09-25T10:49" "2003-09-25T10" "20030925T104941-0300" "20030925T104941" "2003-Sep-25" " Sep-25-2003" "2003.Sep.25" "2003/09/25" "2003 Sep 25" " Wed, July 10, '96" "Tuesday, April 12, 1952 AD 3:30:42pm PST" "123" "-123" "0" "-0" "123.00" "-123.00"
無效的範例如下:
123.45 True "abc"