本文整理了Java中org.apache.lucene.search.TermQuery.
方法的一些代码示例,展示了TermQuery.
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TermQuery.
方法的具体详情如下:
包路径:org.apache.lucene.search.TermQuery
类名称:TermQuery
方法名:
[英]Constructs a query for the term t
.
[中]为术语t
构造一个查询。
代码示例来源:origin: soabase/exhibitor
public QueryBuilder pathExact(String path)
{
Term term = new Term(FieldNames.PATH, path);
queries.add(new TermQuery(term));
return this;
}
代码示例来源:origin: stackoverflow.com
BooleanQuery booleanQuery = new BooleanQuery();
TermQuery userQuery = new TermQuery(new Term("user_id", u.getId()+""));
BooleanQuery innerBooleanQuery = new BooleanQuery();
innerBooleanQuery.add(new BooleanClause(name_query, Occur.SHOULD));
innerBooleanQuery.add(new BooleanClause(desc_query, Occur.SHOULD));
booleanQuery.add(new BooleanClause(userQuery , Occur.MUST));
booleanQuery.add(new BooleanClause(innerBooleanQuery, Occur.MUST));
代码示例来源:origin: apache/nifi
private BooleanQuery buildLineageQuery(final Collection
// Create a query for all Events related to the FlowFiles of interest. We do this by adding all ID's as
// "SHOULD" clauses and then setting the minimum required to 1.
final BooleanQuery lineageQuery;
if (flowFileUuids == null || flowFileUuids.isEmpty()) {
lineageQuery = null;
} else {
lineageQuery = new BooleanQuery();
for (final String flowFileUuid : flowFileUuids) {
lineageQuery.add(new TermQuery(new Term(SearchableFields.FlowFileUUID.getSearchableFieldName(), flowFileUuid)), Occur.SHOULD);
}
lineageQuery.setMinimumNumberShouldMatch(1);
}
return lineageQuery;
}
代码示例来源:origin: larsga/Duke
Query termQuery;
if (fuzzy_search && isFuzzy(fieldName))
termQuery = new FuzzyQuery(new Term(fieldName, term));
else
termQuery = new TermQuery(new Term(fieldName, term));
parent.add(termQuery, required ? Occur.MUST : Occur.SHOULD);
代码示例来源:origin: stackoverflow.com
TermQuery tq= new TermQuery(new Term("url", url));
// BooleanClauses Enum SHOULD says Use this operator for clauses that should appear in the matching documents.
BooleanQuery bq = new BooleanQuery().add(tq,BooleanClause.Occur.SHOULD);
IndexSearcher searcher = new IndexSearcher(index, true);
TopScoreDocCollector collector = TopScoreDocCollector.create(10, true);
searcher.search(query, collector);
代码示例来源:origin: com.atlassian.jira/jira-core
void add(final Term term, final BooleanClause.Occur occurance)
{
if (term != null)
{
result.add(new TermQuery(term), occurance);
}
}
代码示例来源:origin: apache/nifi
flowFileIdQuery = null;
} else {
flowFileIdQuery = new BooleanQuery();
for (final String flowFileUuid : flowFileUuids) {
flowFileIdQuery.add(new TermQuery(new Term(SearchableFields.FlowFileUUID.getSearchableFieldName(), flowFileUuid)), Occur.SHOULD);
代码示例来源:origin: neo4j/neo4j
private static void addIfAssigned( BooleanQuery.Builder builder, long node, String field )
{
if ( node != -1 )
{
builder.add( new TermQuery( new Term( field, "" + node ) ), Occur.MUST );
}
}
代码示例来源:origin: org.apache.lucene/lucene-spellchecker
/**
* Add a clause to a boolean query.
*/
private static void add(BooleanQuery q, String name, String value) {
q.add(new BooleanClause(new TermQuery(new Term(name, value)), BooleanClause.Occur.SHOULD));
}
代码示例来源:origin: openmrs/openmrs-core
@Factory
public Filter getFilter() {
BooleanQuery query = new BooleanQuery();
if (includeTerms.isEmpty()) {
query.add(new MatchAllDocsQuery(), Occur.MUST);
} else {
for (Set
if (terms.size() == 1) {
query.add(new TermQuery(terms.iterator().next()), Occur.MUST);
} else if (terms.size() > 1) {
BooleanQuery subquery = new BooleanQuery();
for (Term term : terms) {
subquery.add(new TermQuery(term), Occur.SHOULD);
}
query.add(subquery, Occur.MUST);
}
}
}
for (Term term : excludeTerms) {
query.add(new TermQuery(term), Occur.MUST_NOT);
}
return new CachingWrapperFilter(new QueryWrapperFilter(query));
}
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
private void addTermToQuery(Term term, BooleanQuery query) {
TermQuery tq = new TermQuery(term);
tq.setBoost(getBoost()); // set the boost
query.add(tq, BooleanClause.Occur.SHOULD); // add to query
}
代码示例来源:origin: querydsl/querydsl
protected Query in(Operation> operation, QueryMetadata metadata, boolean ignoreCase) {
Path> path = getPath(operation.getArg(0));
String field = toField(path);
@SuppressWarnings("unchecked") //this is the expected type
Constant
Collection> values = expectedConstant.getConstant();
BooleanQuery bq = new BooleanQuery();
if (Number.class.isAssignableFrom(path.getType())) {
for (Object value : values) {
TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value)));
bq.add(eq, Occur.SHOULD);
}
} else {
for (Object value : values) {
String[] str = convert(path, value);
bq.add(eq(field, str, ignoreCase), Occur.SHOULD);
}
}
return bq;
}
代码示例来源:origin: neo4j/neo4j
@Override
public Query get( String key, Object value )
{
// TODO we do value.toString() here since initially #addToDocument didn't
// honor ValueContext, and changing it would mean changing store format.
return new TermQuery( new Term( exactKey( key ), value.toString() ) );
}
代码示例来源:origin: org.compass-project/compass
/**
* Add a clause to a boolean query.
*/
private static void add(BooleanQuery q, String name, String value) {
q.add(new BooleanClause(new TermQuery(new Term(name, value)), BooleanClause.Occur.SHOULD));
}
代码示例来源:origin: stackoverflow.com
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery("attributeId", 10), BooleanClause.Occur.MUST);
query.add(new TermQuery("value", "Romance"), BooleanClause.Occur.MUST);
// build "IN" clause
BooleanQuery pidQuery = new BooleanQuery();
for( long productId : productIds ){
pidQuery.add(new TermQuery("productId", productId), BooleanClause.Occur.SHOULD);
}
query.add(pidQuery, BooleanClause.Occur.MUST);
TopDocs docs = searcher.search(query, null, searchLimit);
代码示例来源:origin: querydsl/querydsl
protected Query in(Operation> operation, QueryMetadata metadata, boolean ignoreCase) {
Path> path = getPath(operation.getArg(0));
String field = toField(path);
@SuppressWarnings("unchecked") //This is the second argument type
Constant
Collection> values = collConstant.getConstant();
BooleanQuery bq = new BooleanQuery();
if (Number.class.isAssignableFrom(path.getType())) {
for (Object value : values) {
TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value)));
bq.add(eq, Occur.SHOULD);
}
} else {
for (Object value : values) {
String[] str = convert(path, value);
bq.add(eq(field, str, ignoreCase), Occur.SHOULD);
}
}
return bq;
}
代码示例来源:origin: soabase/exhibitor
public QueryBuilder operationType(int type)
{
Term term = new Term(FieldNames.TYPE, Integer.toString(type));
queries.add(new TermQuery(term));
return this;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base
private static Query createClassWithEnclosedQuery (final String resourceName, final String sourceName) {
final BooleanQuery query = createFQNQuery(resourceName);
if (sourceName != null) {
query.add (new TermQuery(new Term (DocumentUtil.FIELD_SOURCE,sourceName)), Occur.MUST);
}
return query;
}
代码示例来源:origin: stackoverflow.com
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery("attributeId", 7), BooleanClause.Occur.MUST);
query.add(new TermQuery("value", "hindi"), BooleanClause.Occur.MUST);
TopDocs docs = searcher.search(query, null, searchLimit);
代码示例来源:origin: querydsl/querydsl
protected Query in(Operation> operation, QueryMetadata metadata,
boolean ignoreCase) {
Path> path = getPath(operation.getArg(0));
String field = toField(path);
@SuppressWarnings("unchecked")
// this is the expected type
Constant
.getArg(1);
Collection> values = expectedConstant.getConstant();
BooleanQuery bq = new BooleanQuery();
if (Number.class.isAssignableFrom(path.getType())) {
for (Object value : values) {
TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value)));
bq.add(eq, Occur.SHOULD);
}
} else {
for (Object value : values) {
String[] str = convert(path, value);
bq.add(eq(field, str, ignoreCase), Occur.SHOULD);
}
}
return bq;
}