Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search equivalence tests. #14036

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public static void beforeClass() throws Exception {

reader = iw.getReader();
s1 = newSearcher(reader);
// Disable the query cache, which converts two-phase iterators to normal iterators, while we
// want to make sure two-phase iterators are exercised.
s1.setQueryCache(null);
s2 = newSearcher(reader);
s2.setQueryCache(null);
iw.close();
}

Expand All @@ -114,7 +118,6 @@ public static void afterClass() throws Exception {
* tokenization can be assumed to be on whitespace.
*/
static String randomFieldContents() {
// TODO: zipf-like distribution
StringBuilder sb = new StringBuilder();
int numTerms = random().nextInt(15);
for (int i = 0; i < numTerms; i++) {
Expand All @@ -128,7 +131,13 @@ static String randomFieldContents() {

/** returns random character (a-z) */
static char randomChar() {
return (char) TestUtil.nextInt(random(), 'a', 'z');
char c = (char) TestUtil.nextInt(random(), 'a', 'z');
if (random().nextBoolean()) {
// bias towards earlier chars, so that chars have a ~ zipfian distribution with earlier chars
// having a higher frequency
c = (char) TestUtil.nextInt(random(), 'a', c);
}
return c;
}

/** returns a term suitable for searching. terms are single characters in lowercase (a-z) */
Expand Down
Loading