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:
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.QueryConstants;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
|
||||
import org.lucares.pdb.datastore.Proposal;
|
||||
import org.lucares.pdb.datastore.internal.QueryCompletionIndex;
|
||||
import org.lucares.utils.CollectionUtils;
|
||||
@@ -51,10 +52,12 @@ public class NewProposerParser implements QueryConstants {
|
||||
proposals = foundProposals;
|
||||
}
|
||||
}
|
||||
final List<Proposal> nonEmptyProposals = CollectionUtils.filter(proposals, p -> p.hasResults());
|
||||
|
||||
METRICS_LOGGER_PROPOSE.debug("compute proposals took {}ms for query '{}' ",
|
||||
(System.nanoTime() - start) / 1_000_000.0, query);
|
||||
|
||||
return proposals;
|
||||
return nonEmptyProposals;
|
||||
}
|
||||
|
||||
private List<Proposal> proposalsForNonValues(final QueryWithCaretMarker query) {
|
||||
@@ -167,10 +170,11 @@ public class NewProposerParser implements QueryConstants {
|
||||
final SortedSet<String> candidateValues = normalizedExpression
|
||||
.visit(new FindValuesForQueryCompletion(query.getDateRange(), queryCompletionIndex));
|
||||
|
||||
final SortedSet<String> candidateValuesCutAtDots = cutAtDots(candidateValues, queryWithCaretMarker);
|
||||
final SortedSet<String> sortedAndPreparedCandidateValues = resultFilter(query.getResultMode(),
|
||||
candidateValues, queryWithCaretMarker);
|
||||
|
||||
// translate the candidate values to proposals
|
||||
final List<Proposal> proposals = generateProposals(queryWithCaretMarker, candidateValuesCutAtDots);
|
||||
final List<Proposal> proposals = generateProposals(queryWithCaretMarker, sortedAndPreparedCandidateValues);
|
||||
|
||||
return proposals;
|
||||
} catch (final SyntaxException e) {
|
||||
@@ -180,6 +184,18 @@ public class NewProposerParser implements QueryConstants {
|
||||
}
|
||||
}
|
||||
|
||||
private SortedSet<String> resultFilter(final ResultMode resultMode, final SortedSet<String> candidateValues,
|
||||
final String queryWithCaretMarker) {
|
||||
switch (resultMode) {
|
||||
case CUT_AT_DOT:
|
||||
return cutAtDots(candidateValues, queryWithCaretMarker);
|
||||
case FULL_VALUES:
|
||||
return candidateValues;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected value: " + resultMode);
|
||||
}
|
||||
}
|
||||
|
||||
private SortedSet<String> cutAtDots(final SortedSet<String> candidateValues, final String queryWithCaretMarker) {
|
||||
final CandidateGrouper grouper = new CandidateGrouper();
|
||||
return grouper.group(candidateValues, queryWithCaretMarker);
|
||||
|
||||
Reference in New Issue
Block a user