mirror of https://github.com/apache/druid.git
Merge pull request #816 from metamx/fix-search
fix search with same value in multiple columns
This commit is contained in:
commit
8045d0309f
|
@ -41,7 +41,11 @@ public class LexicographicSearchSortSpec implements SearchSortSpec
|
|||
@Override
|
||||
public int compare(SearchHit searchHit, SearchHit searchHit1)
|
||||
{
|
||||
return searchHit.getValue().compareTo(searchHit1.getValue());
|
||||
int retVal = searchHit.getValue().compareTo(searchHit1.getValue());
|
||||
if (retVal == 0) {
|
||||
retVal = searchHit.getDimension().compareTo(searchHit1.getDimension());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -87,12 +87,35 @@ public class SearchQueryRunnerTest
|
|||
QueryRunnerTestHelper.qualityDimension,
|
||||
Sets.newHashSet("automotive", "mezzanine", "travel", "health", "entertainment")
|
||||
);
|
||||
expectedResults.put(QueryRunnerTestHelper.providerDimension.toLowerCase(), Sets.newHashSet("total_market"));
|
||||
expectedResults.put(QueryRunnerTestHelper.providerDimension, Sets.newHashSet("total_market"));
|
||||
expectedResults.put(QueryRunnerTestHelper.placementishDimension, Sets.newHashSet("a"));
|
||||
|
||||
checkSearchQuery(searchQuery, expectedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchSameValueInMultiDims()
|
||||
{
|
||||
SearchQuery searchQuery = Druids.newSearchQueryBuilder()
|
||||
.dataSource(QueryRunnerTestHelper.dataSource)
|
||||
.granularity(QueryRunnerTestHelper.allGran)
|
||||
.intervals(QueryRunnerTestHelper.fullOnInterval)
|
||||
.dimensions(
|
||||
Arrays.asList(
|
||||
QueryRunnerTestHelper.placementDimension,
|
||||
QueryRunnerTestHelper.placementishDimension
|
||||
)
|
||||
)
|
||||
.query("e")
|
||||
.build();
|
||||
|
||||
Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
expectedResults.put(QueryRunnerTestHelper.placementDimension, Sets.newHashSet("preferred"));
|
||||
expectedResults.put(QueryRunnerTestHelper.placementishDimension, Sets.newHashSet("e", "preferred"));
|
||||
|
||||
checkSearchQuery(searchQuery, expectedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFragmentSearch()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue