2014-03-03 48 views
0

我用PY-elasticsearch散裝功能如:手柄不確定的領域Elasticsearch

//loop 
    action = { 
    "_index": "venue", 
    "_type": "venue", 
    "_id": tempid, 
    "_source": item 
    } 
    actions.append(action) 

helpers.bulk(es, actions) 
在我的結果

但是我看到:

"hits": [ 
    { 
     "_index": "venue", 
     "_type": "venue", 
     "_id": "52e6d42fc36b4408dbe907d1", 
     "_score": 4.0977435, 
     "_source": { 
      "city": "Athens", 
      "name": "Half Note Jazz Club", 
      "address": "17 Trivonianou Street", 
     } 
    }, 
    { 
     "_index": "venue", 
     "_type": "venue", 
     "_id": "530391abc36b442b25e8a514", 
     "_score": 4.023251, 
     "_source": { 
      "city": null, <--- this 
      "name": "life Jazz Cafe-bar",    
      "address": null <---- and this 
     } 
    } 
    ] 

假設,當我 「散裝飼料」 ES我有沒有定義城市和地址,是否有辦法在ES中刪除這些字段?

或者ES會始終創建一個空值,即使這個文件沒有這個字段? 這是ES架構還是應該在我的代碼中搜索錯誤?

更新

我完全映射如下:

<type>: { 
    mappings: { 
     <index>: { 
      properties: {     
       address: { 
        type: "string" 
       }, 
       city: { 
        type: "string" 
       }, 
       country: { 
        type: "string" 
       }, 
       location: { 
        properties: { 
         coordinates: { 
          type: "geo_point" 
         }, 
         type: { 
          type: "string" 
         } 
        } 
       }, 
       name: { 
        type: "string" 
       } 
      } 
     } 
    } 
} 

回答

0

我不熟悉的PY-elasticsearch,但無論是bug是在圖書館或在你的代碼爲_source字段總是返回到首先發送給elasticsearch的內容。

+0

謝謝我開始這個[issue](https://github.com/elasticsearch/elasticsearch- py/issues/57)但是請重新檢查我的代碼,它應該是我自己的錯。 – Diolor

0

您的映射中的null_value將爲「null」。所以如果你想省略一個字段,這個字段在文檔中沒有被索引,請不要在映射中指定null_value null_value

+0

我同意你的意見。但是我沒有指定null_value。 – Diolor