Fix #9147
This commit is contained in:
parent
45095ff454
commit
b7c42d47b0
2 changed files with 28 additions and 17 deletions
|
@ -140,10 +140,16 @@ public class SearchCoreFactory {
|
||||||
|
|
||||||
protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
|
protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
subSearchApiOrPublish(phrase, resultMatcher, res, api, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api,
|
||||||
|
boolean publish)
|
||||||
|
throws IOException {
|
||||||
phrase.countUnknownWordsMatchMainResult(res);
|
phrase.countUnknownWordsMatchMainResult(res);
|
||||||
boolean firstUnknownWordMatches = res.firstUnknownWordMatches;
|
boolean firstUnknownWordMatches = res.firstUnknownWordMatches;
|
||||||
List<String> leftUnknownSearchWords = new ArrayList<String>(phrase.getUnknownSearchWords());
|
List<String> leftUnknownSearchWords = new ArrayList<String>(phrase.getUnknownSearchWords());
|
||||||
if(res.otherWordsMatch != null) {
|
if (res.otherWordsMatch != null) {
|
||||||
leftUnknownSearchWords.removeAll(res.otherWordsMatch);
|
leftUnknownSearchWords.removeAll(res.otherWordsMatch);
|
||||||
}
|
}
|
||||||
SearchResult newParentSearchResult = null;
|
SearchResult newParentSearchResult = null;
|
||||||
|
@ -187,19 +193,23 @@ public class SearchCoreFactory {
|
||||||
leftUnknownSearchWords.add(0, phrase.getFirstUnknownSearchWord());
|
leftUnknownSearchWords.add(0, phrase.getFirstUnknownSearchWord());
|
||||||
}
|
}
|
||||||
// publish result to set parentSearchResult before search
|
// publish result to set parentSearchResult before search
|
||||||
if(newParentSearchResult != null) {
|
if (publish) {
|
||||||
SearchResult prev = resultMatcher.setParentSearchResult(newParentSearchResult);
|
if (newParentSearchResult != null) {
|
||||||
resultMatcher.publish(res);
|
SearchResult prev = resultMatcher.setParentSearchResult(newParentSearchResult);
|
||||||
resultMatcher.setParentSearchResult(prev);
|
resultMatcher.publish(res);
|
||||||
} else {
|
resultMatcher.setParentSearchResult(prev);
|
||||||
resultMatcher.publish(res);
|
} else {
|
||||||
|
resultMatcher.publish(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) {
|
if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) {
|
||||||
SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, phrase.isLastUnknownSearchWordComplete());
|
SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, phrase.isLastUnknownSearchWordComplete());
|
||||||
SearchResult prev = resultMatcher.setParentSearchResult(res);
|
SearchResult prev = resultMatcher.setParentSearchResult(publish ? res :
|
||||||
|
resultMatcher.getParentSearchResult());
|
||||||
api.search(nphrase, resultMatcher);
|
api.search(nphrase, resultMatcher);
|
||||||
resultMatcher.setParentSearchResult(prev);
|
resultMatcher.setParentSearchResult(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1103,11 +1113,11 @@ public class SearchCoreFactory {
|
||||||
|
|
||||||
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
||||||
res.otherNames = object.getAllNames(true);
|
res.otherNames = object.getAllNames(true);
|
||||||
|
boolean pub = true;
|
||||||
if (object.getName().startsWith("<")) {
|
if (object.getName().startsWith("<")) {
|
||||||
// streets related to city
|
// streets related to city
|
||||||
continue;
|
pub = false;
|
||||||
}
|
} else if (phrase.isUnknownSearchWordPresent()
|
||||||
if (phrase.isUnknownSearchWordPresent()
|
|
||||||
&& !(nm.matches(res.localeName) || nm.matches(res.otherNames))) {
|
&& !(nm.matches(res.localeName) || nm.matches(res.otherNames))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1129,7 @@ public class SearchCoreFactory {
|
||||||
res.priority = SEARCH_STREET_BY_CITY_PRIORITY;
|
res.priority = SEARCH_STREET_BY_CITY_PRIORITY;
|
||||||
//res.priorityDistance = 1;
|
//res.priorityDistance = 1;
|
||||||
res.objectType = ObjectType.STREET;
|
res.objectType = ObjectType.STREET;
|
||||||
subSearchApiOrPublish(phrase, resultMatcher, res, streetsAPI);
|
subSearchApiOrPublish(phrase, resultMatcher, res, streetsAPI, pub);
|
||||||
if (limit++ > LIMIT) {
|
if (limit++ > LIMIT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1227,8 +1237,8 @@ public class SearchCoreFactory {
|
||||||
res.file = file;
|
res.file = file;
|
||||||
res.priority = priority;
|
res.priority = priority;
|
||||||
res.priorityDistance = 0;
|
res.priorityDistance = 0;
|
||||||
// TOOO phrase.countUnknownWordsMatchMainResult(res);
|
|
||||||
res.firstUnknownWordMatches = startMatch.matches(res.localeName);
|
res.firstUnknownWordMatches = startMatch.matches(res.localeName);
|
||||||
|
// phrase.countUnknownWordsMatchMainResult(res); // same as above
|
||||||
res.relatedObject = s;
|
res.relatedObject = s;
|
||||||
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
res.localeRelatedObjectName = s.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
||||||
res.objectType = ObjectType.HOUSE;
|
res.objectType = ObjectType.HOUSE;
|
||||||
|
@ -1239,6 +1249,7 @@ public class SearchCoreFactory {
|
||||||
res.location = b.getLocation();
|
res.location = b.getLocation();
|
||||||
}
|
}
|
||||||
res.preferredZoom = 17;
|
res.preferredZoom = 17;
|
||||||
|
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
}
|
}
|
||||||
String streetIntersection = phrase.getUnknownWordToSearch();
|
String streetIntersection = phrase.getUnknownWordToSearch();
|
||||||
|
@ -1252,7 +1263,6 @@ public class SearchCoreFactory {
|
||||||
|| !phrase.isSearchTypeAllowed(ObjectType.STREET_INTERSECTION)) {
|
|| !phrase.isSearchTypeAllowed(ObjectType.STREET_INTERSECTION)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// TOOO phrase.countUnknownWordsMatchMainResult(res);
|
|
||||||
res.otherNames = street.getAllNames(true);
|
res.otherNames = street.getAllNames(true);
|
||||||
res.localeName = street.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
res.localeName = street.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
||||||
res.object = street;
|
res.object = street;
|
||||||
|
@ -1264,6 +1274,7 @@ public class SearchCoreFactory {
|
||||||
res.objectType = ObjectType.STREET_INTERSECTION;
|
res.objectType = ObjectType.STREET_INTERSECTION;
|
||||||
res.location = street.getLocation();
|
res.location = street.getLocation();
|
||||||
res.preferredZoom = 16;
|
res.preferredZoom = 16;
|
||||||
|
phrase.countUnknownWordsMatchMainResult(res);
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
"phrase": "Calle de las eras 5, Navacerrada",
|
"phrase": "Calle de las eras 5, Navacerrada",
|
||||||
"results": [
|
"results": [
|
||||||
"5, Calle de las Eras (Uranización Los Corales), Navacerrada [[6, HOUSE, 0.043, 70.17 km]]",
|
"5, Calle de las Eras (Uranización Los Corales), Navacerrada [[6, HOUSE, 0.043, 70.17 km]]",
|
||||||
"Calle de las Eras (Uranización Los Corales), Navacerrada [[5, STREET, 0.310, 70.15 km]]"
|
"Calle de las Eras (Uranización Los Corales), Navacerrada [[5, STREET, 0.310, 70.15 km]]",
|
||||||
|
"Calle del Sotillo (Uranización Los Corales), Pasaje de las Eras (Uranización Los Corales), Navacerrada [[5, STREET_INTERSECTION, 0.043, 70.23 km]]"
|
||||||
],
|
],
|
||||||
"extra-results": [
|
"extra-results": [
|
||||||
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes [[4, HOUSE, 0.430, 60.50 km]]",
|
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes [[4, HOUSE, 0.430, 60.50 km]]",
|
||||||
|
@ -31,8 +32,7 @@
|
||||||
"Calle de las Cruces (Residencial Sanabria), Navacerrada [[4, STREET, 0.310, 70.14 km]]",
|
"Calle de las Cruces (Residencial Sanabria), Navacerrada [[4, STREET, 0.310, 70.14 km]]",
|
||||||
"Calle de las Escuelas, Navacerrada [[4, STREET, 0.310, 70.17 km]]",
|
"Calle de las Escuelas, Navacerrada [[4, STREET, 0.310, 70.17 km]]",
|
||||||
"Calle de las Huertas (Residencial Sanabria), Navacerrada [[4, STREET, 0.310, 70.18 km]]",
|
"Calle de las Huertas (Residencial Sanabria), Navacerrada [[4, STREET, 0.310, 70.18 km]]",
|
||||||
"Calle de la Virgen de las Nieves, Puerto de Navacerrada [[4, STREET, 0.310, 74.59 km]]",
|
"Calle de la Virgen de las Nieves, Puerto de Navacerrada [[4, STREET, 0.310, 74.59 km]]"
|
||||||
"Calle del Sotillo (Uranización Los Corales), Pasaje de las Eras (Uranización Los Corales), Navacerrada [[4, STREET_INTERSECTION, 0.043, 70.23 km]]"
|
|
||||||
],
|
],
|
||||||
"amenities": [
|
"amenities": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue