2015-10-12 30 views
0

我試圖索引以下數據elasticsearch,Elasticsearch MapperParsingException

{ 
"_id": "5619578c1983757a72efef15", 
"aseg": {}, 
"cs": { 
    "source": "None", 
    "ss": "In Transit", 
    "sr": "Weight Captured", 
    "act": "+B", 
    "pid": "BAG21678106", 
    "st": "UD", 
    "dest": "Bharatpur_DC (Rajasthan)", 
    "u": "J", 
    "sl": "Jaipur_Hub (Rajasthan)", 
    "ud": "2015-10-12T14:59:44.270000", 
    "sd": "2015-10-12T14:59:44.270000" 
}, 

"nsl": [ 
    { 
     "dt": [ 
      2015, 
      10, 
      10 
     ], 
     "code": "X-PPONM" 
    }, 
    { 
     "dt": [ 
      2015, 
      10, 
      11 
     ], 
     "code": "X-UCI" 
    }, 
] 
} 

但作爲回報,我得到這個錯誤

MapperParsingException[failed to parse [cs.nsl]]; nested: ElasticsearchIllegalArgumentException[unknown property [dt]]; 

我檢查了映射,映射是正確的,NSL嵌套在CS dict與根級別的nsl有不同的映射。

  "cs": { 
      "properties": { 
       "act": { 
        "type": "string" 
       }, 
       "add": { 
        "type": "string" 
       }, 
       "asr": { 
        "type": "string" 
       }, 
       "bucket": { 
        "type": "string" 
       }, 
       "dest": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "dwbn": { 
        "type": "string" 
       }, 
       "lcld": { 
        "type": "string" 
       }, 
       "lat": { 
        "type": "string" 
       }, 
       "lon": { 
        "type": "string" 
       }, 
       "loc": { 
        "type": "double" 
       }, 
       "nsl": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "ntd": { 
        "type": "date", 
        "format": "dateOptionalTime" 
       }, 
       "pbs": { 
        "type": "string" 
       }, 
       "pid": { 
        "type": "string" 
       }, 
       "pupid": { 
        "type": "string" 
       }, 
       "sd": { 
        "type": "date", 
        "format": "dateOptionalTime" 
       }, 
       "sl": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "source": { 
        "properties": { 
         "source": { 
          "type": "string" 
         }, 
         "source_id": { 
          "type": "string" 
         }, 
         "source_type": { 
          "type": "string" 
         } 
        } 
       }, 
       "sr": { 
        "type": "string" 
       }, 
       "ss": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "st": { 
        "type": "string" 
       }, 
       "u": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "ud": { 
        "type": "date", 
        "format": "dateOptionalTime" 
       }, 
       "vh": { 
        "type": "string" 
       } 
      } 
     }, 

,並在根級映射NSL是遵循

 "nsl": { 
      "properties" : { 
       "code" : { 
         "type" : "string", 
         "index": "not_analyzed" 
        }, 
       "dt" : { 
        "type" : "string", 
        "index": "not_analyzed" 
       } 
      } 
     }, 

發生這種情況只有幾個記錄,其餘全部都是同步的罰款。 負載沒有任何變化。 進一步nsl是CS內部的一個稀疏密鑰。

回答

2

在映射NSL是如下 -

  "nsl": { 
       "type": "string", 
       "index": "not_analyzed" 
      }, 

按照映射,Elasticsearch期待一個具體的字符串值NSL領域,但它的您提供的文檔中的對象數組。 Elasticsearch一旦有了映射,其確定。您無法將對象數據插入到字符串字段中。

+0

因此,nsl有兩個鍵,一個在郵件文檔中,映射如上所述,一個nsl鍵嵌套在cs中。它具有不同的映射,如上所示。 –

+0

是的,這是問題所在。 ES將假定它首先看到的任何文檔的映射並拒絕另一個文檔。 –

+0

好吧,可以是一種情況,因此我試着將默認值傳遞給doc(cs [nsl] ='XXX'),但仍然無效。進一步我猜測nsl在rool級別的映射不應該與嵌套在cs中的nsl的映射衝突。 –

1

我想你的文檔,而無需預先設置,任何映射如下:

{ 
    "aseg": {}, 
    "cs": { 
     "source": "None", 
     "ss": "In Transit", 
     "sr": "Weight Captured", 
     "act": "+B", 
     "pid": "BAG21678106", 
     "st": "UD", 
     "dest": "Bharatpur_DC (Rajasthan)", 
     "u": "J", 
     "nsl":"foo", 
     "sl": "Jaipur_Hub (Rajasthan)", 
     "ud": "2015-10-12T14:59:44.270000", 
     "sd": "2015-10-12T14:59:44.270000" 
    }, 
    "nsl": [ 
     { 
      "dt": [ 
       2015, 
       10, 
       10 
      ], 
      "code": "X-PPONM" 
     }, 
     { 
      "dt": [ 
       2015, 
       10, 
       11 
      ], 
      "code": "X-UCI" 
     } 
    ] 
} 

而ES創建的映射如下:

"nsl": { 
    "properties": { 
     "dt": { 
      "type": "long" 
     }, 
     "code": { 
      "type": "string" 
     } 
    } 
} 

正如你可以看到ES把「DT」鍵入爲「long」,這是日期類型的內部表示形式。那麼,可能需要改變這種類型?

此外,沒有看到成功的文件,它很難猜測,但我相信這些文件沒有「dt」字段值。

當然,你可以自由地將「not_analyzed」,因爲你認爲適合任何領域。

相關問題