File tree 2 files changed +42
-43
lines changed
2 files changed +42
-43
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,15 @@ object IndexFields {
14
14
15
15
def apply (index : String , data : JsValue ) = {
16
16
val docTypes = (data \ index \ " mappings" ).as[JsObject ].keys
17
- val fields = docTypes.flatMap { docType =>
18
- extractProperties((data \ index \ " mappings" \ docType \ " properties" ).as[JsValue ])
19
- }.toSeq
20
- JsArray (fields.map(JsString (_)))
17
+ val fields = if (docTypes.size == 1 && docTypes.head == " properties" ) {
18
+ extractProperties((data \ index \ " mappings" \ " properties" ).as[JsValue ])
19
+ } else { // FIXME: ES < 7
20
+ docTypes.flatMap { docType =>
21
+ extractProperties((data \ index \ " mappings" \ docType \ " properties" ).as[JsValue ])
22
+ }.toSeq
23
+ }
24
+
25
+ JsArray (fields.map(JsString ))
21
26
}
22
27
23
28
def extractProperties (data : JsValue ): Seq [String ] = {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ object IndexFieldsSpec extends Specification {
9
9
s2 """
10
10
IndexField should
11
11
should return only string fields $regularFields
12
- should return fields from all types $multipleTypes
12
+ should return fields from all types $multipleTypes FIXME < 7
13
13
should return sub fields on multi fields fields $multiFields
14
14
should return properties of object fields $objects
15
15
@@ -21,18 +21,16 @@ object IndexFieldsSpec extends Specification {
21
21
|{
22
22
| "index_name": {
23
23
| "mappings": {
24
- | "type_1": {
25
- | "properties": {
26
- | "regular_field": {
27
- | "type": "string"
28
- | },
29
- | "regular_field_2": {
30
- | "type": "string",
31
- | "analyzer": "standard"
32
- | },
33
- | "ignored_field": {
34
- | "type": "integer"
35
- | }
24
+ | "properties": {
25
+ | "regular_field": {
26
+ | "type": "string"
27
+ | },
28
+ | "regular_field_2": {
29
+ | "type": "string",
30
+ | "analyzer": "standard"
31
+ | },
32
+ | "ignored_field": {
33
+ | "type": "integer"
36
34
| }
37
35
| }
38
36
| }
@@ -78,17 +76,15 @@ object IndexFieldsSpec extends Specification {
78
76
|{
79
77
| "index_name": {
80
78
| "mappings": {
81
- | "type_1": {
82
- | "properties": {
83
- | "multi_field": {
84
- | "type": "string",
85
- | "fields": {
86
- | "sub_field": {
87
- | "type": "string"
88
- | },
89
- | "ignored_sub_field": {
90
- | "type": "integer"
91
- | }
79
+ | "properties": {
80
+ | "multi_field": {
81
+ | "type": "string",
82
+ | "fields": {
83
+ | "sub_field": {
84
+ | "type": "string"
85
+ | },
86
+ | "ignored_sub_field": {
87
+ | "type": "integer"
92
88
| }
93
89
| }
94
90
| }
@@ -108,22 +104,20 @@ object IndexFieldsSpec extends Specification {
108
104
|{
109
105
| "index_name": {
110
106
| "mappings": {
111
- | "type_1": {
112
- | "properties": {
113
- | "object_type": {
114
- | "properties": {
115
- | "first_level_property": {
116
- | "properties": {
117
- | "second_level_property": {
118
- | "type": "string"
119
- | }
107
+ | "properties": {
108
+ | "object_type": {
109
+ | "properties": {
110
+ | "first_level_property": {
111
+ | "properties": {
112
+ | "second_level_property": {
113
+ | "type": "string"
120
114
| }
121
- | },
122
- | "first_level_property_2": {
123
- | "properties ": {
124
- | "second_level_property ": {
125
- | "type ": "string"
126
- | }
115
+ | }
116
+ | },
117
+ | "first_level_property_2 ": {
118
+ | "properties ": {
119
+ | "second_level_property ": {
120
+ | "type": "string"
127
121
| }
128
122
| }
129
123
| }
You can’t perform that action at this time.
0 commit comments