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


Java QueryNodeException类代码示例

本文整理汇总了Java中org.apache.lucene.queryparser.flexible.core.QueryNodeException的典型用法代码示例。如果您正苦于以下问题:Java QueryNodeException类的具体用法?Java QueryNodeException怎么用?Java QueryNodeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QueryNodeException类属于org.apache.lucene.queryparser.flexible.core包,在下文中一共展示了QueryNodeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLuceneQuery

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
/**
 * Returns the Lucene query for the given locale and query text.
 * 
 * @param searchString
 *            the text query for the Lucene query parser
 * @param mId
 *            the marketplace id
 * @param locale
 *            the locale for the analyzer to use
 * @param isDefaultLocaleHandling
 * @return the Lucene query for the given locale and query text
 * @throws ParseException
 *             in case the query cannot be parsed
 */
private org.apache.lucene.search.Query getLuceneQuery(String searchString,
        String mId, String locale, boolean isDefaultLocaleHandling)
        throws SyntaxError, QueryNodeException {

    // construct wildcard query for the actual search part
    org.apache.lucene.search.Query textQuery = LuceneQueryBuilder
            .getServiceQuery(searchString, locale, DEFAULT_LOCALE,
                    isDefaultLocaleHandling);

    // build mId part
    TermQuery mIdQuery = new TermQuery(new Term(ProductClassBridge.MP_ID,
            QueryParser.escape(mId).toLowerCase()));

    // now construct final query
    BooleanQuery query = new BooleanQuery();
    query.add(mIdQuery, Occur.MUST);
    query.add(textQuery, Occur.MUST);
    return query;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:SearchServiceBean.java

示例2: preProcessNode

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {
  QueryNode parent = node.getParent();
  if (node instanceof BooleanQueryNode) {
    if (parent instanceof BooleanQueryNode) {
      node.setTag(TAG_REMOVE, Boolean.TRUE); // no precedence
    } else {
      node.setTag(TAG_BOOLEAN_ROOT, Boolean.TRUE);
    }
  } else if (parent instanceof BooleanQueryNode) {
    if ((parent instanceof AndQueryNode)
        || (usingAnd && isDefaultBooleanQueryNode(parent))) {
      tagModifierButDoNotOverride(node, ModifierQueryNode.Modifier.MOD_REQ);
    }
  }
  return node;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例3: postProcessNode

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

  if (node instanceof WildcardQueryNode) {
    WildcardQueryNode wildcardNode = (WildcardQueryNode) node;

    if (wildcardNode.getText().length() > 0) {
      
      // Validate if the wildcard was escaped
      if (UnescapedCharSequence.wasEscaped(wildcardNode.getText(), 0))
        return node;
      
      switch (wildcardNode.getText().charAt(0)) {    
        case '*':
        case '?':
          throw new QueryNodeException(new MessageImpl(
              QueryParserMessages.LEADING_WILDCARD_NOT_ALLOWED, node
                  .toQueryString(new EscapeQuerySyntaxImpl())));    
      }
    }

  }

  return node;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:AllowLeadingWildcardProcessor.java

示例4: getNumericDataType

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
private static NumericType getNumericDataType(Number number) throws QueryNodeException {
  
  if (number instanceof Long) {
    return NumericType.LONG;
  } else if (number instanceof Integer) {
    return NumericType.INT;
  } else if (number instanceof Double) {
    return NumericType.DOUBLE;
  } else if (number instanceof Float) {
    return NumericType.FLOAT;
  } else {
    throw new QueryNodeException(
        new MessageImpl(
            QueryParserMessages.NUMBER_CLASS_NOT_SUPPORTED_BY_NUMERIC_RANGE_QUERY,
            number.getClass()));
  }
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:NumericRangeQueryNode.java

示例5: build

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public Query build(QueryNode queryNode) throws QueryNodeException {
  SlopQueryNode phraseSlopNode = (SlopQueryNode) queryNode;

  Query query = (Query) phraseSlopNode.getChild().getTag(
      QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);

  if (query instanceof PhraseQuery) {
    ((PhraseQuery) query).setSlop(phraseSlopNode.getValue());

  } else {
    ((MultiPhraseQuery) query).setSlop(phraseSlopNode.getValue());
  }

  return query;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SlopQueryNodeBuilder.java

示例6: build

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public Query build(QueryNode queryNode) throws QueryNodeException {
  BoostQueryNode boostNode = (BoostQueryNode) queryNode;
  QueryNode child = boostNode.getChild();

  if (child == null) {
    return null;
  }

  Query query = (Query) child
      .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
  query.setBoost(boostNode.getValue());

  return query;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:BoostQueryNodeBuilder.java

示例7: process

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Operator op = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR);
  
  if (op == null) {
    throw new IllegalArgumentException(
        "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
  }

  this.usingAnd = StandardQueryConfigHandler.Operator.AND == op;

  return super.process(queryTree);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:BooleanModifiersQueryNodeProcessor.java

示例8: processChildren

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
protected void processChildren(QueryNode queryTree) throws QueryNodeException {

  if (this.processChildren) {
    super.processChildren(queryTree);

  } else {
    this.processChildren = true;
  }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:MultiFieldQueryNodeProcessor.java

示例9: postProcessNode

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

  // the old Lucene Parser ignores FuzzyQueryNode that are also PrefixWildcardQueryNode or WildcardQueryNode
  // we do the same here, also ignore empty terms
  if (node instanceof FieldQueryNode || node instanceof FuzzyQueryNode) {      
    FieldQueryNode fqn = (FieldQueryNode) node;      
    CharSequence text = fqn.getText(); 
    
    // do not process wildcards for TermRangeQueryNode children and 
    // QuotedFieldQueryNode to reproduce the old parser behavior
    if (fqn.getParent() instanceof TermRangeQueryNode 
        || fqn instanceof QuotedFieldQueryNode 
        || text.length() <= 0){
      // Ignore empty terms
      return node;
    }
    
    // Code below simulates the old lucene parser behavior for wildcards
    
    if (isPrefixWildcard(text)) {        
      PrefixWildcardQueryNode prefixWildcardQN = new PrefixWildcardQueryNode(fqn);
      return prefixWildcardQN;
      
    } else if (isWildcard(text)){
      WildcardQueryNode wildcardQN = new WildcardQueryNode(fqn);
      return wildcardQN;
    }
           
  }

  return node;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:WildcardQueryNodeProcessor.java

示例10: process

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Operator op = getQueryConfigHandler().get(
      ConfigurationKeys.DEFAULT_OPERATOR);
  
  if (op == null) {
    throw new IllegalArgumentException(
        "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
  }
  
  this.usingAnd = StandardQueryConfigHandler.Operator.AND == op;
  
  return processIteration(queryTree);
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例11: processChildren

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
protected void processChildren(QueryNode queryTree) throws QueryNodeException {
  List<QueryNode> children = queryTree.getChildren();
  if (children != null && children.size() > 0) {
    for (QueryNode child : children) {
      child = processIteration(child);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例12: postProcessNode

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
  if (node.containsTag(TAG_BOOLEAN_ROOT)) {
    this.childrenBuffer.clear();
    fillChildrenBufferAndApplyModifiery(node);
    node.set(childrenBuffer);
  }
  return node;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例13: process

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Boolean lowercaseExpandedTerms = getQueryConfigHandler().get(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS);

  if (lowercaseExpandedTerms != null && lowercaseExpandedTerms) {
    return super.process(queryTree);
  }

  return queryTree;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:LowercaseExpandedTermsQueryNodeProcessor.java

示例14: process

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Boolean allowsLeadingWildcard = getQueryConfigHandler().get(ConfigurationKeys.ALLOW_LEADING_WILDCARD);

  if (allowsLeadingWildcard != null) {

    if (!allowsLeadingWildcard) {
      return super.process(queryTree);
    }

  }

  return queryTree;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AllowLeadingWildcardProcessor.java

示例15: postProcessNode

import org.apache.lucene.queryparser.flexible.core.QueryNodeException; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
  
  if (node instanceof TermRangeQueryNode) {
    TermRangeQueryNode rangeNode = (TermRangeQueryNode) node;
    FieldQueryNode lowerNode = rangeNode.getLowerBound();
    FieldQueryNode upperNode = rangeNode.getUpperBound();
    CharSequence lowerText = lowerNode.getText();
    CharSequence upperText = upperNode.getText();
    
    if (OPEN_RANGE_TOKEN.equals(upperNode.getTextAsString())
        && (!(upperText instanceof UnescapedCharSequence) || !((UnescapedCharSequence) upperText)
            .wasEscaped(0))) {
      upperText = "";
    }
    
    if (OPEN_RANGE_TOKEN.equals(lowerNode.getTextAsString())
        && (!(lowerText instanceof UnescapedCharSequence) || !((UnescapedCharSequence) lowerText)
            .wasEscaped(0))) {
      lowerText = "";
    }
    
    lowerNode.setText(lowerText);
    upperNode.setText(upperText);
  }
  
  return node;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:OpenRangeQueryNodeProcessor.java


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