Skip to content

Commit

Permalink
Issue 514: Improve logic around isEmpty()/!isEmpty() in query.
Browse files Browse the repository at this point in the history
If the field is not empty but the value is empty, then the wildcard should be used.
The entire "query" string can even be removed.
  • Loading branch information
kaladay committed Feb 7, 2023
1 parent a3cabab commit 3d4bccc
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/main/java/edu/tamu/sage/service/SolrDiscoveryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,9 @@ public DiscoveryContext buildDiscoveryContext(DiscoveryView discoveryView, Strin
});
}

String query = "";
if (search.getField().isEmpty() && search.getValue().isEmpty()) {
query = "*";
}
else {
query = search.getValue();
}

SolrQuery solrQuery = new SolrQuery(query);
SolrQuery solrQuery = new SolrQuery(StringUtils.isEmpty(search.getValue()) ? "*" : search.getValue());

if (!search.getField().isEmpty()) {
if (StringUtils.isNotEmpty(search.getField())) {
solrQuery.add("df", search.getField());
}

Expand Down

0 comments on commit 3d4bccc

Please sign in to comment.