Skip to content

Country codes #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ http://localhost:2322/api?q=berlin&osm_tag=tourism
"name": "Berlin",
"state": "Berlin",
"country": "Germany",
"countrycode": "DE",
"osm_key": "place",
"osm_value": "city",
"osm_type": "N",
Expand All @@ -194,6 +195,7 @@ http://localhost:2322/api?q=berlin&osm_tag=tourism
"postcode": "14053",
"state": "Berlin",
"country": "Germany",
"countrycode": "DE",
"osm_key": "leisure",
"osm_value": "stadium",
"osm_type": "W",
Expand Down
6 changes: 5 additions & 1 deletion es/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
}
}
},
"countrycode": {
"type": "text",
"index": false
},
"housenumber": {
"type": "text",
"index": true,
Expand Down Expand Up @@ -482,4 +486,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions src/main/java/de/komoot/photon/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Constants {
public static final String HOUSENUMBER = "housenumber";
public static final String NAME = "name";
public static final String COUNTRY = "country";
public static final String COUNTRYCODE = "countrycode";
public static final String CITY = "city";
public static final String STREET = "street";
public static final String STATE = "state";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/de/komoot/photon/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;
import com.neovisionaries.i18n.CountryCode;
import com.vividsolutions.jts.geom.Envelope;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -47,6 +48,9 @@ public static XContentBuilder convert(PhotonDoc doc, String[] languages) throws
writeName(builder, doc.getName(), languages);
writeIntlNames(builder, doc.getCity(), "city", languages);
writeIntlNames(builder, doc.getCountry(), "country", languages);
CountryCode countryCode = doc.getCountryCode();
if (countryCode != null)
builder.field(Constants.COUNTRYCODE, countryCode.getAlpha2());
writeIntlNames(builder, doc.getState(), "state", languages);
writeIntlNames(builder, doc.getStreet(), "street", languages);
writeContext(builder, doc.getContext(), languages);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/komoot/photon/utils/ConvertToJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
@Slf4j
public class ConvertToJson implements OneWayConverter<SearchResponse, List<JSONObject>> {
private final static String[] KEYS_LANG_UNSPEC = {Constants.OSM_ID, Constants.OSM_VALUE, Constants.OSM_KEY, Constants.POSTCODE, Constants.HOUSENUMBER, Constants.OSM_TYPE};
private final static String[] KEYS_LANG_UNSPEC = {Constants.OSM_ID, Constants.OSM_VALUE, Constants.OSM_KEY, Constants.POSTCODE, Constants.HOUSENUMBER, Constants.COUNTRYCODE, Constants.OSM_TYPE};
private final static String[] KEYS_LANG_SPEC = {Constants.NAME, Constants.COUNTRY, Constants.CITY, Constants.STREET, Constants.STATE};
private final String lang;

Expand Down