List of usage examples for org.apache.lucene.search QueryUtils check
public static void check(Query q)
From source file:com.sindicetech.siren.search.spans.TestNodeSpansBasics.java
License:Open Source License
@Test public void testSpanNearExact() throws Exception { this.addDocuments(this.generateDocuments(500)); NodeSpanQuery term1 = new NodeSpanQuery(ntq("seventy").getQuery()); NodeSpanQuery term2 = new NodeSpanQuery(ntq("seven").getQuery()); NearSpanQuery spanQuery = new NearSpanQuery(new NodeSpanQuery[] { term1, term2 }, 0, true); this.checkHits(spanQuery, 77, 177, 277, 377, 477); QueryUtils.check(term1); QueryUtils.check(term2);//from w w w. jav a 2s . c om QueryUtils.checkUnequal(term1, term2); }
From source file:com.sindicetech.siren.search.spans.TestTermSpansBasics.java
License:Open Source License
@Test public void testSpanNearExact() throws Exception { this.addDocuments(this.generateDocuments(500)); TermSpanQuery term1 = new TermSpanQuery(new Term(DEFAULT_TEST_FIELD, "seventy")); TermSpanQuery term2 = new TermSpanQuery(new Term(DEFAULT_TEST_FIELD, "seven")); NearSpanQuery spanQuery = new NearSpanQuery(new TermSpanQuery[] { term1, term2 }, 0, true); this.checkHits(spanQuery, 77, 177, 277, 377, 477); QueryUtils.check(term1); QueryUtils.check(term2);//from w w w. ja v a2 s . c o m QueryUtils.checkUnequal(term1, term2); }
From source file:org.apache.solr.search.QueryEqualityTest.java
License:Apache License
/** * 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/*from w ww . j av a 2 s. com*/ * @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]); } } }
From source file:org.elasticsearch.common.lucene.IndexCacheableQueryTests.java
License:Apache License
public void testBasics() throws IOException { DummyIndexCacheableQuery query = new DummyIndexCacheableQuery(); QueryUtils.check(query); Query rewritten = query.rewrite(new MultiReader(new IndexReader[0])); QueryUtils.check(rewritten);/*from w ww. ja va2 s .co m*/ QueryUtils.checkUnequal(query, rewritten); Query rewritten2 = query.rewrite(new MultiReader(new IndexReader[0])); QueryUtils.check(rewritten2); QueryUtils.checkUnequal(rewritten, rewritten2); }
From source file:org.elasticsearch.index.search.child.TopChildrenQueryTests.java
License:Apache License
@Test public void testBasicQuerySanities() { Query childQuery = new TermQuery(new Term("field", "value")); ScoreType scoreType = ScoreType.values()[random().nextInt(ScoreType.values().length)]; ParentFieldMapper parentFieldMapper = SearchContext.current().mapperService().documentMapper("child") .parentFieldMapper();//from ww w .ja v a 2 s . co m ParentChildIndexFieldData parentChildIndexFieldData = SearchContext.current().fieldData() .getForField(parentFieldMapper); Query query = new TopChildrenQuery(parentChildIndexFieldData, childQuery, "child", "parent", scoreType, 1, 1, SearchContext.current().cacheRecycler(), wrapWithFixedBitSetFilter(NonNestedDocsFilter.INSTANCE)); QueryUtils.check(query); }
From source file:org.elasticsearch.search.slice.DocValuesSliceQueryTests.java
License:Apache License
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); }
From source file:org.elasticsearch.search.slice.TermsSliceQueryTests.java
License:Apache License
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); }
From source file:org.tallison.solr.search.QueryEqualityTest.java
License:Apache License
/** * 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//from w ww . j av a 2s . c o m * @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, true, 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]); } } }