2016-11-09 6 views
0

저는 ES가 매우 새롭습니다. 학습 세트로 https://github.com/dariusk/corpora/blob/master/data/humans/us_presidents.json을 사용하고 있습니다.문서 업데이트시 ElasticSearch/Kibana 필드

은 우선은 내가 키바에 개발 도구 탭이 입력 :

POST /presidents/president/1 
{ 
     "website":"", 
     "startdate":"2009-01-20", 
     "role_type_label":"President", 
     "enddate":"2013-01-20", 
     "description":"President", 
     "district":null, 
     "phone":null, 
     "title":"President", 
     "congress_numbers":[ 
      111, 
      112, 
      113 
     ], 
     "title_long":"President", 
     "current":false, 
     "person":{ 
      "name":"President Barack Obama [D]", 
      "firstname":"Barack", 
      "twitterid":null, 
      "middlename":"", 
      "gender":"male", 
      "bioguideid":"O000167", 
      "namemod":"", 
      "birthday":"1961-08-04", 
      "link":"https://www.govtrack.us/congress/members/barack_obama/400629", 
      "youtubeid":null, 
      "sortname":"Obama, Barack (President) [D]", 
      "lastname":"Obama", 
      "gender_label":"Male", 
      "osid":"N00009638", 
      "pvsid":"9490", 
      "nickname":"", 
      "id":400629, 
      "cspanid":null 
     } 
} 

:

POST /presidents/president/1 
{ "bo" : 
     { 
     "website":"", 
     "startdate":"2009-01-20", 
     "role_type_label":"President", 
     "enddate":"2013-01-20", 
     "description":"President", 
     "district":null, 
     "phone":null, 
     "title":"President", 
     "congress_numbers":[ 
      111, 
      112, 
      113 
     ], 
     "title_long":"President", 
     "current":false, 
     "person":{ 
      "name":"President Barack Obama [D]", 
      "firstname":"Barack", 
      "twitterid":null, 
      "middlename":"", 
      "gender":"male", 
      "bioguideid":"O000167", 
      "namemod":"", 
      "birthday":"1961-08-04", 
      "link":"https://www.govtrack.us/congress/members/barack_obama/400629", 
      "youtubeid":null, 
      "sortname":"Obama, Barack (President) [D]", 
      "lastname":"Obama", 
      "gender_label":"Male", 
      "osid":"N00009638", 
      "pvsid":"9490", 
      "nickname":"", 
      "id":400629, 
      "cspanid":null 
     } 
     ... 
     } 
} 

그럼 내가 개별 대통령에 대한 더 많은 데이터를 추가하려면, 차라리 이렇게해야 실현 좋습니다. ES가 업데이트를 허용했습니다.

하지만 이제 키바 나의 관리/색인 패턴으로 이동하면 person.lastnamebo.person.lastname이 필드로 표시됩니다.

왜 이전 필드가 남아 있었습니까? ES가 더 이상 업데이트 된 문서에없는 필드를 유지하는 것이 정상입니까?

그리고 분명히 예외적으로 우스운 것들을 제외하고는, 오늘의 선거 결과에 관한 정보는 없습니다.

답변

1

이것은 Elasticsearch의 정상적인 예상 동작입니다.

ES는 기본적으로 삽입하려는 데이터를 동적으로 매핑합니다. 색인에서 동일한 유형의 여러 객체를 색인 할 때이 모든 객체는 동일한 매핑을 공유합니다. 의도는 해당 유형의 잠재적 필드를 모두 포함하지 않고 오브젝트를 삽입 할 수있게하고 어쨌든 인덱스에 삽입하는 것입니다.

색인 작성시 또는 색인의 새 유형을 정의하여 사용자가 직접 맵핑을 정의 할 수 있습니다. 매핑은 일부주의 사항과 함께 업데이트 될 수도 있습니다.

다음과 같은 실행, 색인의 유형의 매핑을 참조하십시오 :

GET /tk_file.2016/TK_FILE/_mapping 

과 같이 표시됩니다 귀하의 응답 : 당신은 매핑의 세트를 가지고 여기

{ 
    "presidents": { 
     "mappings": { 
     "president": { 
      "properties": { 
       "bo": { 
        "properties": { 
        "congress_numbers": { 
         "type": "long" 
        }, 
        "current": { 
         "type": "boolean" 
        }, 
        "description": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "enddate": { 
         "type": "date" 
        }, 
        "person": { 
         "properties": { 
          "bioguideid": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "birthday": { 
           "type": "date" 
          }, 
          "firstname": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "gender": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "gender_label": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "id": { 
           "type": "long" 
          }, 
          "lastname": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "link": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "middlename": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "name": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "namemod": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "nickname": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "osid": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "pvsid": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          }, 
          "sortname": { 
           "type": "text", 
           "fields": { 
           "keyword": { 
            "type": "keyword", 
            "ignore_above": 256 
           } 
           } 
          } 
         } 
        }, 
        "role_type_label": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "startdate": { 
         "type": "date" 
        }, 
        "title": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "title_long": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "website": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        } 
        } 
       }, 
       "congress_numbers": { 
        "type": "long" 
       }, 
       "current": { 
        "type": "boolean" 
       }, 
       "description": { 
        "type": "text", 
        "fields": { 
        "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
        } 
        } 
       }, 
       "enddate": { 
        "type": "date" 
       }, 
       "person": { 
        "properties": { 
        "bioguideid": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "birthday": { 
         "type": "date" 
        }, 
        "firstname": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "gender": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "gender_label": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "id": { 
         "type": "long" 
        }, 
        "lastname": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "link": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "middlename": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "name": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "namemod": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "nickname": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "osid": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "pvsid": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "sortname": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        } 
        } 
       }, 
       "role_type_label": { 
        "type": "text", 
        "fields": { 
        "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
        } 
        } 
       }, 
       "startdate": { 
        "type": "date" 
       }, 
       "title": { 
        "type": "text", 
        "fields": { 
        "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
        } 
        } 
       }, 
       "title_long": { 
        "type": "text", 
        "fields": { 
        "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
        } 
        } 
       }, 
       "website": { 
        "type": "text", 
        "fields": { 
        "keyword": { 
         "type": "keyword", 
         "ignore_above": 256 
        } 
        } 
       } 
      } 
     } 
     } 
    } 
} 

공지 사항 bo 개체 및 관련 하위 필드뿐만 아니라 후속 문서의 각 필드에 대한 매핑이 있어야합니다. 이것이 동적 매핑의 효과입니다.

이 매핑 유연성을 사용하지 않으려면 동적 매핑을 명시 적으로 비활성화하고 데이터 구조를 포함하여 문서의 구조를 직접 정의 할 수 있습니다. 아마도 bioguideid을 현재 매핑에 정의되어 있기 때문에 텍스트 대신 정수로 사용 하시겠습니까? Mappings API으로 연결됩니다.

관련 문제