Package org.apache.lucene.queryParser

Examples of org.apache.lucene.queryParser.ParseException


          userAccessTokens = getAccessTokens(authenticatedUserName);
        }
        catch (IOException e)
        {
          LOG.error("IO exception communicating with MCF authority service: "+e.getMessage(),e);
          throw new ParseException("IO exception communicating with MCF authority service: "+e.getMessage());
        }
      }

      BooleanQuery bq = new BooleanQuery();
      //bf.setMaxClauseCount(100000);
View Full Code Here


            while ((t = ts.next(t)) != null) {
                count++;
                isCJ = StandardTokenizer.TOKEN_TYPES[StandardTokenizer.CJ].equals(t.type());
            }
        } catch (IOException e) {
            throw new ParseException(e.getMessage());
        } finally {
            try {
                ts.close();
            } catch (IOException e) {
                // ignore
View Full Code Here

    @Override
    protected Query getWildcardQuery(String field, String termStr) throws ParseException {
        if (isMetaKeywordField(field) || isIndexedAsKeyword(field)) {
          if (!getAllowLeadingWildcard() && (termStr.startsWith("*") || termStr.startsWith("?"))) {
              throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
          }
          Term t = new Term(field, termStr);
          return newWildcardQuery(t);
        } else {
            return super.getWildcardQuery(field, termStr);
View Full Code Here

    @Override
    protected Query getPrefixQuery(String field, String termStr) throws ParseException {
        if (isMetaKeywordField(field) || isIndexedAsKeyword(field)) {
            if (!getAllowLeadingWildcard() && termStr.startsWith("*")) {
                throw new ParseException("'*' not allowed as first character in PrefixQuery");
            }
            Term t = new Term(field, termStr);
            return newPrefixQuery(t);
        } else {
            return super.getPrefixQuery(field, termStr);
View Full Code Here

                count++;
                isCJ = StandardTokenizer.TOKEN_TYPES[StandardTokenizer.CJ].equals(t.type());
            }
            ts.end();
        } catch (IOException e) {
            throw new ParseException(e.getMessage());
        } finally {
            try {
                ts.close();
            } catch (IOException e) {
                // ignore
View Full Code Here

    }

    if (countTokens != tlist.size()) {
      /* this means that the analyzer used either added or consumed
       * (common for a stemmer) tokens, and we can't build a WildcardQuery */
      throw new ParseException("Cannot build WildcardQuery with analyzer "
          + getAnalyzer().getClass() + " - tokens added or lost");
    }

    if (tlist.size() == 0) {
      return null;
View Full Code Here

    if (tlist.size() == 1) {
      return super.getPrefixQuery(field, (String) tlist.get(0));
    } else {
      /* this means that the analyzer used consumed the only token we had,
       * and we can't build a PrefixQuery */
      throw new ParseException("Cannot build PrefixQuery with analyzer "
          + getAnalyzer().getClass() + " - token was consumed");
    }
  }
View Full Code Here

    } catch (IOException e) {
      // ignore
    }

    if (multipleTokens) {
      throw new ParseException("Cannot build FuzzyQuery with analyzer " + getAnalyzer().getClass()
          + " - tokens were added");
    }

    return (t == null) ? null : super.getFuzzyQuery(field, t.termText(), minSimilarity);
  }
View Full Code Here

      source.close();
    } catch (IOException e) {
      // ignore
    }
    if (multipleTokens) {
      throw new ParseException("Cannot build RangeQuery with analyzer " + getAnalyzer().getClass()
          + " - tokens were added to part1");
    }

    source = getAnalyzer().tokenStream(field, new StringReader(part2));
    // part2
    try {
      t = source.next();
      if (t != null) {
        part2 = t.termText();
      }
      multipleTokens = source.next() != null;
    } catch (IOException e) {
      t = null;
    }
    try {
      source.close();
    } catch (IOException e) {
      // ignore
    }
    if (multipleTokens) {
      throw new ParseException("Cannot build RangeQuery with analyzer " + getAnalyzer().getClass()
          + " - tokens were added to part2");
    }
    return super.getRangeQuery(field, part1, part2, inclusive);
  }
View Full Code Here

                count++;
                isCJ = StandardTokenizer.TOKEN_TYPES[StandardTokenizer.CJ].equals(t.type());
            }
            ts.end();
        } catch (IOException e) {
            throw new ParseException(e.getMessage());
        } finally {
            try {
                ts.close();
            } catch (IOException e) {
                // ignore
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.