2017-12-18 4 views
0

현재 Elasticsearch에 대한 매핑 파일을 단순화하기 위해 고심하고 있습니다. 실제로 동일한 구조의 여러 Object 필드가 있습니다 (예 : 여기에서 소스와 대상)여러 정확한 필드와 일치하는 동적 검색 동적 템플릿

여러 패턴과 일치 할 수 있도록 동적 템플릿을 설정하는 방법이 있습니까?

는 여기에 내가 실행 무엇 : 나는 (~ 20)에 맞도록이 같은 계획을 많이 가지고

POST /_template/mapping-lol 
{ 
    "template": "*-newevents-*", 
    "mappings": { 
    "log": { 
     "dynamic_templates": [ 
     { 
      "system": { 
      "match_pattern": "regex", 
      "match": "^(source|destination)$", 
      "mapping": { 
       "properties": { 
       "name": { 
        "dynamic": false, 
        "type": "object", 
        "properties": { 
        "first": { 
         "type": "text" 
        }, 
        "last": { 
         "type": "text" 
        } 
        } 
       }, 
       "ip": { 
        "type": "ip" 
       } 
       } 
      } 
      } 
     } 
     ], 
     "properties": { 
     "source": { 
      "type": "object", 
      "dynamic": true 
     }, 
     "destination": { 
      "type": "object", 
      "dynamic": true 
     } 
     } 
    } 
    } 
} 

POST /tenant-newevents-1/log 
{ 
    "source": { 
    "name": { 
     "first": "John", 
     "last": "Doe" 
    }, 
    "ip": "1.2.3.4" 
    }, 
    "destination": { 
    "name": { 
     "first": "Jane", 
     "last": "Doe" 
    }, 
    "ip": "3.4.5.6" 
    } 
} 

GET /tenant-newevents-1 

이 위에서 작동하지 않습니다 ...

.

도움 주셔서 감사합니다.

+0

나에게 잘 어울립니다. ES 5와 6을 시험해 보았는데 제대로 작동했습니다. 색인/매핑을 만드는 방법을 보여주십시오. – Val

+0

curl -XPOST "locallhost : 9200/_template/mapping-events"[email protected] – moutonjr

+0

좋습니다! mymapping.json의 내용은 어떻습니까? – Val

답변

0

OK 무엇이 잘못되었는지 알아 냈습니다. 필드를 매핑하면 안됩니다. 전혀 아니요 동적 매핑을 진행하십시오. 매핑에서 "소스"및 "대상"스키마 제거가 효과적입니다.

POST /_template/mapping-lol 
{ 
    "template": "*-newevents-*", 
    "mappings": { 
    "log": { 
     "dynamic_templates": [ 
     { 
      "system": { 
      "match_pattern": "regex", 
      "match": "^(source|destination)$", 
      "mapping": { 
       "properties": { 
       "name": { 
        "dynamic": false, 
        "type": "object", 
        "properties": { 
        "first": { 
         "type": "text" 
        }, 
        "last": { 
         "type": "text" 
        } 
        } 
       }, 
       "ip": { 
        "type": "ip" 
       } 
       } 
      } 
      } 
     } 
     ], 
     "properties": {} 
    } 
    } 
} 
+0

그게 내 다음 댓글이었습니다 ;-) 동적 템플릿이 있다면 매핑하는 것이 의미가 없습니다. – Val