2017-04-04 13 views
0

私はElastic Searchインデックスの動的マッパーを無効にしようとしています。以下は、私がKibanaコンソールを使って実行している一連のクエリです。Elastic Search 5.2のインデックスごとの動的マッピングを無効にする

「index.mapper.dynamic」を追加すると、インデックスレベルで無効にする必要がありますか? HERE EDITED

: 私も「偽in the type. Strangely, if I post the document then it doesn't actually update the mapping, so if check _mapping` 『filteredField』にダイナミックプロパティを設定しようとしましたがリストされていないが、私は、ドキュメントを検索する場合、filteredFieldがインデックス化し、そこにあるされています! -

弾性バージョン:

{ 
    "name": "DpVBoAZ", 
    "cluster_name": "elasticsearch", 
    "cluster_uuid": "RX6axsbOTMatorw7s5AOXQ", 
    "version": { 
    "number": "5.2.0", 
    "build_hash": "24e05b9", 
    "build_date": "2017-01-24T19:52:35.800Z", 
    "build_snapshot": false, 
    "lucene_version": "6.4.0" 
    }, 
    "tagline": "You Know, for Search" 
} 

しかし、最終的なGET戻り、このドキュメントは、filteredField私はちょうどテストに投稿されたドキュメントに追加されたフィールドであることに注意してください - それは結果であってはなりません。私はマッピングもチェックし、マッピングに動的に追加されました。

私の作成インデックスクエリで何が問題になっていますか?

{ 
    "_index": "meu_locations", 
    "_type": "location", 
    "_id": "12345", 
    "_version": 2, 
    "found": true, 
    "_source": { 
    "__v": 0, 
    "address1": "30 Mort Street", 
    "email": "[email protected]", 
    "faxNumber": "(02) 6122 0070", 
    "geo": { 
     "location": { 
     "lon": 149.1317, 
     "lat": -35.27433 
     }, 
     "autogeocode": false 
    }, 
    "identifier": "sample-store", 
    "phoneNumber": "(02) 6122 0000", 
    "postCode": "2612", 
    "state": "ACT", 
    "suburb": "Braddon", 
    "title": "Hello New Title", 
    "filteredField": "Hello There", 
    "urlToken": "sample-store", 
    "status": "Active", 
    "country": "AU", 
    "id": "Skcyxox6x" 
    } 
} 

検索は、あなたのインデックスの動的なマッピングを無効にするには、マッピングで"dynamic": "strict"にあなたが持っている

DELETE meu_locations 

PUT meu_locations 
{ 
    "settings": { 
    "index.mapper.dynamic": false, 
    "index.mapping.total_fields.limit": 2000, 
    "analysis": { 
     "filter": { 
     "email": { 
      "type": "pattern_capture", 
      "preserve_original": 1, 
      "patterns": [ 
      "([^@]+)", 
      "(\\p{L}+)", 
      "(\\d+)", 
      "@(.+)", 
      "([^[email protected]]+)" 
      ] 
     } 
     }, 
     "analyzer": { 
     "case_insensitive_sort": { 
      "tokenizer": "keyword", 
      "filter": [ 
      "lowercase" 
      ] 
     }, 
     "email": { 
      "tokenizer": "uax_url_email", 
      "filter": [ 
      "email", 
      "lowercase", 
      "unique" 
      ] 
     } 
     } 
    } 
    }, 
    "mappings": { 
    "location": { 
     "dynamic": false, 
     "properties": { 
     "title": { 
      "type": "keyword" 
     }, 
     "identifier": { 
      "type": "keyword", 
      "index": "not_analyzed" 
     }, 
     "address1": { 
      "type": "text" 
     }, 
     "address2": { 
      "type": "text" 
     }, 
     "state": { 
      "type": "keyword" 
     }, 
     "suburb": { 
      "type": "text" 
     }, 
     "postCode": { 
      "type": "keyword" 
     }, 
     "country": { 
      "type": "keyword" 
     }, 
     "phoneNumber": { 
      "type": "keyword" 
     }, 
     "type": { 
      "type": "keyword", 
      "index": "not_analyzed" 
     }, 
     "geo": { 
      "properties": { 
      "location": { 
       "type": "geo_point" 
      }, 
      "autogeocode": { 
       "type": "boolean" 
      } 
      } 
     }, 
     "services": { 
      "properties": { 
      "specialOrder": { 
       "type": "boolean" 
      }, 
      "assembleIt": { 
       "type": "boolean" 
      }, 
      "wifi": { 
       "type": "boolean" 
      }, 
      "officeFitout": { 
       "type": "boolean" 
      }, 
      "deliverIt": { 
       "type": "boolean" 
      }, 
      "techServices": { 
       "type": "boolean" 
      }, 
      "parking": { 
       "type": "boolean" 
      }, 
      "courtesyTrailer": { 
       "type": "boolean" 
      }, 
      "extraCover": { 
       "type": "boolean" 
      } 
      } 
     }, 
     "updatedAt": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "createdAt": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "publishDate": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "expiryDate": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "status": { 
      "type": "keyword" 
     } 
     } 
    } 
    } 
} 

