Skip to content

Commit

Permalink
increase limit to improve de-duplication count (#301)
Browse files Browse the repository at this point in the history
* increase limit to improve dedupplication count

* fix via comment from @lonvia
  • Loading branch information
karussell committed Jan 29, 2018
1 parent 5f8d9a7 commit aeb33f9
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ public AbstractPhotonRequestHandler(ElasticsearchSearcher elasticsearchSearcher)
@Override
public List<JSONObject> handle(R photonRequest) {
TagFilterQueryBuilder queryBuilder = buildQuery(photonRequest);
Integer limit = photonRequest.getLimit();
SearchResponse results = elasticsearchSearcher.search(queryBuilder.buildQuery(), limit);
// for the case of deduplication we need a bit more results, #300
int limit = photonRequest.getLimit();
int extLimit = limit > 1 ? (int) Math.round(photonRequest.getLimit() * 1.5) : 1;
SearchResponse results = elasticsearchSearcher.search(queryBuilder.buildQuery(), extLimit);
if (results.getHits().getTotalHits() == 0) {
results = elasticsearchSearcher.search(queryBuilder.withLenientMatch().buildQuery(), limit);
results = elasticsearchSearcher.search(queryBuilder.withLenientMatch().buildQuery(), extLimit);
}
List<JSONObject> resultJsonObjects = new ConvertToJson(photonRequest.getLanguage()).convert(results);
StreetDupesRemover streetDupesRemover = new StreetDupesRemover(photonRequest.getLanguage());
Expand Down

0 comments on commit aeb33f9

Please sign in to comment.