0

我只是試圖將我的mongodb與ElasticSearch同步。我已經完成了與河流的同步,並且河已經工作了。但ES不會顯示所有字段,只顯示 「_source」 的對象 「_TS」 字段:Elasticsearch:已經重新映射,但它仍然不會顯示所有字段

請求: GET本地主機:9200 /測試/命令/ _search 響應:

{ 
    "took": 11, 
    "timed_out": false, 
    "_shards": { 
     "total": 5, 
     "successful": 5, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 137, 
     "max_score": 1, 
     "hits": [ 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58a3251f761f35a107724add", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58a340467f39c50f3a54c614", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b8ec806f34179d7c7b2431", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b8eff56f3417670f7b244a", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b8f0af6f3417fb207b244c", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b8f19a6f341761337b23da", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b9320c6f3417bc1c7b23c7", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b9339f6f341777237b23c6", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b934ab6f341778237b23c7", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      }, 
      { 
       "_index": "test", 
       "_type": "orders", 
       "_id": "58b96ef76f34174a4b7b23c8", 
       "_score": 1, 
       "_source": { 
        "_ts": 6438761296509796000 
       } 
      } 
     ] 
    } 
} 

我已經做了重映射,它顯示了更新的映射。看到這一點: 要求: GET本地主機:9200 /測試/命令/ _mapping 響應:

