org.apache.lucene.search.Query.toString()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中org.apache.lucene.search.Query.toString方法的一些代码示例,展示了Query.toString的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.toString方法的具体详情如下:
包路径:org.apache.lucene.search.Query
类名称:Query
方法名:toString

Query.toString介绍

[英]Prints a query to a string.
[中]将查询打印到字符串。

代码示例

代码示例来源:origin: oracle/opengrok

/**
 * Gets the instance from {@code search(...)} if it was called.
 * @return defined instance or {@code null}
 */
public String getQuery() {
  return query != null ? query.toString() : null;
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** Prints a query to a string. */
@Override
public final String toString() {
 return toString("");
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString(String field) {
 return indexQuery.toString(field);
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString() {
 return "score(" + query.toString() + ")";
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString() {
 return "score(" + weight.parentQuery.toString() + ")";
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString(String field) {
 return new StringBuilder("ConstantScore(")
  .append(query.toString(field))
  .append(')')
  .toString();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString(String field) {
 StringBuilder builder = new StringBuilder();
 builder.append("(");
 builder.append(query.toString(field));
 builder.append(")");
 builder.append("^");
 builder.append(boost);
 return builder.toString();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString(String field) {
 StringBuilder builder = new StringBuilder("Synonym(");
 for (int i = 0; i < terms.length; i++) {
  if (i != 0) {
   builder.append(" ");
  }
  Query termQuery = new TermQuery(terms[i]);
  builder.append(termQuery.toString(field));
 }
 builder.append(")");
 return builder.toString();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
 public String toString() {
  return occur.toString() + query.toString();
 }
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** Prettyprint us.
 * @param field the field to which we are applied
 * @return a string that shows what we do, of the form "(disjunct1 | disjunct2 | ... | disjunctn)^boost"
 */
@Override
public String toString(String field) {
 StringBuilder buffer = new StringBuilder();
 buffer.append("(");
 for (int i = 0 ; i < disjuncts.length; i++) {
  Query subquery = disjuncts[i];
  if (subquery instanceof BooleanQuery) {   // wrap sub-bools in parens
   buffer.append("(");
   buffer.append(subquery.toString(field));
   buffer.append(")");
  }
  else buffer.append(subquery.toString(field));
  if (i != disjuncts.length-1) buffer.append(" | ");
 }
 buffer.append(")");
 if (tieBreakerMultiplier != 0.0f) {
  buffer.append("~");
  buffer.append(tieBreakerMultiplier);
 }
 return buffer.toString();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public String toString(String field) {
 StringBuilder builder = new StringBuilder("Blended(");
 for (int i = 0; i < terms.length; ++i) {
  if (i != 0) {
   builder.append(" ");
  }
  Query termQuery = new TermQuery(terms[i]);
  if (boosts[i] != 1f) {
   termQuery = new BoostQuery(termQuery, boosts[i]);
  }
  builder.append(termQuery.toString(field));
 }
 builder.append(")");
 return builder.toString();
}

代码示例来源:origin: oracle/opengrok

return fields;
String queryString = query.toString("");
if (queryString.contains(DEFS + ":")) {
  fields.add(DEFS);

代码示例来源:origin: querydsl/querydsl

@Override
public String toString() {
  String str = createQuery().toString();
  return CharMatcher.JAVA_ISO_CONTROL.replaceFrom(str, '_');
}

代码示例来源:origin: querydsl/querydsl

@Override
public String toString() {
  String str = createQuery().toString();
  return CharMatcher.JAVA_ISO_CONTROL.replaceFrom(str, '_');
}

代码示例来源:origin: querydsl/querydsl

@Override
public String toString() {
  String str = createQuery().toString();
  return CharMatcher.JAVA_ISO_CONTROL.replaceFrom(str, '_');
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
 final Scorer s = scorer(context);
 final boolean exists;
 if (s == null) {
  exists = false;
 } else {
  final TwoPhaseIterator twoPhase = s.twoPhaseIterator();
  if (twoPhase == null) {
   exists = s.iterator().advance(doc) == doc;
  } else {
   exists = twoPhase.approximation().advance(doc) == doc && twoPhase.matches();
  }
 }
 if (exists) {
  return Explanation.match(
    score, getQuery().toString() + (score == 1f ? "" : "^" + score));
 } else {
  return Explanation.noMatch(getQuery().toString() + " doesn't match id " + doc);
 }
}

代码示例来源:origin: oracle/opengrok

/**
 * Test of setFreetext method, of class QueryBuilder.
 * @throws ParseException parse exception
 */
@Test
public void testParsePath() throws ParseException {        
  QueryBuilder instance = new QueryBuilder();
  String expResult = "+this +is +a +test +path";
  QueryBuilder result = instance.setPath("this/is/a/test/path");
  Query test = result.build();        
  assertEquals(expResult, test.toString(QueryBuilder.PATH) );        
  
  expResult = "+this +is +a +test +path +with +file +. +ext";
  result = instance.setPath("/this/is/a/test/path/with/file.ext");
  test = result.build();        
  assertEquals(expResult, test.toString(QueryBuilder.PATH) );        
  
}

代码示例来源:origin: apache/geode

@Test
public void defaultFieldParameterShouldBeUsedByQuery() throws LuceneQueryException {
 StringQueryProvider provider = new StringQueryProvider("findThis", "field-2");
 Query query = provider.getQuery(mockIndex);
 Assert.assertNotNull(query);
 assertEquals("field-2:findthis", query.toString());
}

代码示例来源:origin: apache/geode

@Test
public void testQueryConstruction() throws LuceneQueryException {
 StringQueryProvider provider = new StringQueryProvider("foo:bar", DEFAULT_FIELD);
 Query query = provider.getQuery(mockIndex);
 Assert.assertNotNull(query);
 assertEquals("foo:bar", query.toString());
}

代码示例来源:origin: apache/geode

@Test
@Ignore("Custom analyzer not yet supported, this is a duplicate test right now")
public void usesCustomAnalyzer() throws LuceneQueryException {
 StringQueryProvider provider = new StringQueryProvider("findThis", DEFAULT_FIELD);
 Query query = provider.getQuery(mockIndex);
 Assert.assertNotNull(query);
 assertEquals("field-1:findthis field-2:findthis", query.toString());
}

相关文章