This commit is contained in:
crimean 2019-07-07 12:05:25 +03:00
parent 4e651f8164
commit 91e9b9e9cb
2 changed files with 12 additions and 4 deletions

View file

@ -354,7 +354,7 @@ public class SearchCoreFactory {
private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher)
throws IOException { throws IOException {
if (phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3 || phrase.getUnknownSearchWords().size() > 0) { if (phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3 || phrase.getUnknownSearchWords().size() > 0 || phrase.isSearchTypeAllowed(ObjectType.POSTCODE, true)) {
final boolean locSpecified = phrase.getLastTokenLocation() != null; final boolean locSpecified = phrase.getLastTokenLocation() != null;
LatLon loc = phrase.getLastTokenLocation(); LatLon loc = phrase.getLastTokenLocation();
final List<SearchResult> immediateResults = new ArrayList<>(); final List<SearchResult> immediateResults = new ArrayList<>();

View file

@ -422,10 +422,18 @@ public class SearchPhrase {
} }
public boolean isSearchTypeAllowed(ObjectType searchType) { public boolean isSearchTypeAllowed(ObjectType searchType) {
if (getSearchTypes() == null) { return isSearchTypeAllowed(searchType, false);
return true; }
public boolean isSearchTypeAllowed(ObjectType searchType, boolean exclusive) {
ObjectType[] searchTypes = getSearchTypes();
if (searchTypes == null) {
return !exclusive;
} else { } else {
for (ObjectType type : getSearchTypes()) { if (exclusive && searchTypes.length > 1) {
return false;
}
for (ObjectType type : searchTypes) {
if (type == searchType) { if (type == searchType) {
return true; return true;
} }