Package org.apache.lucene.queryParser.core.nodes

Examples of org.apache.lucene.queryParser.core.nodes.FieldableNode


  protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

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

      if (config != null) {
        FieldConfig fieldConfig = config.getFieldConfig(fieldNode.getField());

        if (fieldConfig != null && fieldConfig.hasAttribute(BoostAttribute.class)) {
          BoostAttribute boostAttr = fieldConfig.getAttribute(BoostAttribute.class);

          return new BoostQueryNode(node, boostAttr.getBoost());
View Full Code Here


  @Override
  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

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

    if (node instanceof FieldableNode) {
      this.processChildren = false;
      FieldableNode fieldNode = (FieldableNode) node;

      if (fieldNode.getField() == null) {
        CharSequence[] fields = getQueryConfigHandler().get(ConfigurationKeys.MULTI_FIELDS);

        if (fields == null) {
          throw new IllegalArgumentException(
              "StandardQueryConfigHandler.ConfigurationKeys.MULTI_FIELDS should be set on the QueryConfigHandler");
        }

        if (fields != null && fields.length > 0) {
          fieldNode.setField(fields[0]);

          if (fields.length == 1) {
            return fieldNode;

          } else {
            LinkedList<QueryNode> children = new LinkedList<QueryNode>();
            children.add(fieldNode);

            for (int i = 1; i < fields.length; i++) {
              try {
                fieldNode = (FieldableNode) fieldNode.cloneTree();
                fieldNode.setField(fields[i]);

                children.add(fieldNode);

              } catch (CloneNotSupportedException e) {
                // should never happen
View Full Code Here

  protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

    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);
View Full Code Here

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

    if (node instanceof FieldableNode) {
      this.processChildren = false;
      FieldableNode fieldNode = (FieldableNode) node;

      if (fieldNode.getField() == null) {

        if (!getQueryConfigHandler().hasAttribute(MultiFieldAttribute.class)) {
          throw new IllegalArgumentException(
              "MultiFieldAttribute should be set on the QueryConfigHandler");
        }

        CharSequence[] fields = getQueryConfigHandler().getAttribute(
            MultiFieldAttribute.class).getFields();

        if (fields != null && fields.length > 0) {
          fieldNode.setField(fields[0]);

          if (fields.length == 1) {
            return fieldNode;

          } else {
            LinkedList<QueryNode> children = new LinkedList<QueryNode>();
            children.add(fieldNode);

            for (int i = 1; i < fields.length; i++) {
              try {
                fieldNode = (FieldableNode) fieldNode.cloneTree();
                fieldNode.setField(fields[i]);

                children.add(fieldNode);

              } catch (CloneNotSupportedException e) {
                // should never happen
View Full Code Here

  protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

    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 && fieldConfig.hasAttribute(BoostAttribute.class)) {
          BoostAttribute boostAttr = fieldConfig.getAttribute(BoostAttribute.class);
View Full Code Here

  @Override
  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.hasAttribute(UniqueFieldAttribute.class)) {
        throw new IllegalArgumentException(
            "UniqueFieldAttribute should be defined in the config handler!");
      }

      CharSequence uniqueField = queryConfig.getAttribute(
          UniqueFieldAttribute.class).getUniqueField();

      fieldNode.setField(uniqueField);

    }

    return node;
View Full Code Here

  protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

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

      if (config != null) {
        FieldConfig fieldConfig = config.getFieldConfig(fieldNode.getField());

        if (fieldConfig != null && fieldConfig.hasAttribute(BoostAttribute.class)) {
          BoostAttribute boostAttr = (BoostAttribute) fieldConfig.getAttribute(BoostAttribute.class);

          return new BoostQueryNode(node, boostAttr.getBoost());
View Full Code Here

  protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

    if (node instanceof FieldableNode) {
      this.processChildren = false;
      FieldableNode fieldNode = (FieldableNode) node;

      if (fieldNode.getField() == null) {

        if (!getQueryConfigHandler().hasAttribute(MultiFieldAttribute.class)) {
          throw new IllegalArgumentException(
              "MultiFieldAttribute should be set on the QueryConfigHandler");
        }

        CharSequence[] fields = ((MultiFieldAttribute) getQueryConfigHandler()
            .getAttribute(MultiFieldAttribute.class)).getFields();

        if (fields != null && fields.length > 0) {
          fieldNode.setField(fields[0]);

          if (fields.length == 1) {
            return fieldNode;

          } else {
            LinkedList<QueryNode> children = new LinkedList<QueryNode>();
            children.add(fieldNode);

            for (int i = 1; i < fields.length; i++) {
              try {
                fieldNode = (FieldableNode) fieldNode.cloneTree();
                fieldNode.setField(fields[i]);

                children.add(fieldNode);

              } catch (CloneNotSupportedException e) {
                // should never happen
View Full Code Here

  @Override
  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.hasAttribute(UniqueFieldAttribute.class)) {
        throw new IllegalArgumentException(
            "UniqueFieldAttribute should be defined in the config handler!");
      }

      CharSequence uniqueField = ((UniqueFieldAttribute) queryConfig
          .getAttribute(UniqueFieldAttribute.class)).getUniqueField();

      fieldNode.setField(uniqueField);

    }

    return node;
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.core.nodes.FieldableNode

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.