only field prefixes returned instead of full values
When using autocomplete to return field values I missed, that autocomplete had the feature that cut values at dots. So instead of returning full field values only the prefix up to the first dot was returned. Fixed by making the cut-at-dot feature optional.
This commit is contained in:
@@ -18,6 +18,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
|
||||
import org.lucares.pdb.datastore.Proposal;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
@@ -214,14 +215,14 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
// TODO get date range from UI
|
||||
final DateTimeRange dateRange = DateTimeRange.max();
|
||||
final int zeroBasedCaretIndex = caretIndex - 1;
|
||||
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex);
|
||||
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex,
|
||||
ResultMode.CUT_AT_DOT);
|
||||
|
||||
final AutocompleteResponse result = new AutocompleteResponse();
|
||||
|
||||
final List<Proposal> proposals = db.autocomplete(q);
|
||||
final List<Proposal> nonEmptyProposals = CollectionUtils.filter(proposals, p -> p.hasResults());
|
||||
|
||||
final List<AutocompleteProposal> autocompleteProposals = toAutocompleteProposals(nonEmptyProposals);
|
||||
final List<AutocompleteProposal> autocompleteProposals = toAutocompleteProposals(proposals);
|
||||
Collections.sort(autocompleteProposals, new AutocompleteProposalByValue());
|
||||
|
||||
result.setProposals(autocompleteProposals);
|
||||
@@ -252,14 +253,18 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
SortedSet<String> fields(@PathVariable(name = "fieldName") final String fieldName,
|
||||
@RequestParam(name = "query") final String query) {
|
||||
|
||||
final String q = String.format("(%s) and %s=", query, fieldName);
|
||||
final int caretIndex = q.length() + 1; // the autocomplete methods needs a 1-based index
|
||||
// TODO get date range from UI
|
||||
final String q = query.isBlank()//
|
||||
? String.format("%s = ", fieldName)//
|
||||
: String.format("(%s) and %s=", query, fieldName);
|
||||
final int zeroBasedCaretIndex = q.length();
|
||||
final DateTimeRange dateRange = DateTimeRange.max();
|
||||
final QueryWithCaretMarker autocompleteQuery = new QueryWithCaretMarker(q, dateRange, zeroBasedCaretIndex,
|
||||
ResultMode.FULL_VALUES);
|
||||
|
||||
final AutocompleteResponse autocompleteResponse = this.autocomplete(q, caretIndex);
|
||||
final List<AutocompleteProposal> proposals = autocompleteResponse.getProposals();
|
||||
final List<Proposal> result = db.autocomplete(autocompleteQuery);
|
||||
|
||||
final SortedSet<String> fields = CollectionUtils.map(proposals, new TreeSet<>(),
|
||||
AutocompleteProposal::getValue);
|
||||
final SortedSet<String> fields = CollectionUtils.map(result, new TreeSet<>(), Proposal::getProposedTag);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user