當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。