postgresql – How to select specific rows for each ORDER BY clause

I have two tables, map1 and map2 and I execute a SQL operation on them. I get several possible combinations between the columns map1.id1 and map2.id2.

I have tried the query below:

SELECT map1.id1, ​​map2.id2, MIN (ST_HausdorffDistance (map1.g1, map2.g2)), map2.g2
DE map1, map2
WHERE ST_HausdorffDistance (map1.g1, map2.g2) <2
GROUPING BY map1.id1, ​​map2.g2, map2.id2, ST_HausdorffDistance (map1.g1, map2.g2)
ORDER BY map1.id1, ​​map2.id2, ST_HausdorffDistance (map1.g1, map2.g2)

Output current

Several lines for Id1:

id1 id2 min g2
---- ---- ---------------- -------------------------- -------------------------------------------------- -------------------------------------------------- -
6116 338 1.8122154049353 "0102000020E610000002000000590E3EDEF5AB23409255B6B4BF1B4A4031197DBBDBAB23404AF663EEB51B4A40"
6116 645 1.72162999509807 "0102000020E61000000300000057900B73277D2340A1675831011E4A4094C55801197D23406A204C40021E4A40B0CFF7AE9C7C234079AAE8B4131E4A40"
6116 674 1.82397666934862 "0102000020E6100000000000000AC0E6F8C53B723405B80118F1F1E4A404EFF48C78BB723406C9159620A1E4A40"
65,695 1.22999509807 "01456020E61000000300000057900B73277D2340A1675831011E4A4094C55801197D23406A204C40021E4A40B0CFF7AE9C7C234079AAE8B4131E4A40"
65 689 1.556666934862 "0202000020E610000002000000AC0E6F8C53B723405B80118F1E4A404EFF48C78BB723406C9159620A1E4A40"

Desired output

I wanted to SELECT only the 1st or 1st rows for a Id1 (6116):

id1 id2 min g2
---- ---- ---------------- -------------------------- -------------------------------------------------- ----------------------------------------------
6116 338 1.8122154049353 "0102000020E610000002000000590E3EDEF5AB23409255B6B4BF1B4A4031197DBBDBAB23404AF663EEB51B4A40"
65,695 1.22999509807 "01456020E61000000300000057900B73277D2340A1675831011E4A4094C55801197D23406A204C40021E4A40B0CFF7AE9C7C234079AAE8B4131E4A40"