내가이 쿼리를 사용하고 있습니다로 처리 하나의 필드에있다 (SQLfying는 SELECT field, count(field) GROUP BY field
것ElasticSearch 집계 : 공백 문자열 값 얻기 위해서 두 개의 문자열
난 그렇게하기 위해서. ES이 요청을 전송 :이 컬렉션에 하나 개의 문서가있다
{
"query" : {
"bool" : {
"must" : {
"exists" : {
"field" : "metainfos.ceeaacceaeaaccebeaacceceaaccedeaac"
}
}
}
},
"aggregations" : {
"followUpActivity.metainfo.metainfos.ceeaacceaeaaccebeaacceceaaccedeaac" : {
"terms" : {
"field" : "metainfos.ceeaacceaeaaccebeaacceceaaccedeaac",
"missing" : "null"
}
}
}
}
:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "living_v1",
"_type" : "fuas",
"_id" : "a2cb0ba1-8955-11e6-8a00-0242ac110007",
"_score" : 1.0,
"_routing" : "user2",
"_source" : {
"user" : "user2",
"timestamp" : "2016-10-03T11:08:30.074Z",
"startTimestamp" : "2016-10-03T11:08:30.074Z",
"dueTimestamp" : null,
"closingTimestamp" : null,
"matter" : "Fua 1",
"comment" : null,
"status" : 0,
"backlogStatus" : 20,
"metainfos" : {
"ceeaacceaeaaccebeaacceceaaccedeaac" : [ "Living Digital" ]
},
"resources" : [ ],
"notes" : null
}
} ]
}
}
으로 당신이 볼 수 doc.metainfos.ceeaacc... = ["Living Digital"]
"digital"
또 다른 하나
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "living_v1",
"_type" : "fuas",
"_id" : "a2cb0ba1-8955-11e6-8a00-0242ac110007",
"_score" : 1.0,
"_routing" : "user2",
"_source":{"user":"user2","timestamp":"2016-10-03T11:08:30.074Z","startTimestamp":"2016-10-03T11:08:30.074Z","dueTimestamp":null,"closingTimestamp":null,"matter":"Fua 1","comment":null,"status":0,"backlogStatus":20,"metainfos":{"ceeaacceaeaaccebeaacceceaaccedeaac":["Living Digital"]},"resources":[],"notes":null}
} ]
},
"aggregations" : {
"followUpActivity.metainfo.metainfos.ceeaacceaeaaccebeaacceceaaccedeaac" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "digital",
"doc_count" : 1
}, {
"key" : "living",
"doc_count" : 1
} ]
}
}
}
ES는 나에게 두 값을 받고있다. 나는 shole 값 "Living Digital"
을 사용하여 집합을 얻고 싶습니다.
매핑 방식은 다음과 같습니다
{
"living_v1" : {
"mappings" : {
"fuas" : {
"properties" : {
"backlogStatus" : {
"type" : "long"
},
"comment" : {
"type" : "string"
},
"matter" : {
"type" : "string"
},
"metainfos" : {
"properties" : {
"ceeaacceaeaaccebeaacceceaaccedeaac" : {
"type" : "string"
}
}
},
"startTimestamp" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
},
"status" : {
"type" : "long"
},
"timestamp" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
},
"user" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
}
당신이 볼 수 있듯이 :
"metainfos" : {
"properties" : {
"ceeaacceaeaaccebeaacceceaaccedeaac" : {
"type" : "string"
}
}
}
나에게 문제는 "ceeaacceaeaaccebeaacceceaaccedeaac는"사용자가 주문형 재산 작성 나도 몰라입니다 어떻게 not-analyzed
을 metainfos.*
필드로 설정할 수 있습니까?
#curl -XPUT 'http://localhost:9200/living_v1/' -d '
{
"mappings": {
"fuas": {
"dynamic_templates": [
{
"metainfos": {
"path_match": "metainfos.*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
]
}
}
}
'
living_v1
인덱스가 이미 존재 내게 말하고 :
편집
나는 테스트했습니다. 지금까지 내가 here에 알아낼 수있었습니다 나는 PUT
index
에 보낼 필요가 : 이미 눈치로, 검색 동작은 기본적으로 적용된 매핑에 의해 발생
{
"error":{
"root_cause":[
{
"type":"index_already_exists_exception",
"reason":"already exists",
"index":"living_v1"
}
],
"type":"index_already_exists_exception",
"reason":"already exists",
"index":"living_v1"
},
"status":400
}
동적 색인 템플릿을 찾고 있다고 생각합니다. http://stackoverflow.com/a/23370138/693546 – mblaettermann