@@ -121,7 +121,7 @@ class RestlasticSearchClientTest extends WordSpec with Matchers with ScalaFuture
121
121
val foundDoc : ElasticJsonDocument = whenReady(resFut){ res =>
122
122
res.rawSearchResponse.hits.hits.head
123
123
}
124
-
124
+
125
125
val delFut = restClient.deleteById(index, tpe, foundDoc._id)
126
126
127
127
whenReady(delFut) { res =>
@@ -195,15 +195,15 @@ class RestlasticSearchClientTest extends WordSpec with Matchers with ScalaFuture
195
195
res.jsonStr should include(" doc4" )
196
196
res.jsonStr should not include " doc5"
197
197
}
198
-
198
+
199
199
val delFut = restClient.bulkDelete(index, tpe, Seq (doc3, doc4, doc5))
200
200
whenReady(delFut){ resp =>
201
201
resp.length should be(3 )
202
202
resp.head.success should be(true )
203
203
resp(1 ).success should be(true )
204
204
resp(2 ).success should be(true )
205
205
}
206
-
206
+
207
207
refresh()
208
208
val resFut2 = restClient.query(index, tpe, new QueryRoot (TermQuery (" text" , " here" )))
209
209
whenReady(resFut2) { res =>
@@ -1109,6 +1109,38 @@ class RestlasticSearchClientTest extends WordSpec with Matchers with ScalaFuture
1109
1109
Await .result(delFut, 10 .seconds) // May not need Await?
1110
1110
}
1111
1111
1112
+ " Support nested mapping" in {
1113
+ val basicFieldMapping = BasicFieldMapping (StringType , None , Some (analyzerName), ignoreAbove = Some (10000 ), Some (analyzerName))
1114
+ val metadataMapping = Mapping (tpe,
1115
+ IndexMapping (
1116
+ Map (" name" -> basicFieldMapping,
1117
+ " kv" -> NestedObjectMapping (Map (" key" -> basicFieldMapping, " val" -> basicFieldMapping))
1118
+ )
1119
+ )
1120
+ )
1121
+
1122
+ val mappingFut = restClient.putMapping(index, tpe, metadataMapping)
1123
+ whenReady(mappingFut) { _ => refresh() }
1124
+ val mappingRes = restClient.getMapping(index, tpe)
1125
+ val expected = """ "kv":{"type":"nested","properties":{"key":{"type":"string","analyzer":"keyword_lowercase","ignore_above":10000},"val":{"type":"string","analyzer":"keyword_lowercase","ignore_above":10000}}}"""
1126
+ mappingRes.futureValue.jsonStr.toString.contains(expected) should be(true )
1127
+ }
1128
+
1129
+ " Support multi-fields mapping" in {
1130
+ val fields = FieldsMapping (Map (" raw" -> BasicFieldMapping (StringType , None , Some (analyzerName), ignoreAbove = Some (10000 ), Some (analyzerName))))
1131
+ val basicFieldMapping = BasicFieldMapping (StringType , None , Some (analyzerName), ignoreAbove = Some (10000 ), Some (analyzerName), fieldsOption = Some (fields))
1132
+ val metadataMapping = Mapping (tpe,
1133
+ IndexMapping (
1134
+ Map (" multi-fields" -> basicFieldMapping)
1135
+ )
1136
+ )
1137
+ val mappingFut = restClient.putMapping(index, tpe, metadataMapping)
1138
+ whenReady(mappingFut) { _ => refresh() }
1139
+ val mappingRes = restClient.getMapping(index, tpe)
1140
+ val expected = """ {"multi-fields":{"type":"string","fields":{"raw":{"type":"string","analyzer":"keyword_lowercase","ignore_above":10000}},"analyzer":"keyword_lowercase","ignore_above":10000}}"""
1141
+ mappingRes.futureValue.jsonStr.toString.contains(expected) should be(true )
1142
+ }
1143
+
1112
1144
def indexDocs (docs : Seq [Document ]): Unit = {
1113
1145
val bulkIndexFuture = restClient.bulkIndex(index, tpe, docs)
1114
1146
whenReady(bulkIndexFuture) { _ => refresh() }
0 commit comments