Preamble: this solution was being written before the moment when the author demonstrated his efforts in the field calculator.
In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
.
Let's assume we have a layer 'units_1'
(yellow) with its corresponding attribute tables accordingly, see image below.
Case 1. With aggregation
With the following query, it is possible to estimate the length of the common boundary shared by any two corresponding districts/polygons.
SELECT
u11.*,
GROUP_CONCAT(u12.id || ', len:' || round(st_length(st_intersection(u11.geometry, u12.geometry)), 4), "; ") AS "neighbor_info"
FROM
"unit_1" AS u11, "unit_1" AS u12
WHERE
st_intersects(u11.geometry, u12.geometry)
AND u11.id <> u12.id
GROUP BY
u11.id
ORDER BY
u11.id ASC
The output Virtual Layer with its Attribute table will look as following
Case 2. Without aggregation
In case if no aggregation has to be conducted then proceed with the following query
SELECT
u11.*,
u12.id || ', len:' || round(st_length(st_intersection(u11.geometry, u12.geometry)), 4) AS "neighbor_info"
FROM
"unit_1" AS u11, "unit_1" AS u12
WHERE
st_intersects(u11.geometry, u12.geometry)
AND u11.id <> u12.id
ORDER BY
u11.id ASC
Then the new output Virtual Layer with its Attribute table will look as following