Skip to content

Commit

Permalink
SOLR-15531: Cross-collection join fixed to ignore documents that do n…
Browse files Browse the repository at this point in the history
…ot contain value in from field
  • Loading branch information
hossman committed Jul 28, 2021
1 parent 5e8857c commit e7e80b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ Bug Fixes

* SOLR-15531: SignificantTerms streaming function should not fail on empty collections (Benedikt Arnold via Mike Drob)

* SOLR-15531: Cross-collection join fixed to ignore documents that do not contain value in "from" field (hossman)

Other Changes
---------------------
(No changes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ private DocSet getDocSet() throws IOException {
}

Object value = tuple.get(fromField);
collector.collect(value);
if (null != value) {
collector.collect(value);
}
}
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

Expand Down Expand Up @@ -68,8 +69,6 @@ public static void setupIndexes(boolean routeByKey) throws IOException, SolrServ

buildIndexes(routeByKey);

assertResultCount("products", "*:*", NUM_PRODUCTS, true);
assertResultCount("parts", "*:*", NUM_PRODUCTS * 10 / 4, true);
}

private static void clearCollection(String collection) throws IOException, SolrServerException {
Expand Down Expand Up @@ -104,11 +103,20 @@ private static void buildIndexes(boolean routeByKey) throws IOException, SolrSer
}
}

// some extra docs in each collection (not counded in NUM_PRODUCTS) that should drop out of the joins because they don't have the join key
productDocs.add(new SolrInputDocument("id", buildId(NUM_PRODUCTS+10, String.valueOf(NUM_PRODUCTS+10), routeByKey), "size_s", "M"));
partDocs.add(new SolrInputDocument("id", buildId(NUM_PRODUCTS+10, String.valueOf(NUM_PRODUCTS+10), routeByKey)));

Collections.shuffle(productDocs, random());
Collections.shuffle(partDocs, random());

indexDocs("products", productDocs);
cluster.getSolrClient().commit("products");
assertResultCount("products", "*:*", 1 + NUM_PRODUCTS, true);

indexDocs("parts", partDocs);
cluster.getSolrClient().commit("parts");
assertResultCount("parts", "*:*", 1 + (NUM_PRODUCTS * 10 / 4), true);
}

private static String buildId(int productId, String id, boolean routeByKey) {
Expand Down

0 comments on commit e7e80b1

Please sign in to comment.