本文整理汇总了Java中org.apache.lucene.search.QueryUtils.checkEqual方法的典型用法代码示例。如果您正苦于以下问题:Java QueryUtils.checkEqual方法的具体用法?Java QueryUtils.checkEqual怎么用?Java QueryUtils.checkEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.QueryUtils
的用法示例。
在下文中一共展示了QueryUtils.checkEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquality1
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testEquality1() {
SpanQuery q1 = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
SpanQuery q2 = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
SpanQuery q3 = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "XXXXX");
SpanQuery q4 = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "XXXXX")) , "first");
SpanQuery q5 = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("xXXX", "sally")) , "first");
QueryUtils.checkEqual(q1, q2);
QueryUtils.checkUnequal(q1, q3);
QueryUtils.checkUnequal(q1, q4);
QueryUtils.checkUnequal(q1, q5);
SpanQuery qA = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
qA.setBoost(9f);
SpanQuery qB = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
QueryUtils.checkUnequal(qA, qB);
qB.setBoost(9f);
QueryUtils.checkEqual(qA, qB);
}
示例2: tryQuerySameTypes
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
void tryQuerySameTypes(String template, String numbers, String type) throws SyntaxError {
String s1 = template;
String s2 = template;
String s3 = template;
String[] numParts = numbers.split(",");
String type2 = type.replace("val1", "val2");
for (int idx = 0; s1.contains("#"); ++idx) {
String patV = "#v" + Integer.toString(idx);
String patN = "#n" + Integer.toString(idx);
s1 = s1.replace(patV, type).replace(patN, numParts[idx]);
s2 = s2.replace(patV, type).replace(patN, numParts[idx]);
s3 = s3.replace(patV, type2).replace(patN, numParts[idx]);
}
//SolrQueryRequest req1 = req( "q","*:*", "fq", s1);
Query q1 = getQuery(s1);
Query q2 = getQuery(s2);
Query q3 = getQuery(s3);
QueryUtils.checkEqual(q1, q2);
QueryUtils.checkUnequal(q1, q3);
}
示例3: testBasics
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testBasics() {
MinDocQuery query1 = new MinDocQuery(42);
MinDocQuery query2 = new MinDocQuery(42);
MinDocQuery query3 = new MinDocQuery(43);
QueryUtils.check(query1);
QueryUtils.checkEqual(query1, query2);
QueryUtils.checkUnequal(query1, query3);
}
示例4: testBasics
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testBasics() {
TermsSliceQuery query1 =
new TermsSliceQuery("field1", 1, 10);
TermsSliceQuery query2 =
new TermsSliceQuery("field1", 1, 10);
TermsSliceQuery query3 =
new TermsSliceQuery("field2", 1, 10);
TermsSliceQuery query4 =
new TermsSliceQuery("field1", 2, 10);
QueryUtils.check(query1);
QueryUtils.checkEqual(query1, query2);
QueryUtils.checkUnequal(query1, query3);
QueryUtils.checkUnequal(query1, query4);
}
示例5: testBasics
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testBasics() {
DocValuesSliceQuery query1 =
new DocValuesSliceQuery("field1", 1, 10);
DocValuesSliceQuery query2 =
new DocValuesSliceQuery("field1", 1, 10);
DocValuesSliceQuery query3 =
new DocValuesSliceQuery("field2", 1, 10);
DocValuesSliceQuery query4 =
new DocValuesSliceQuery("field1", 2, 10);
QueryUtils.check(query1);
QueryUtils.checkEqual(query1, query2);
QueryUtils.checkUnequal(query1, query3);
QueryUtils.checkUnequal(query1, query4);
}
示例6: testEqualsHashCode
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testEqualsHashCode() {
CommonTermsQuery query = new CommonTermsQuery(randomOccur(random()),
randomOccur(random()), random().nextFloat(), random().nextBoolean());
int terms = atLeast(2);
for (int i = 0; i < terms; i++) {
query.add(new Term(TestUtil.randomRealisticUnicodeString(random()),
TestUtil.randomRealisticUnicodeString(random())));
}
QueryUtils.checkHashEquals(query);
QueryUtils.checkUnequal(new CommonTermsQuery(randomOccur(random()),
randomOccur(random()), random().nextFloat(), random().nextBoolean()),
query);
{
final long seed = random().nextLong();
Random r = new Random(seed);
CommonTermsQuery left = new CommonTermsQuery(randomOccur(r),
randomOccur(r), r.nextFloat(), r.nextBoolean());
int leftTerms = atLeast(r, 2);
for (int i = 0; i < leftTerms; i++) {
left.add(new Term(TestUtil.randomRealisticUnicodeString(r), TestUtil
.randomRealisticUnicodeString(r)));
}
left.setHighFreqMinimumNumberShouldMatch(r.nextInt(4));
left.setLowFreqMinimumNumberShouldMatch(r.nextInt(4));
r = new Random(seed);
CommonTermsQuery right = new CommonTermsQuery(randomOccur(r),
randomOccur(r), r.nextFloat(), r.nextBoolean());
int rightTerms = atLeast(r, 2);
for (int i = 0; i < rightTerms; i++) {
right.add(new Term(TestUtil.randomRealisticUnicodeString(r), TestUtil
.randomRealisticUnicodeString(r)));
}
right.setHighFreqMinimumNumberShouldMatch(r.nextInt(4));
right.setLowFreqMinimumNumberShouldMatch(r.nextInt(4));
QueryUtils.checkEqual(left, right);
}
}
示例7: checkEqualParsings
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
void checkEqualParsings(String s1, String s2) throws Exception {
String fieldName = "foo";
BasicQueryFactory qf = new BasicQueryFactory(16);
Query lq1, lq2;
lq1 = QueryParser.parse(s1).makeLuceneQueryField(fieldName, qf);
lq2 = QueryParser.parse(s2).makeLuceneQueryField(fieldName, qf);
QueryUtils.checkEqual(lq1, lq2);
}
示例8: testRewrite0
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testRewrite0() throws Exception {
SpanQuery q = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
q.setBoost(8.7654321f);
SpanQuery qr = (SpanQuery) searcher.rewrite(q);
QueryUtils.checkEqual(q, qr);
Set<Term> terms = new HashSet<>();
qr.extractTerms(terms);
assertEquals(1, terms.size());
}
示例9: testRewrite2
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testRewrite2() throws Exception {
SpanQuery q1 = new SpanTermQuery(new Term("last", "smith"));
SpanQuery q2 = new SpanTermQuery(new Term("last", "jones"));
SpanQuery q = new SpanNearQuery(new SpanQuery[]
{ q1, new FieldMaskingSpanQuery(q2, "last")}, 1, true );
Query qr = searcher.rewrite(q);
QueryUtils.checkEqual(q, qr);
HashSet<Term> set = new HashSet<>();
qr.extractTerms(set);
assertEquals(2, set.size());
}
示例10: testGeodistSource
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
@Test
public void testGeodistSource() throws SyntaxError {
Query q_home = getQuery("geodist(home_ll, 45.0, 43.0)");
Query q_work = getQuery("geodist(work_ll, 45.0, 43.0)");
Query q_home2 = getQuery("geodist(home_ll, 45.0, 43.0)");
QueryUtils.checkUnequal(q_work, q_home);
QueryUtils.checkEqual(q_home, q_home2);
}
示例11: assertQueryEquals
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
/**
* NOTE: defType is not only used to pick the parser, but, if non-null it is
* also to record the parser being tested for coverage sanity checking
*
* @see QueryUtils#check
* @see QueryUtils#checkEqual
* @see #testParserCoverage
*/
protected void assertQueryEquals(final String defType,
final SolrQueryRequest req,
final String... inputs) throws Exception {
if (null != defType) qParsersTested.add(defType);
final Query[] queries = new Query[inputs.length];
try {
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req,rsp));
for (int i = 0; i < inputs.length; i++) {
queries[i] = (QParser.getParser(inputs[i], defType, req).getQuery());
}
} finally {
SolrRequestInfo.clearRequestInfo();
}
for (int i = 0; i < queries.length; i++) {
QueryUtils.check(queries[i]);
// yes starting j=0 is redundent, we're making sure every query
// is equal to itself, and that the quality checks work regardless
// of which caller/callee is used.
for (int j = 0; j < queries.length; j++) {
QueryUtils.checkEqual(queries[i], queries[j]);
}
}
}
示例12: testEqualsHashCode
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testEqualsHashCode() {
CommonTermsQuery query = new CommonTermsQuery(randomOccur(random()),
randomOccur(random()), random().nextFloat(), random().nextBoolean());
int terms = atLeast(2);
for (int i = 0; i < terms; i++) {
query.add(new Term(_TestUtil.randomRealisticUnicodeString(random()),
_TestUtil.randomRealisticUnicodeString(random())));
}
QueryUtils.checkHashEquals(query);
QueryUtils.checkUnequal(new CommonTermsQuery(randomOccur(random()),
randomOccur(random()), random().nextFloat(), random().nextBoolean()),
query);
{
final long seed = random().nextLong();
Random r = new Random(seed);
CommonTermsQuery left = new CommonTermsQuery(randomOccur(r),
randomOccur(r), r.nextFloat(), r.nextBoolean());
int leftTerms = atLeast(r, 2);
for (int i = 0; i < leftTerms; i++) {
left.add(new Term(_TestUtil.randomRealisticUnicodeString(r), _TestUtil
.randomRealisticUnicodeString(r)));
}
r = new Random(seed);
CommonTermsQuery right = new CommonTermsQuery(randomOccur(r),
randomOccur(r), r.nextFloat(), r.nextBoolean());
int rightTerms = atLeast(r, 2);
for (int i = 0; i < rightTerms; i++) {
right.add(new Term(_TestUtil.randomRealisticUnicodeString(r), _TestUtil
.randomRealisticUnicodeString(r)));
}
QueryUtils.checkEqual(left, right);
}
}
示例13: testRewrite0
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testRewrite0() throws Exception {
SpanQuery q = new FieldMaskingSpanQuery
(new SpanTermQuery(new Term("last", "sally")) , "first");
q.setBoost(8.7654321f);
SpanQuery qr = (SpanQuery) searcher.rewrite(q);
QueryUtils.checkEqual(q, qr);
Set<Term> terms = new HashSet<Term>();
qr.extractTerms(terms);
assertEquals(1, terms.size());
}
示例14: testRewrite2
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
public void testRewrite2() throws Exception {
SpanQuery q1 = new SpanTermQuery(new Term("last", "smith"));
SpanQuery q2 = new SpanTermQuery(new Term("last", "jones"));
SpanQuery q = new SpanNearQuery(new SpanQuery[]
{ q1, new FieldMaskingSpanQuery(q2, "last")}, 1, true );
Query qr = searcher.rewrite(q);
QueryUtils.checkEqual(q, qr);
HashSet<Term> set = new HashSet<Term>();
qr.extractTerms(set);
assertEquals(2, set.size());
}
示例15: assertQueryEquals
import org.apache.lucene.search.QueryUtils; //导入方法依赖的package包/类
private void assertQueryEquals(final String defType,
final SolrQueryRequest req,
final String... inputs) throws Exception {
if (null != defType) qParsersTested.add(defType);
final Query[] queries = new Query[inputs.length];
try {
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req,rsp));
for (int i = 0; i < inputs.length; i++) {
queries[i] = (QParser.getParser(inputs[i], defType, req).getQuery());
}
for (int i = 0; i < queries.length; i++) {
QueryUtils.check(queries[i]);
// yes starting j=0 is redundent, we're making sure every query
// is equal to itself, and that the quality checks work regardless
// of which caller/callee is used.
for (int j = 0; j < queries.length; j++) {
QueryUtils.checkEqual(queries[i], queries[j]);
}
}
} finally {
SolrRequestInfo.clearRequestInfo();
}
}