Map<Integer, GeoName> parentMap = new HashMap<Integer, GeoName>();
Map<Integer, Set<GeoName>> grandParentMap = new HashMap<Integer, Set<GeoName>>();
for (Integer parentId : childMap.keySet()) {
// Lucene query used to look for exact match on the "geonameID" field
Query q = NumericRangeQuery.newIntRange(GEONAME_ID.key(), parentId, parentId, true, true);
TopDocs results = indexSearcher.search(q, null, 1, POPULATION_SORT);
if (results.scoreDocs.length > 0) {
Document doc = indexSearcher.doc(results.scoreDocs[0].doc);
GeoName parent = GeoName.parseFromGeoNamesRecord(doc.get(GEONAME.key()), doc.get(PREFERRED_NAME.key()));
parentMap.put(parent.getGeonameID(), parent);
if (!parent.isAncestryResolved()) {