/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Term position unit test.
*
*
* @version $Revision: 1161586 $
*/
return new TokenStream() {
private int i = 0;
public boolean incrementToken() {
return false;
i++;
return true;
}
public void reset() throws IOException {
super.reset();
this.i = 0;
}
};
}
};
writer.addDocument(d);
// first token should be at position 0
// second token should be at position 2
PhraseQuery q;
q = new PhraseQuery();
// same as previous, just specify positions explicitely.
q = new PhraseQuery();
// specifying correct positions should find the phrase.
q = new PhraseQuery();
q = new PhraseQuery();
q = new PhraseQuery();
// phrase query would find it when correct positions are specified.
q = new PhraseQuery();
// phrase query should fail for non existing searched term
// even if there exist another searched terms in the same searched position.
q = new PhraseQuery();
// multi-phrase query should succed for non existing searched term
// because there exist another searched terms in the same searched position.
q = new PhraseQuery();
q = new PhraseQuery();
q = new PhraseQuery();
q = new PhraseQuery();
// should not find "1 2" because there is a gap of 1 in the index
new StopWhitespaceAnalyzer(false));
// omitted stop word cannot help because stop filter swallows the increments.
// query parser alone won't help, because stop filter swallows the increments.
qp.setEnablePositionIncrements(true);
// stop filter alone won't help, because query parser swallows the increments.
qp.setEnablePositionIncrements(false);
// when both qp qnd stopFilter propagate increments, we should find the doc.
new StopWhitespaceAnalyzer(true));
qp.setEnablePositionIncrements(true);
}
boolean enablePositionIncrements;
}
}
}
new StringReader("a a b c d e a f g h i j a b k k")));
int count = 0;
// "a" occurs 4 times
int expected = 0;
// only one doc has "a"
count = 0;
boolean sawZero = false;
//System.out.println("\ngetPayloadSpans test");
//System.out.println(pspans.doc() + " - " + pspans.start() + " - "+ pspans.end());
}
//System.out.println("\ngetSpans test");
count = 0;
sawZero = false;
count++;
//System.out.println(spans.doc() + " - " + spans.start() + " - " + spans.end());
}
//System.out.println("\nPayloadSpanUtil test");
sawZero = false;
//System.out.println(s);
}
}
}
}
}
int pos;
int i;
super(input);
pos = 0;
i = 0;
}
if (input.incrementToken()) {
int posIncr;
if (i % 2 == 1) {
posIncr = 1;
} else {
posIncr = 0;
}
if (TestPositionIncrement.VERBOSE) {
}
i++;
return true;
} else {
return false;
}
}
}