PUT meu_locations/location/12345 
{ 
    "__v": 0, 
    "address1": "30 Mort Street", 
    "email": "[email protected]", 
    "faxNumber": "(02) 6122 0070", 
    "geo": { 
    "location": { 
     "lon": 149.1317, 
     "lat": -35.27433 
    }, 
    "autogeocode": false 
    }, 
    "identifier": "sample-store", 
    "phoneNumber": "(02) 6122 0000", 
    "postCode": "2612", 
    "state": "ACT", 
    "suburb": "Braddon", 
    "title": "Hello New Title", 
    "filteredField": "Hello There", 
    "urlToken": "sample-store", 
    "status": "Active", 
    "country": "AU", 
    "id": "Skcyxox6x" 
} 

GET meu_locations/location/12345 
+0

私はそれがどのように弾性マッピングの作品の私の誤解だと思うし始めています。フィールドがマップされていない場合、私は(やや賢明に)想定し、そのフィールドは '_source'に格納されず、ただドロップされます。しかし、おそらく弾性はまだ_sourceにフィールドを格納しますが、インデックスへのフィールドマッピングは保存しないのでしょうか?これは私が観察していることです。フィールドを保持する私の唯一の選択肢は、ソースでフィルタリングし、完璧なドキュメントを投稿することです。少なくとも厳密に設定することで、私は間違いを止めることができます。フィールドがちょうど落とされたならば、もっと良いでしょう。誰でもこれを確認できますか? –

答えて

0

を照会します。

設定のマッピング部分を変更する必要があります。

PUT meu_locations2 
{ 
    "settings": { 
    "index.mapping.total_fields.limit": 2000, 
    "analysis": { 
     "filter": { 
     "email": { 
      "type": "pattern_capture", 
      "preserve_original": 1, 
      "patterns": [ 
      "([^@]+)", 
      "(\\p{L}+)", 
      "(\\d+)", 
      "@(.+)", 
      "([^[email protected]]+)" 
      ] 
     } 
     }, 
     "analyzer": { 
     "case_insensitive_sort": { 
      "tokenizer": "keyword", 
      "filter": [ 
      "lowercase" 
      ] 
     }, 
     "email": { 
      "tokenizer": "uax_url_email", 
      "filter": [ 
      "email", 
      "lowercase", 
      "unique" 
      ] 
     } 
     } 
    } 
    }, 
    "mappings": { 
    "location": { 
     "dynamic": false, 
     "properties": { 
     "title": { 
      "type": "keyword" 
     }, 
     "identifier": { 
      "type": "keyword", 
      "index": "not_analyzed" 
     }, 
     "address1": { 
      "type": "text" 
     }, 
     "address2": { 
      "type": "text" 
     }, 
     "state": { 
      "type": "keyword" 
     }, 
     "suburb": { 
      "type": "text" 
     }, 
     "postCode": { 
      "type": "keyword" 
     }, 
     "country": { 
      "type": "keyword" 
     }, 
     "phoneNumber": { 
      "type": "keyword" 
     }, 
     "type": { 
      "type": "keyword", 
      "index": "not_analyzed" 
     }, 
     "geo": { 
      "properties": { 
      "location": { 
       "type": "geo_point" 
      }, 
      "autogeocode": { 
       "type": "boolean" 
      } 
      } 
     }, 
     "services": { 
      "properties": { 
      "specialOrder": { 
       "type": "boolean" 
      }, 
      "assembleIt": { 
       "type": "boolean" 
      }, 
      "wifi": { 
       "type": "boolean" 
      }, 
      "officeFitout": { 
       "type": "boolean" 
      }, 
      "deliverIt": { 
       "type": "boolean" 
      }, 
      "techServices": { 
       "type": "boolean" 
      }, 
      "parking": { 
       "type": "boolean" 
      }, 
      "courtesyTrailer": { 
       "type": "boolean" 
      }, 
      "extraCover": { 
       "type": "boolean" 
      } 
      } 
     }, 
     "updatedAt": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "createdAt": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "publishDate": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "expiryDate": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "status": { 
      "type": "keyword" 
     } 
     } 
    } 
    } 
} 

おかげ

+0

私はすでにそれを試みました。私は例外をスローしたくありません。私はフィールドを無視したい。私はタイプレベルでfalseに設定しようとしましたが、無駄にしました。 –

+0

例外をスローしたくない場合は、私の回答を編集しました。false.httpsに設定してください://github.com/elastic/elasticsearch/issues/17880 https://github.com/elastic/elasticsearch/issues/ 12358 – user3775217

+0

更新された質問を確認してください。私もそれを試してみました。マップされていなくても、フィールドはインデックスに登録され、検索可能です。私はそれがバグでなければならないと確信しています...最新のものを反映するようにスクリプトを更新しました。 –

関連する問題