나는 default mapping을 사용했다. 이 경우 나는 단지 하나의 필드를 가지고,하지만 난 그것을 분석되지 않습니다 있는지 확인하려면 (내가 유형에 걸쳐 페이스 팅을 할 수있는 말) :
curl -XDELETE "http://localhost:9200/test_index"
curl -XPUT "http://localhost:9200/test_index" -d'
{
"mappings": {
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}'
가 그럼 난 문서의 몇 가지를 만들어, 다른 유형의 각 :
curl -XPUT "http://localhost:9200/test_index/doc_type1/1" -d'
{ "title": "some text" }'
curl -XPUT "http://localhost:9200/test_index/doc_type2/2" -d'
{ "title": "some other text" }'
그래서 각 유형에 대한 매핑이 동적으로 생성되며, "title"
의 기본 매핑이 포함됩니다. 우리는 매핑을보고이를 볼 수 있습니다
curl -XGET "http://localhost:9200/test_index/_mapping"
...
{
"test_index": {
"mappings": {
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
},
"doc_type2": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
},
"doc_type1": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
을 그리고 나는 title
필드에 패싯 경우 내가 기대하는 것을 다시 얻을 것이다 :
: 여기
curl -XPOST "http://localhost:9200/test_index/_search" -d'
{
"size": 0,
"facets": {
"title_values": {
"terms": {
"field": "title",
"size": 10
}
}
}
}'
...
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0,
"hits": []
},
"facets": {
"title_values": {
"_type": "terms",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term": "some text",
"count": 1
},
{
"term": "some other text",
"count": 1
}
]
}
}
}
내가 사용하는 코드입니다
http://sense.qbox.io/gist/05c503ce9ea841ca4013953b211e00dadf6f1549
이 질문에 대한 답변?
편집 : 여기은 기존 인덱스에 대한 _default_
매핑을 업데이트 할 수있는 방법은 다음과 같습니다. (나는 그런데,이 대답을 Elasticsearch 버전 1.3.4을 사용)
curl -XPUT "http://localhost:9200/test_index/_default_/_mapping" -d'
{
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}'