mirror of https://github.com/apache/lucene.git
LUCENE-6459: carry forward changes from backport
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682172 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b74b925950
commit
cdc666122b
|
@ -77,7 +77,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 7));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 6));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 5));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -114,7 +115,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new SuggestField("suggest_field", "abd", 4));
|
||||
document.add(new SuggestField("suggest_field", "The Foo Fighters", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abcdd", 5));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -144,7 +146,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -204,7 +207,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
|
||||
document.add(new ContextSuggestField("suggest_field", null, "suggestion_no_ctx", 4));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -234,7 +238,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.emptyList(), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", null, "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -267,7 +272,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
|
||||
document.add(new ContextSuggestField("suggest_field", Arrays.asList("type1", "type2", "type3"), "suggestion", 4));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -304,7 +310,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -340,7 +347,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -373,7 +381,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -405,7 +414,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 7));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 6));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 5));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -442,7 +452,8 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ public class TestContextSuggestField extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("context_suggest_field", Collections.singletonList("type2"), "suggestion2", 3));
|
||||
document.add(new ContextSuggestField("context_suggest_field", Collections.singletonList("type3"), "suggestion3", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "suggestion4", 1));
|
||||
document.add(new ContextSuggestField("context_suggest_field", Collections.singletonList("type4"), "suggestion4", 1));
|
||||
iw.addDocument(document);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TestFuzzyCompletionQuery extends LuceneTestCase {
|
|||
document.add(new SuggestField("suggest_field", "suaggestion", 4));
|
||||
document.add(new SuggestField("suggest_field", "ssuggestion", 1));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "sugfoo", 1));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -91,7 +91,8 @@ public class TestFuzzyCompletionQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "sudggestion", 1));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "sugdgestion", 1));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggdestion", 1));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
@ -126,7 +127,8 @@ public class TestFuzzyCompletionQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "sudggestion", 1));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "sugdgestion", 1));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggdestion", 1));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
|
|
@ -72,7 +72,8 @@ public class TestPrefixCompletionQuery extends LuceneTestCase {
|
|||
document.add(new SuggestField("suggest_field", "abd", 4));
|
||||
document.add(new SuggestField("suggest_field", "The Foo Fighters", 2));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abcdd", 5));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -95,12 +96,11 @@ public class TestPrefixCompletionQuery extends LuceneTestCase {
|
|||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
document.add(new IntField("filter_int_fld", i, Field.Store.NO));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
|
@ -151,12 +151,12 @@ public class TestPrefixCompletionQuery extends LuceneTestCase {
|
|||
document.add(new SuggestField("suggest_field", "apples", 3));
|
||||
iw.addDocument(document);
|
||||
|
||||
document.clear();
|
||||
document = new Document();
|
||||
document.add(new IntField("filter_int_fld", 10, Field.Store.NO));
|
||||
document.add(new SuggestField("suggest_field", "applle", 4));
|
||||
iw.addDocument(document);
|
||||
|
||||
document.clear();
|
||||
document = new Document();
|
||||
document.add(new IntField("filter_int_fld", 4, Field.Store.NO));
|
||||
document.add(new SuggestField("suggest_field", "apple", 5));
|
||||
iw.addDocument(document);
|
||||
|
|
|
@ -58,7 +58,8 @@ public class TestRegexCompletionQuery extends LuceneTestCase {
|
|||
document.add(new SuggestField("suggest_field", "asuggestion", 2));
|
||||
document.add(new SuggestField("suggest_field", "ssuggestion", 3));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "wsuggestion", 4));
|
||||
iw.addDocument(document);
|
||||
|
||||
|
@ -87,7 +88,8 @@ public class TestRegexCompletionQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "sudggestion", 4));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "sugdgestion", 3));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggdestion", 2));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
@ -121,7 +123,8 @@ public class TestRegexCompletionQuery extends LuceneTestCase {
|
|||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type2"), "sudggestion", 4));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type3"), "sugdgestion", 3));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
document = new Document();
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggdestion", 2));
|
||||
document.add(new ContextSuggestField("suggest_field", Collections.singletonList("type4"), "suggestion", 1));
|
||||
iw.addDocument(document);
|
||||
|
|
|
@ -139,7 +139,7 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
public void testDupSuggestFieldValues() throws Exception {
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(300));
|
||||
final int num = Math.min(1000, atLeast(300));
|
||||
int[] weights = new int[num];
|
||||
for(int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
|
@ -176,10 +176,10 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
|
||||
Document document = new Document();
|
||||
int numLive = 0;
|
||||
List<Entry> expectedEntries = new ArrayList<>();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, num - i));
|
||||
if (i % 2 == 0) {
|
||||
document.add(newStringField("str_field", "delete", Field.Store.YES));
|
||||
|
@ -189,7 +189,6 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
document.add(newStringField("str_field", "no_delete", Field.Store.YES));
|
||||
}
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
|
@ -213,12 +212,11 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
document.add(newStringField("str_fld", "deleted", Field.Store.NO));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
|
@ -243,12 +241,11 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
// using IndexWriter instead of RandomIndexWriter
|
||||
IndexWriter iw = new IndexWriter(dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
document.add(newStringField("delete", "delete", Field.Store.NO));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
|
@ -273,12 +270,11 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
// using IndexWriter instead of RandomIndexWriter
|
||||
IndexWriter iw = new IndexWriter(dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
for (int i = 1; i <= num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
document.add(new IntField("weight_fld", i, Field.Store.YES));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
|
@ -306,7 +302,7 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
document.add(new SuggestField("sug_field_1", "apple", 4));
|
||||
document.add(new SuggestField("sug_field_2", "april", 3));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
document = new Document();
|
||||
document.add(new SuggestField("sug_field_1", "aples", 3));
|
||||
document.add(new SuggestField("sug_field_2", "apartment", 2));
|
||||
iw.addDocument(document);
|
||||
|
@ -340,16 +336,15 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
|
||||
// have segments of 4 documents
|
||||
// with descending suggestion weights
|
||||
// suggest should early terminate for
|
||||
// segments with docs having lower suggestion weights
|
||||
for (int i = num; i > 0; i--) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
if (i % 4 == 0) {
|
||||
iw.commit();
|
||||
}
|
||||
|
@ -369,18 +364,17 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
Document document = new Document();
|
||||
List<Entry> entries = new ArrayList<>();
|
||||
|
||||
// ensure at least some segments have no suggest field
|
||||
for (int i = num; i > 0; i--) {
|
||||
Document document = new Document();
|
||||
if (random().nextInt(4) == 1) {
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, i));
|
||||
entries.add(new Entry("abc_" + i, i));
|
||||
}
|
||||
document.add(new IntField("weight_fld", i, Field.Store.YES));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
if (usually()) {
|
||||
iw.commit();
|
||||
}
|
||||
|
@ -401,13 +395,12 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
|
||||
Document document = new Document();
|
||||
int num = Math.min(1000, atLeast(10));
|
||||
for (int i = 0; i < num; i++) {
|
||||
Document document = new Document();
|
||||
document.add(new SuggestField("suggest_field", "abc_" + i, num));
|
||||
document.add(new IntField("int_field", i, Field.Store.YES));
|
||||
iw.addDocument(document);
|
||||
document.clear();
|
||||
|
||||
if (random().nextBoolean()) {
|
||||
iw.commit();
|
||||
|
@ -630,7 +623,7 @@ public class TestSuggestField extends LuceneTestCase {
|
|||
return iwcWithSuggestField(analyzer, asSet(suggestFields));
|
||||
}
|
||||
|
||||
static IndexWriterConfig iwcWithSuggestField(Analyzer analyzer, Set<String> suggestFields) {
|
||||
static IndexWriterConfig iwcWithSuggestField(Analyzer analyzer, final Set<String> suggestFields) {
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(random(), analyzer);
|
||||
iwc.setMergePolicy(newLogMergePolicy());
|
||||
Codec filterCodec = new Lucene50Codec() {
|
||||
|
|
Loading…
Reference in New Issue