本文整理了Java中org.apache.lucene.search.BooleanQuery.toString()
方法的一些代码示例,展示了BooleanQuery.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanQuery.toString()
方法的具体详情如下:
包路径:org.apache.lucene.search.BooleanQuery
类名称:BooleanQuery
方法名:toString
[英]Prints a user-readable version of this query.
[中]打印此查询的用户可读版本。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public String toString() {
return "authorisation query: " + query.toString();
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public String toString(String field) {
return getBooleanQuery().toString(field);
}
代码示例来源:origin: org.apache.lucene/lucene-facet
@Override
public String toString(String field) {
return getBooleanQuery().toString(field);
}
代码示例来源:origin: stackoverflow.com
BooleanQuery b = new BooleanQuery();
Set<String> fields = params.keySet();
StandardAnalyzer analyzer = new StandardAnalyzer(version);
b.add(new TermQuery(new Term("cs-method", "GET"), BooleanClause.Occur.SHOULD);
b.add(new TermQuery(new Term("cs-uri", "/blank"), BooleanClause.Occur.SHOULD);
Query q = new QueryParser(version, "cs-method", analyzer).parse(b.toString());
代码示例来源:origin: org.aperteworkflow/integration
public List<Document> search(String query, int offset, int limit, Query... addQueries) {
try {
LOGGER.fine("Parsing lucene search query: " + query);
QueryParser qp = new QueryParser(Version.LUCENE_35, "all", new StandardAnalyzer(Version.LUCENE_35));
Query q = qp.parse(query);
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term(AWF__TYPE, PROCESS_INSTANCE)), BooleanClause.Occur.MUST);
for (Query qq : addQueries) {
bq.add(qq, BooleanClause.Occur.MUST);
}
bq.add(q, BooleanClause.Occur.MUST);
LOGGER.fine("Searching lucene index with query: " + bq.toString());
TopDocs search = indexSearcher.search(bq, offset + limit);
List<Document> results = new ArrayList<Document>(limit);
LOGGER.fine("Total result count for query: " + bq.toString() + " is " + search.totalHits);
for (int i = offset; i < offset+limit && i < search.totalHits; i++) {
ScoreDoc scoreDoc = search.scoreDocs[i];
results.add(indexSearcher.doc(scoreDoc.doc));
}
return results;
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: stackoverflow.com
public class Tokens {
private static void printTokens(String string, Analyzer analyzer) throws IOException {
System.out.println("Using " + analyzer.getClass().getName());
TokenStream ts = analyzer.tokenStream("default", new StringReader(string));
OffsetAttribute offsetAttribute = ts.addAttribute(OffsetAttribute.class);
CharTermAttribute charTermAttribute = ts.addAttribute(CharTermAttribute.class);
while(ts.incrementToken()) {
int startOffset = offsetAttribute.startOffset();
int endOffset = offsetAttribute.endOffset();
String term = charTermAttribute.toString();
System.out.println(term + " (" + startOffset + " " + endOffset + ")");
}
System.out.println();
}
public static void main(String[] args) throws IOException {
printTokens("foo-bar 1-2-3", new StandardAnalyzer(Version.LUCENE_40));
printTokens("foo-bar 1-2-3", new ClassicAnalyzer(Version.LUCENE_40));
QueryParser standardQP = new QueryParser(Version.LUCENE_40, "", new StandardAnalyzer(Version.LUCENE_40));
BooleanQuery q1 = (BooleanQuery) standardQP.parse("someField:(foo\\-bar\\ 1\\-2\\-3)");
System.out.println(q1.toString() + " # of clauses:" + q1.getClauses().length);
}
}
代码示例来源:origin: stackoverflow.com
Set<String> fieldSet = Sets.newHashSet();
fieldSet.add(rangeQueryField);
BooleanQuery fieldsQuery = new BooleanQuery();
for (String field : fields) {
fieldSet.add(field);
WildcardQuery queryPart = new WildcardQuery(new Term(field, queryText));
fieldsQuery.add(queryPart, Occur.SHOULD);
}
BooleanQuery query = new BooleanQuery();
query.add(fieldsQuery, Occur.MUST);
NumericRangeFilter<Long> longNumericRangeFilter = NumericRangeFilter.newLongRange(rangeQueryField, rangeValue, Long.MAX_VALUE, false, false);
MultiFieldQueryParser queryParser = new MultiFieldQueryParser(version, fieldSet.toArray(new String[0]), analyzer);
queryParser.setAllowLeadingWildcard(true);
Query q = queryParser.parse(query.toString());
TopFieldDocs searchResults = searcher.search(q, longNumericRangeFilter, maxResultsToReturn, sort);
代码示例来源:origin: wonder.eof/ERIndexing
public IndexDocument findDocument(EOKeyGlobalID globalID) {
NSMutableArray<Document> result = new NSMutableArray();
long start = System.currentTimeMillis();
try {
Searcher searcher = indexSearcher();
String pk = ERXKeyGlobalID.globalIDForGID(globalID).asString();
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term(GID, pk)), Occur.MUST);
Hits hits = searcher.search(query);
log.info("Searched for: " + query.toString(GID) + " in " + (System.currentTimeMillis() - start) + " ms");
for (Iterator iter = hits.iterator(); iter.hasNext();) {
Hit hit = (Hit) iter.next();
result.addObject(hit.getDocument());
}
log.info("Returning " + result.count() + " after " + (System.currentTimeMillis() - start) + " ms");
} catch (IOException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
}
return new IndexDocument(result.lastObject());
}
代码示例来源:origin: lucene4ir/lucene4ir
bqb.add(nbc);
BooleanQuery q = bqb.build();
System.out.println("ExpandedQuery: " + q.toString());
results = searcher.search(q, p.maxResults);
hits = results.scoreDocs;
代码示例来源:origin: org.xcmis/xcmis-search-service
log.debug(query.toString());
代码示例来源:origin: apache/maven-indexer
public Set<ArtifactInfo> searchBySHA1( final String checksum )
throws IOException
{
final BooleanQuery query = new BooleanQuery();
query.add( getIndexer().constructQuery( MAVEN.SHA1, new SourcedSearchExpression( checksum ) ), MUST );
LOGGER.debug( "Executing search query: {}; ctx id: {}; idx dir: {}",
new String[]{ query.toString(), indexingContext.getId(),
indexingContext.getIndexDirectory().toString() } );
final FlatSearchResponse response = getIndexer().searchFlat( new FlatSearchRequest( query, indexingContext ) );
LOGGER.info( "Hit count: {}", response.getReturnedHitsCount() );
final Set<ArtifactInfo> results = response.getResults();
if ( LOGGER.isDebugEnabled() )
{
for ( final ArtifactInfo result : results )
{
LOGGER.debug( "Found artifact: {}", result.toString() );
}
}
return results;
}
代码示例来源:origin: dkpro/dkpro-core
String cacheKey = q.toString();
代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-app
getLogger().error( "Got I/O exception while searching for query \"" + bq.toString() + "\"", e );
代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-app
getLogger().error( "Got I/O exception while searching for query \"" + bq.toString() + "\"", e );
代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-app
getLogger().error( "Got I/O exception while searching for query \"" + bq.toString() + "\"", e );
代码示例来源:origin: SciGraph/SciGraph
logger.finest(finalQuery.toString());
try (Transaction tx = graph.beginTx()) {
IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery);
代码示例来源:origin: apache/maven-indexer
new String[]{ query.toString(), indexingContext.getId(),
indexingContext.getIndexDirectory().toString() } );
代码示例来源:origin: hibernate/hibernate-search
.add( desc, BooleanClause.Occur.SHOULD )
.build();
log.debug( query.toString() );
代码示例来源:origin: hibernate/hibernate-search
.add( desc, BooleanClause.Occur.SHOULD )
.build();
log.debug( query.toString() );
代码示例来源:origin: hibernate/hibernate-search
.add( desc, BooleanClause.Occur.SHOULD )
.build();
log.debug( query.toString() );
内容来源于网络,如有侵权,请联系作者删除!