質問編集履歴

1

例文をわかりやすく修正しました

2016/11/21 05:31

投稿

furu3labs
furu3labs

スコア8

test CHANGED
File without changes
test CHANGED
@@ -2,11 +2,15 @@
2
2
 
3
3
  ElasticSearch で nested されている filed から任意の filed のみを取得したいです。
4
4
 
5
+
6
+
7
+ 以下のようなブログとコメントを持つとします。
8
+
5
- body.date に一致した body filed だけを取得することは可能なのでょうか?
9
+ この中から特定の発言者(comments.name)に一致したコメントだけを取り出す、または発信日(comments.date)に一致したコメントだけを取得することを想定ています。
6
10
 
7
11
 
8
12
 
9
- _source : { "include" : [ "body" ] } 指定で body がデータの大き配列となってしまうので、読み込みのデータ量を少なくしたいす。
13
+ コメント全部を取得するのはデータ量的に重くので避けたいと考えています。
10
14
 
11
15
 
12
16
 
@@ -16,101 +20,29 @@
16
20
 
17
21
  ```
18
22
 
23
+ PUT /my_index
24
+
25
+
26
+
19
27
  {
20
28
 
21
- "test" : {
29
+ "mappings": {
22
30
 
23
- "mappings" : {
31
+ "blogbody": {
24
32
 
25
- "books" : {
33
+ "properties": {
26
34
 
27
- "properties" : {
35
+ "comments": {
28
36
 
29
- "sample_id" : {
37
+ "type": "nested",
30
38
 
31
- "type" : "long",
39
+ "properties": {
32
40
 
33
- "store" : true
41
+ "name": { "type": "string" },
34
42
 
35
- },
43
+ "comment": { "type": "string" },
36
44
 
37
- "name" : {
38
-
39
- "type" : "string",
40
-
41
- "store" : true
42
-
43
- },
44
-
45
- "body" : {
46
-
47
- "type" : "nested",
48
-
49
- "properties" : {
50
-
51
- "date" : {
52
-
53
- "type" : "date",
45
+ "date": { "type": "date" }
54
-
55
- "store" : true,
56
-
57
- "format" : "y-M-d"
58
-
59
- },
60
-
61
- "info1" : {
62
-
63
- "type" : "nested",
64
-
65
- "properties" : {
66
-
67
- "price" : {
68
-
69
- "type" : "long",
70
-
71
- "store" : true
72
-
73
- },
74
-
75
- "qty" : {
76
-
77
- "type" : "long",
78
-
79
- "store" : true
80
-
81
- }
82
-
83
- }
84
-
85
- },
86
-
87
- "info2" : {
88
-
89
- "type" : "nested",
90
-
91
- "properties" : {
92
-
93
- "price" : {
94
-
95
- "type" : "long",
96
-
97
- "store" : true
98
-
99
- },
100
-
101
- "qty" : {
102
-
103
- "type" : "long",
104
-
105
- "store" : true
106
-
107
- }
108
-
109
- }
110
-
111
- }
112
-
113
- }
114
46
 
115
47
  }
116
48