当前位置: 首页>>代码示例>>Java>>正文


Java PrefixQuery.setRewriteMethod方法代码示例

本文整理汇总了Java中org.apache.lucene.search.PrefixQuery.setRewriteMethod方法的典型用法代码示例。如果您正苦于以下问题:Java PrefixQuery.setRewriteMethod方法的具体用法?Java PrefixQuery.setRewriteMethod怎么用?Java PrefixQuery.setRewriteMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.PrefixQuery的用法示例。


在下文中一共展示了PrefixQuery.setRewriteMethod方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
@Override
public final Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, QueryShardContext context) {
    failIfNotIndexed();
    PrefixQuery query = new PrefixQuery(new Term(name(), indexedValueForSearch(value)));
    if (method != null) {
        query.setRewriteMethod(method);
    }
    return query;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:StringFieldType.java

示例2: build

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
@Override
public PrefixQuery build(QueryNode queryNode) throws QueryNodeException {    

  PrefixWildcardQueryNode wildcardNode = (PrefixWildcardQueryNode) queryNode;

  String text = wildcardNode.getText().subSequence(0, wildcardNode.getText().length() - 1).toString();
  PrefixQuery q = new PrefixQuery(new Term(wildcardNode.getFieldAsString(), text));
  
  MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
  if (method != null) {
    q.setRewriteMethod(method);
  }
  
  return q;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:PrefixWildcardQueryNodeBuilder.java

示例3: queryFromString

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
private static Query queryFromString(Analyzer analyzer, String searchText, int fuzzy) {
	if (searchText != null && !searchText.isEmpty()) {
		BooleanQuery.Builder b = new BooleanQuery.Builder();
		try (TokenStream stream = analyzer.tokenStream(FIELD_TERM, searchText)) {
			CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
			stream.reset();
			while (stream.incrementToken()) {
				String s = termAtt.toString();
				Term term = new Term("term", s);
				Query tq = s.length() > MINIMUM_CHARS_FOR_FUZZY_SEARCH && fuzzy > 0 ? new FuzzyQuery(term, fuzzy) : new TermQuery(term);
				if (s.length() >= MINIMUM_CHARS_FOR_PREFIX_SEARCH) {
					PrefixQuery pq = new PrefixQuery(new Term("term", s));
					pq.setRewriteMethod(PrefixQuery.SCORING_BOOLEAN_REWRITE);
					BooleanQuery bq = new BooleanQuery.Builder().add(tq, Occur.SHOULD).add(pq, Occur.SHOULD).build();
					b.add(bq, Occur.MUST);
				}
				else {
					b.add(tq,Occur.MUST);
				}
			}
			stream.end();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return b.build();
	}
	return null;
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:29,代码来源:Search.java

示例4: getPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
@Override
public Query getPrefixQuery(QParser parser, SchemaField sf, String termStr) {
  if(termStr.equals("foo")) {
    termStr = "bar";
  } else if (termStr.equals("bar")) {
    termStr = "foo";
  }

  PrefixQuery query = new PrefixQuery(new Term(sf.getName(), termStr));
  query.setRewriteMethod(sf.getType().getRewriteMethod(parser, sf));
  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:MyCrazyCustomField.java

示例5: newPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
/**
 * Builds a new PrefixQuery instance
 * @param prefix Prefix term
 * @return new PrefixQuery instance
 */
protected Query newPrefixQuery(Term prefix){
  PrefixQuery query = new PrefixQuery(prefix);
  SchemaField sf = schema.getField(prefix.field());
  query.setRewriteMethod(sf.getType().getRewriteMethod(parser, sf));
  return query;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:12,代码来源:SolrQueryParserBase.java

示例6: createPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
@Override
public Query createPrefixQuery(final @NonNull String name, final @NonNull String value) {
    final PrefixQuery pq = new PrefixQuery(new Term(name, value));
    pq.setRewriteMethod(PrefixQuery.CONSTANT_SCORE_FILTER_REWRITE);
    return pq;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:Queries.java

示例7: newPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
/**
 * Builds a new PrefixQuery instance
 * 
 * @param prefix Prefix term
 * @return new PrefixQuery instance
 */
protected Query newPrefixQuery(Term prefix) {
	PrefixQuery query = new PrefixQuery(prefix);
	query.setRewriteMethod(multiTermRewriteMethod);
	return query;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:12,代码来源:QueryParser.java

示例8: getPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
/**
 * Returns a Query instance for doing prefix searches on this field type.
 * Also, other QueryParser implementations may have different semantics.
 * <p/>
 * Sub-classes should override this method to provide their own range query implementation.
 *
 * @param parser       the {@link org.apache.solr.search.QParser} calling the method
 * @param sf           the schema field
 * @param termStr      the term string for prefix query
 * @return a Query instance to perform prefix search
 *
 */
public Query getPrefixQuery(QParser parser, SchemaField sf, String termStr) {
  PrefixQuery query = new PrefixQuery(new Term(sf.getName(), termStr));
  query.setRewriteMethod(sf.getType().getRewriteMethod(parser, sf));
  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:FieldType.java

示例9: newPrefixQuery

import org.apache.lucene.search.PrefixQuery; //导入方法依赖的package包/类
/**
 * Builds a new PrefixQuery instance
 * 
 * @param prefix
 *            Prefix term
 * @return new PrefixQuery instance
 */
protected Query newPrefixQuery(Term prefix) {
	PrefixQuery query = new PrefixQuery(prefix);
	query.setRewriteMethod(multiTermRewriteMethod);
	return query;
}
 
开发者ID:easynet-cn,项目名称:resource-query-parser,代码行数:13,代码来源:QueryParserBase.java


注:本文中的org.apache.lucene.search.PrefixQuery.setRewriteMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。