Package org.apache.lucene.queryparser.flexible.core.config

Examples of org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler


  @Override
  protected QueryNode preProcessNode(final QueryNode node)
  throws QueryNodeException {
    if (node instanceof DatatypeQueryNode) {
      // Set the datatype analyzer to use on the descendant querynodes
      final QueryConfigHandler conf = this.getQueryConfigHandler();
      final Map<String, Analyzer> dtAnalyzers = conf.get(KeywordConfigurationKeys.DATATYPES_ANALYZERS);
      final DatatypeQueryNode dt = (DatatypeQueryNode) node;

      if (dtAnalyzers == null) {
        throw new IllegalArgumentException("KeywordConfigurationKeys.DATAYPES_ANALYZERS " +
            "should be set on the KeywordQueryConfigHandler");
View Full Code Here


  protected QueryNode postProcessNode(final QueryNode node) throws QueryNodeException {

    if (node.getParent() == null) { // node is root, we processed the tree
      if (hasUnaryReqOperator) { // we found a req modifier in the tree

        final QueryConfigHandler conf = this.getQueryConfigHandler();
        if (!conf.has(ConfigurationKeys.DEFAULT_OPERATOR)) {
          throw new IllegalArgumentException(
              "ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
        }
        conf.set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
      }
    }
    return node;

  }
View Full Code Here

    // convert the CharSequence into a QueryNode tree
    QueryNode queryTree = queryParser.parse("body:text", null);

    // create a config handler with a attribute used in
    // UniqueFieldQueryNodeProcessor
    QueryConfigHandler spanQueryConfigHandler = new SpansQueryConfigHandler();
    spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, "index");

    // set up the processor pipeline with the ConfigHandler
    // and create the pipeline for this simple demo
    QueryNodeProcessorPipeline spanProcessorPipeline = new QueryNodeProcessorPipeline(
        spanQueryConfigHandler);
View Full Code Here

  protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

    if (node instanceof FieldableNode) {
      FieldableNode fieldNode = (FieldableNode) node;

      QueryConfigHandler queryConfig = getQueryConfigHandler();

      if (queryConfig == null) {
        throw new IllegalArgumentException(
            "A config handler is expected by the processor UniqueFieldQueryNodeProcessor!");
      }

      if (!queryConfig.has(SpansQueryConfigHandler.UNIQUE_FIELD)) {
        throw new IllegalArgumentException(
            "UniqueFieldAttribute should be defined in the config handler!");
      }

      String uniqueField = queryConfig.get(SpansQueryConfigHandler.UNIQUE_FIELD);
      fieldNode.setField(uniqueField);

    }

    return node;
View Full Code Here

    // empty constructor
  }

  @Override
  public QueryNode process(QueryNode queryTree) throws QueryNodeException {
    QueryConfigHandler queryConfig = getQueryConfigHandler();

    if (queryConfig != null) {
      Integer defaultPhraseSlop = queryConfig.get(ConfigurationKeys.PHRASE_SLOP);
     
      if (defaultPhraseSlop != null) {
        this.defaultPhraseSlop = defaultPhraseSlop;

        return super.process(queryTree);
View Full Code Here

  @Override
  protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

    if (node instanceof FuzzyQueryNode) {
      FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node;
      QueryConfigHandler config = getQueryConfigHandler();

      FuzzyConfig fuzzyConfig = null;
     
      if (config != null && (fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG)) != null) {
        fuzzyNode.setPrefixLength(fuzzyConfig.getPrefixLength());

        if (fuzzyNode.getSimilarity() < 0) {
          fuzzyNode.setSimilarity(fuzzyConfig.getMinSimilarity());
        }
View Full Code Here

  protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
   
    if (node instanceof FieldQueryNode
        && !(node.getParent() instanceof RangeQueryNode)) {
     
      QueryConfigHandler config = getQueryConfigHandler();
     
      if (config != null) {
        FieldQueryNode fieldNode = (FieldQueryNode) node;
        FieldConfig fieldConfig = config.getFieldConfig(fieldNode
            .getFieldAsString());
       
        if (fieldConfig != null) {
          NumericConfig numericConfig = fieldConfig
              .get(ConfigurationKeys.NUMERIC_CONFIG);
View Full Code Here

    if (node instanceof FieldableNode &&
        (node.getParent() == null || !(node.getParent() instanceof FieldableNode))) {
     
      FieldableNode fieldNode = (FieldableNode) node;
      QueryConfigHandler config = getQueryConfigHandler();

      if (config != null) {
        CharSequence field = fieldNode.getField();
        FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field));

        if (fieldConfig != null) {
          Float boost = fieldConfig.get(ConfigurationKeys.BOOST);

          if (boost != null) {
View Full Code Here

   * @param fuzzyPrefixLength
   *          The fuzzyPrefixLength to set.
   */
  @Override
  public void setFuzzyPrefixLength(int fuzzyPrefixLength) {
    QueryConfigHandler config = getQueryConfigHandler();
    FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
   
    if (fuzzyConfig == null) {
      fuzzyConfig = new FuzzyConfig();
      config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
    }

    fuzzyConfig.setPrefixLength(fuzzyPrefixLength);
   
  }
View Full Code Here

   * Set the minimum similarity for fuzzy queries. Default is defined on
   * {@link FuzzyQuery#defaultMinSimilarity}.
   */
  @Override
  public void setFuzzyMinSim(float fuzzyMinSim) {
    QueryConfigHandler config = getQueryConfigHandler();
    FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
   
    if (fuzzyConfig == null) {
      fuzzyConfig = new FuzzyConfig();
      config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
    }

    fuzzyConfig.setMinSimilarity(fuzzyMinSim);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.