类org.apache.lucene.search.spans.SpanContainingQuery源码实例Demo

下面列出了怎么用org.apache.lucene.search.spans.SpanContainingQuery的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lucene-solr   文件: TestPayloadScoreQuery.java
@Test
public void testSpanContainingQuery() throws Exception {

  // twenty WITHIN ((one OR hundred) NEAR two)~2
  SpanContainingQuery q = new SpanContainingQuery(
      new SpanNearQuery(new SpanQuery[]{
          new SpanOrQuery(new SpanTermQuery(new Term("field", "one")), new SpanTermQuery(new Term("field", "hundred"))),
          new SpanTermQuery(new Term("field", "two"))
      }, 2, true),
      new SpanTermQuery(new Term("field", "twenty"))
  );

  checkQuery(q, new AveragePayloadFunction(), new int[] { 222, 122 }, new float[]{ 4.0f, 3.666666f });
  checkQuery(q, new MaxPayloadFunction(), new int[]{ 122, 222 }, new float[]{ 4.0f, 4.0f });
  checkQuery(q, new MinPayloadFunction(), new int[]{ 222, 122 }, new float[]{ 4.0f, 2.0f });

}
 
源代码2 项目: lucene-solr   文件: TestSpanExtractors.java
public void testSpanContains() {
  Term t1 = new Term("field", "term1");
  Term t2 = new Term("field", "term22");
  Term t3 = new Term("field", "term333");
  SpanContainingQuery swq = new SpanContainingQuery(
      SpanNearQuery.newOrderedNearQuery("field")
          .addClause(new SpanTermQuery(t1))
          .addClause(new SpanTermQuery(t2))
          .build(),
      new SpanTermQuery(t3));

  assertEquals(Collections.singleton(t3), collectTerms(swq));
}
 
源代码3 项目: mtas   文件: MtasSpanContainingQuery.java
/**
 * Instantiates a new mtas span containing query.
 *
 * @param q1 the q 1
 * @param q2 the q 2
 */
public MtasSpanContainingQuery(MtasSpanQuery q1, MtasSpanQuery q2) {
  super(q1 != null ? q1.getMinimumWidth() : null,
      q1 != null ? q1.getMaximumWidth() : null);
  if (q2 != null && q2.getMinimumWidth() != null
      && (this.getMinimumWidth() == null
          || this.getMinimumWidth() < q2.getMinimumWidth())) {
    this.setWidth(q2.getMinimumWidth(), this.getMaximumWidth());
  }
  bigQuery = q1;
  smallQuery = q2;
  if (bigQuery != null && bigQuery.getField() != null) {
    field = bigQuery.getField();
  } else if (smallQuery != null && smallQuery.getField() != null) {
    field = smallQuery.getField();
  } else {
    field = null;
  }
  if (field != null && bigQuery != null && smallQuery != null) {
    if (bigQuery.getField() != null && smallQuery.getField() != null) {
      baseQuery = new SpanContainingQuery(bigQuery, smallQuery);
    } else {
      baseQuery = null;
    }
  } else {
    baseQuery = null;
  }
}
 
 类所在包
 类方法
 同包方法