내 elasticsearch db에서 중첩 된 문서의 필드를 검색하고 싶습니다.elasticsearch.js 및 각도를 사용하여 Elasticsearch에서 중첩 된 개체를 검색하는 방법
curl -X GET 'http://localhost:9200/jira-dev/_search?pretty=true' -d '
{
"_source" : false,
"query" : {
"nested" : {
"path" : "issues",
"query" : {
"bool": {
"should": [
{
"wildcard":{
"issues.fields.description":"*migrate*"
}
},
{
"wildcard":{
"issues.fields.comment.comments.body":"*autodeploy*"
}
}
]
}
},
"inner_hits" : {"size": 5000}
}
}
}'
하지만이 방법으로 elasticsearch.js를 사용하여 전화를 할 때, 그것이 어떤 결과를 얻을하지 않습니다 :
나는 중첩 된 객체의 필드 (점점 (10) 내부 안타를) 검색하려면 다음 명령을 사용하여client.search({
index: 'jira-dev/',
type: 'jira',
body: {
query: {
nested : {
path : "issues",
query : {
bool: {
should: [
{
wildcard:{
"issues.fields.description":"*migrate*"
}
},
{
wildcard:{
"issues.fields.comment.comments.body":"*autodeploy*"
}
}
]
}
},
inner_hits : {size: 5000}
}
}
}
}).then(function (resp) {
var hits = resp.hits.totals;
console.log('works');
}, function (err) {
console.log('epic fail');
console.trace(err.message);
});
내가 사용하는 구문이 올바르지 않다고 생각하지만 elasticsearch.js를 사용하여 중첩 쿼리의 예를 찾지 못했습니다.
미리 감사드립니다.
편집 : 요청 같이
, 문서의 구성되어 다음
curl -X POST 'http://localhost:9200/jira-dev/' -d '{
"mappings" : {
"jira" : {
"properties" : {
"expand" : {"type" : "string"},
"startAt" : {"type" : "integer"},
"maxResults" : {"type" : "integer"},
"total" : {"type" : "integer"},
"issues" : {
"type" : "nested",
"include_in_parent" : false,
"properties" : {
"created" : {"type" : "date", "format" : "date_hour_minute_second_fraction"}
}
}
}
}
},
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
}
}'
및 예 : 마지막
{
"_index": "jira-dev",
"_type": "jira",
"_id": "1",
"_version": 1,
"_score": 1,
"_source": {
"expand": "schema,names",
"startAt": 0,
"maxResults": 1000,
"total": 604,
"issues": [
{
"key": "STACK-1",
"fields": {
"summary": "A nice summary",
"created": "2016-06-28T09:45:32.000+0000",
"description": null,
"comment": {
"startAt": 0,
"maxResults": 1,
"total": 1,
"comments": [
{
"self": url",
"id": "30293",
"author": {
"name": "stack_overflow",
"key": "stack_overflow"
},
"body": "Following epic has been created: url",
"updateAuthor": {
"name": "stack_overflow",
"key": "stack_overflow",
"timeZone": "Europe/Madrid"
},
"created": "2016-03-04T10:09:11.000+0000",
"updated": "2016-03-04T10:09:11.000+0000"
}
]
}
}
}
]
}
}
문서의 구조가 어떻게 보이는지 예를 들려 줄 수 있습니까? –
확실히 예를 들어 추가했습니다. –