importThread.start();
template.query("SELECT " + selectColsPlaceX + " FROM placex WHERE linked_place_id IS NULL order by geometry_sector; ", new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
PhotonDoc doc = placeRowMapper.mapRow(rs, 0);
if(!doc.isUsefulForIndex()) return; // do not import document
// finalize document by taking into account the higher level address assigned to this doc.
final List<AddressRow> addresses = getAddresses(doc);
for(AddressRow address : addresses) {
if(address.isCity()) {
if(doc.getCity() != null) {
doc.getContext().add(doc.getCity());
}
doc.setCity(address.getName());
} else if(address.isStreet() && doc.getStreet() == null) {
doc.setStreet(address.getName());
} else if(address.hasPostcode() && doc.getPostcode() == null) {
doc.setPostcode(address.getPostcode());
} else {
if(address.isUsefulForContext()) {
doc.getContext().add(address.getName());
}
}
}