Skip to content

Commit

Permalink
Set synaptic field mapping to nested (#4527)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergrabinski authored Nov 24, 2023
1 parent 96174df commit 7c23e52
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/docker/config/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
},
"curated": {
"type": "boolean"
}
},
"preSynapticPathway": { "type": "nested" },
"postSynapticPathway": { "type": "nested" }
}
}
25 changes: 25 additions & 0 deletions tests/src/test/resources/kg/search/synapse-agg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"aggs": {
"preSynapticBrainRegions": {
"nested": {
"path": "preSynapticPathway"
},
"aggs": {
"preSynapticBrainRegions": {
"filter": {
"term": {
"preSynapticPathway.about.keyword": "https://bbp.epfl.ch/neurosciencegraph/data/BrainRegion"
}
},
"aggs": {
"label": {
"terms": {
"field": "preSynapticPathway.label.keyword"
}
}
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions tests/src/test/resources/kg/search/synapse-two-pathways.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"about": "BrainRegion",
"label": "Somatosensory areas",
"notation": "SS"
},
{
"@id": "http://bbp.epfl.ch/neurosciencegraph/ontologies/mtypes/TNJ_NwHgTKe1iv_XLR_0Yg",
"about": "BrainCellType",
"label": "SO_BS"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,11 @@ class SearchConfigIndexingSpec extends BaseIntegrationSpec {
field(
"preSynapticPathway",
json"""[
{
"@id": "http://bbp.epfl.ch/neurosciencegraph/ontologies/mtypes/TNJ_NwHgTKe1iv_XLR_0Yg",
"about": "https://bbp.epfl.ch/neurosciencegraph/data/BrainCellType",
"label": "SO_BS"
},
{
"@id": "http://api.brain-map.org/api/v2/data/Structure/453",
"about": "https://bbp.epfl.ch/neurosciencegraph/data/BrainRegion",
Expand Down Expand Up @@ -839,6 +844,33 @@ class SearchConfigIndexingSpec extends BaseIntegrationSpec {
json should have(field("postSynapticPathway", singlePathway))
}
}

"aggregate presynaptic brain regions" in {
val query = jsonContentOf("kg/search/synapse-agg.json")
val preSynapticBrainRegionAgg =
json"""{
"preSynapticBrainRegions" : {
"doc_count" : 3,
"preSynapticBrainRegions" : {
"doc_count" : 2,
"label" : {
"buckets" : [
{
"doc_count" : 2,
"key" : "Somatosensory areas"
}
],
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0
}
}
}
}"""

deltaClient.post[Json]("/search/query", query, Rick) { (json, _) =>
aggregationIn(json) should contain(preSynapticBrainRegionAgg)
}
}
}

/**
Expand All @@ -851,6 +883,9 @@ class SearchConfigIndexingSpec extends BaseIntegrationSpec {
private def queryDocument(id: String) =
jsonContentOf("kg/search/id-query.json", "id" -> id)

private def aggregationIn(json: Json): Option[Json] =
json.hcursor.downField("aggregations").as[Json].toOption

/** Post a resource across all defined projects in the suite */
private def postResource(resourcePath: String): IO[List[Assertion]] = {
val json = jsonContentOf(resourcePath)
Expand Down

0 comments on commit 7c23e52

Please sign in to comment.