Package org.apache.lucene.queryParser

Examples of org.apache.lucene.queryParser.ParseException


   * @return double
   * @throws ParseException
   */
  public double parseDouble() throws ParseException {
    String str = parseArg();
    if (argWasQuoted()) throw new ParseException("Expected double instead of quoted string:" + str);
    double value = Double.parseDouble(str);
    return value;
  }
View Full Code Here


   * @return An int
   * @throws ParseException
   */
  public int parseInt() throws ParseException {
    String str = parseArg();
    if (argWasQuoted()) throw new ParseException("Expected double instead of quoted string:" + str);
    int value = Integer.parseInt(str);
    return value;
  }
View Full Code Here

        // read unquoted literal ended by whitespace ',' or ')'
        // there is no escaping.
        int valStart = sp.pos;
        for (;;) {
          if (sp.pos >= sp.end) {
            throw new ParseException("Missing end to unquoted value starting at " + valStart + " str='" + sp.val +"'");
          }
          char c = sp.val.charAt(sp.pos);
          if (c==')' || c==',' || Character.isWhitespace(c)) {
            val = sp.val.substring(valStart, sp.pos);
            break;
View Full Code Here

        } else {
          // value here is *after* the local params... ask the parser.
          sub = subQuery(qs, null);
          // int subEnd = sub.findEnd(')');
          // TODO.. implement functions to find the end of a nested query
          throw new ParseException("Nested local params must have value in v parameter.  got '" + qs + "'");
        }
      } else {
        throw new ParseException("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
      }
 
      sp.pos += end-start;  // advance past nested query
      nestedQuery = sub.getQuery();
    }
View Full Code Here

    } else if (ch == '$') {
      sp.pos++;
      String param = sp.getId();
      String val = getParam(param);
      if (val == null) {
        throw new ParseException("Missing param " + param + " while parsing function '" + sp.val + "'");
      }

      QParser subParser = subQuery(val, "func");
      if (subParser instanceof FunctionQParser) {
        ((FunctionQParser)subParser).setParseMultipleSources(true);
      }
      Query subQuery = subParser.getQuery();
      if (subQuery instanceof FunctionQuery) {
        valueSource = ((FunctionQuery) subQuery).getValueSource();
      } else {
        valueSource = new QueryValueSource(subQuery, 0.0f);
      }

      /***
       // dereference *simple* argument (i.e., can't currently be a function)
       // In the future we could support full function dereferencing via a stack of ValueSource (or StringParser) objects
      ch = val.length()==0 ? '\0' : val.charAt(0);

      if (ch>='0' && ch<='9'  || ch=='.' || ch=='+' || ch=='-') {
        QueryParsing.StrParser sp = new QueryParsing.StrParser(val);
        Number num = sp.getNumber();
        if (num instanceof Long) {
          valueSource = new LongConstValueSource(num.longValue());
        } else if (num instanceof Double) {
          valueSource = new DoubleConstValueSource(num.doubleValue());
        } else {
          // shouldn't happen
          valueSource = new ConstValueSource(num.floatValue());
        }
      } else if (ch == '"' || ch == '\'') {
        QueryParsing.StrParser sp = new QueryParsing.StrParser(val);
        val = sp.getQuotedString();
        valueSource = new LiteralValueSource(val);
      } else {
        if (val.length()==0) {
          valueSource = new LiteralValueSource(val);
        } else {
          String id = val;
          SchemaField f = req.getSchema().getField(id);
          valueSource = f.getType().getValueSource(f, this);
        }
      }
       ***/

    } else {

      String id = sp.getId();
      if (sp.opt("(")) {
        // a function... look it up.
        ValueSourceParser argParser = req.getCore().getValueSourceParser(id);
        if (argParser==null) {
          throw new ParseException("Unknown function " + id + " in FunctionQuery(" + sp + ")");
        }
        valueSource = argParser.parse(this);
        sp.expect(")");
      }
      else {
View Full Code Here

    }
  }

  private void checkRecurse() throws ParseException {
    if (recurseCount++ >= 100) {
      throw new ParseException("Infinite Recursion detected parsing query '" + qstr + "'");
    }
  }
View Full Code Here

            {
              return new NumericSelectInQuery<Long>(field,tft.getPrecisionStep(),DataType.LONG, new HdfsToSet.TransDate(),file);
            }
          }
       
        throw new ParseException("file type error");


    } catch (Exception e) {
        throw new ParseException(e.toString());
    }
      }
  };
    }
View Full Code Here

        String contains = localParams.get(QueryParsing.V);
        String field=localParams.get(QueryParsing.F);
        return new StringContainsQuery(contains.split(","), field);

    } catch (Exception e) {
        throw new ParseException(e.toString());
    }
      }
  };
    }
View Full Code Here

      eatws();
      int slen = s.length();
      if (val.regionMatches(pos, s, 0, slen)) {
        pos += slen;
      } else {
        throw new ParseException("Expected '" + s + "' at position " + pos + " in '" + val + "'");
      }
    }
View Full Code Here

        }
        return val.substring(id_start, pos);
      }

      if (errMessage != null) {
        throw new ParseException(errMessage + " at pos " + pos + " str='" + val + "'");
      }
      return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.ParseException

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.