mirror of https://github.com/apache/druid.git
Fixes #761
This commit is contained in:
parent
7cfe86b7bc
commit
b57ac513bd
|
@ -162,13 +162,16 @@ public class SearchQueryRunner implements QueryRunner<Result<SearchResultValue>>
|
|||
while (!cursor.isDone()) {
|
||||
for (Map.Entry<String, DimensionSelector> entry : dimSelectors.entrySet()) {
|
||||
final DimensionSelector selector = entry.getValue();
|
||||
final IndexedInts vals = selector.getRow();
|
||||
for (int i = 0; i < vals.size(); ++i) {
|
||||
final String dimVal = selector.lookupName(vals.get(i));
|
||||
if (searchQuerySpec.accept(dimVal)) {
|
||||
set.add(new SearchHit(entry.getKey(), dimVal));
|
||||
if (set.size() >= limit) {
|
||||
return set;
|
||||
|
||||
if (selector != null) {
|
||||
final IndexedInts vals = selector.getRow();
|
||||
for (int i = 0; i < vals.size(); ++i) {
|
||||
final String dimVal = selector.lookupName(vals.get(i));
|
||||
if (searchQuerySpec.accept(dimVal)) {
|
||||
set.add(new SearchHit(entry.getKey(), dimVal));
|
||||
if (set.size() >= limit) {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,10 +115,10 @@ public class SearchQueryRunnerTest
|
|||
Map<String, Set<String>> expectedResults = new HashMap<String, Set<String>>();
|
||||
expectedResults.put(
|
||||
QueryRunnerTestHelper.qualityDimension, new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"automotive", "mezzanine", "travel", "health", "entertainment"
|
||||
Arrays.asList(
|
||||
"automotive", "mezzanine", "travel", "health", "entertainment"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
checkSearchQuery(
|
||||
|
@ -366,6 +366,24 @@ public class SearchQueryRunnerTest
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchNonExistingDimension()
|
||||
{
|
||||
Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
checkSearchQuery(
|
||||
Druids.newSearchQueryBuilder()
|
||||
.dataSource(QueryRunnerTestHelper.dataSource)
|
||||
.granularity(QueryRunnerTestHelper.allGran)
|
||||
.intervals(QueryRunnerTestHelper.fullOnInterval)
|
||||
.dimensions("does_not_exist")
|
||||
.query("a")
|
||||
.build(),
|
||||
expectedResults
|
||||
);
|
||||
}
|
||||
|
||||
private void checkSearchQuery(SearchQuery searchQuery, Map<String, Set<String>> expectedResults)
|
||||
{
|
||||
Iterable<Result<SearchResultValue>> results = Sequences.toList(
|
||||
|
|
Loading…
Reference in New Issue