{ 
    "test": { 
     "mappings": { 
      "orders": { 
       "properties": { 
        "_ts": { 
         "type": "long" 
        }, 
        "activeDate": { 
         "type": "text" 
        }, 
        "awbNumber": { 
         "type": "text" 
        }, 
        "batchID": { 
         "type": "text" 
        }, 
        "consignee": { 
         "properties": { 
          "id": { 
           "type": "text" 
          }, 
          "name": { 
           "type": "text" 
          }, 
          "phoneNumber": { 
           "type": "text" 
          } 
         } 
        }, 
        "consigner": { 
         "properties": { 
          "id": { 
           "type": "text" 
          }, 
          "name": { 
           "type": "text" 
          }, 
          "phoneNumber": { 
           "type": "text" 
          } 
         } 
        }, 
        "courier": { 
         "properties": { 
          "actualRate": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "id": { 
           "type": "integer" 
          }, 
          "max_day": { 
           "type": "integer" 
          }, 
          "min_day": { 
           "type": "integer" 
          }, 
          "name": { 
           "type": "text" 
          }, 
          "rate": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "rate_id": { 
           "type": "integer" 
          }, 
          "rate_name": { 
           "type": "text" 
          }, 
          "shipmentType": { 
           "type": "integer" 
          } 
         } 
        }, 
        "creationDate": { 
         "type": "text" 
        }, 
        "destination": { 
         "properties": { 
          "address": { 
           "type": "text" 
          }, 
          "cityID": { 
           "type": "integer" 
          }, 
          "cityName": { 
           "type": "text" 
          }, 
          "id": { 
           "type": "integer" 
          }, 
          "provinceID": { 
           "type": "integer" 
          }, 
          "provinceName": { 
           "type": "text" 
          } 
         } 
        }, 
        "driver": { 
         "properties": { 
          "feedback": { 
           "properties": { 
            "comment": { 
             "type": "text" 
            }, 
            "score": { 
             "type": "long" 
            } 
           } 
          }, 
          "id": { 
           "type": "long" 
          }, 
          "isPaymentCollected": { 
           "type": "integer" 
          }, 
          "name": { 
           "type": "text" 
          }, 
          "phoneNumber": { 
           "type": "text" 
          }, 
          "vehicleNumber": { 
           "type": "text" 
          }, 
          "vehicleType": { 
           "type": "text" 
          } 
         } 
        }, 
        "externalID": { 
         "type": "text" 
        }, 
        "groupID": { 
         "type": "integer" 
        }, 
        "id": { 
         "type": "text" 
        }, 
        "isActive": { 
         "type": "long" 
        }, 
        "isAutoTrack": { 
         "type": "integer" 
        }, 
        "isCustomAWB": { 
         "type": "integer" 
        }, 
        "isEscrow": { 
         "type": "integer" 
        }, 
        "isLabelPrinted": { 
         "type": "integer" 
        }, 
        "lastUpdatedDate": { 
         "type": "text" 
        }, 
        "origin": { 
         "properties": { 
          "address": { 
           "type": "text" 
          }, 
          "cityID": { 
           "type": "integer" 
          }, 
          "cityName": { 
           "type": "text" 
          }, 
          "id": { 
           "type": "integer" 
          }, 
          "provinceID": { 
           "type": "integer" 
          }, 
          "provinceName": { 
           "type": "text" 
          } 
         } 
        }, 
        "package": { 
         "properties": { 
          "content": { 
           "type": "text" 
          }, 
          "contents": { 
           "type": "integer" 
          }, 
          "cubicalWeight": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "dimension": { 
           "properties": { 
            "height": { 
             "properties": { 
              "UoM": { 
               "type": "text" 
              }, 
              "value": { 
               "type": "integer" 
              } 
             } 
            }, 
            "length": { 
             "properties": { 
              "UoM": { 
               "type": "text" 
              }, 
              "value": { 
               "type": "integer" 
              } 
             } 
            }, 
            "width": { 
             "properties": { 
              "UoM": { 
               "type": "text" 
              }, 
              "value": { 
               "type": "integer" 
              } 
             } 
            } 
           } 
          }, 
          "fragile": { 
           "type": "integer" 
          }, 
          "isConfirmed": { 
           "type": "integer" 
          }, 
          "itemName": { 
           "type": "text" 
          }, 
          "itemSubtype": { 
           "type": "integer" 
          }, 
          "itemType": { 
           "type": "integer" 
          }, 
          "pictureURL": { 
           "type": "text" 
          }, 
          "price": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "type": { 
           "type": "integer" 
          }, 
          "weight": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          } 
         } 
        }, 
        "paymentType": { 
         "type": "text" 
        }, 
        "pickUpTime": { 
         "type": "text" 
        }, 
        "rates": { 
         "properties": { 
          "actualInsurance": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "long" 
            } 
           } 
          }, 
          "actualShipment": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "escrowCost": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "fulfillmentCost": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "insurance": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "long" 
            } 
           } 
          }, 
          "itemPrice": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "liability": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          }, 
          "shipment": { 
           "properties": { 
            "UoM": { 
             "type": "text" 
            }, 
            "value": { 
             "type": "integer" 
            } 
           } 
          } 
         } 
        }, 
        "readyTime": { 
         "type": "text" 
        }, 
        "shipmentStatus": { 
         "properties": { 
          "description": { 
           "type": "text" 
          }, 
          "name": { 
           "type": "text" 
          }, 
          "statusCode": { 
           "type": "integer" 
          }, 
          "updateDate": { 
           "type": "text" 
          }, 
          "updatedBy": { 
           "type": "text" 
          } 
         } 
        }, 
        "source": { 
         "type": "text" 
        }, 
        "specialID": { 
         "type": "text" 
        }, 
        "stickerNumber": { 
         "type": "text" 
        }, 
        "useInsurance": { 
         "type": "integer" 
        } 
       } 
      } 
     } 
    } 
} 

我期待我能得到整個領域(而不只是單一的 「_TS」 字段)「 _source「字段,它應該與我所映射的字段相同。

我試圖刪除索引並重新創建一個,仍然沒有工作。這種問題的任何線索。我真的很需要幫助,非常感謝。

回答

0

ElasticSearch具有創建字段的行爲。所以如果你這樣做

PUT document/index/1 
{ 
    "id" : "1", 
    "name" : "kashish", 
    "phoneNumber" : "9740683281" 
} 

這會自動爲您的索引創建字段。我所說明的是,如果由於某種原因明確定義了字段並不適合你,那麼可以清空索引(如果包含虛擬數據),然後把你的JSON放入其中,ES將自動拾取。

+0

你的意思是在創建索引後立即插入一個文檔?我試過了,但仍然沒有奏效。 –

+0

請勿創建文檔或索引。只需要放置請求,不需要創建任何文檔和索引它會自動選擇給定的json,並根據字段名稱爲您配置字段類型。希望能幫助到你。 –

+0

對不起,但我不明白。我沒有在ES上創建文檔,我在mongodb shell上創建了它,並自動同步到ES中。我不知道如何創建索引,但它會自動創建。你可以給我一些關於如何自動創建索引的例子。謝謝你@Kashish Verma –

相關問題