Package org.apache.lucene.queryparser.classic

Examples of org.apache.lucene.queryparser.classic.QueryParser$LookaheadSuccess


    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    QueryParser parser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
        Version.LUCENE_43));
    Query q = parser.parse("Foo*");
    br.setQuery(q);

    BoboBrowser browser = new BoboBrowser(boboMultiReader);
    BrowseResult result = browser.browse(br);

View Full Code Here


    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    QueryParser parser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
        Version.LUCENE_43));
    Query q = parser.parse("Foo*");
    br.setQuery(q);

    BoboBrowser browser = new BoboBrowser(boboMultiReader);
    BrowseResult result = browser.browse(br);

View Full Code Here

    m_indexWriter.commit();

    DirectoryReader reader = DirectoryReader.open(m_indexWriter, true);
    IndexSearcher searcher = new IndexSearcher(reader);
    TopScoreDocCollector docCollector = TopScoreDocCollector.create(100, true);
    QueryParser queryParser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
        Version.LUCENE_43));
    Query query = queryParser.parse("Foo*");
    searcher.search(query, docCollector);
    TopDocs docs = docCollector.topDocs();
    ScoreDoc[] scoreDocs = docs.scoreDocs;

    assertEquals("should be doc 0", 0, scoreDocs[0].doc);
View Full Code Here

    BrowseSelection red = new BrowseSelection(color);
    red.addValue(RED);
    red.addValue(BLUE);
    br.addSelection(red);

    QueryParser parser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
        Version.LUCENE_43));
    Query q = parser.parse("Foo*");
    br.setQuery(q);

    BoboBrowser browser = new BoboBrowser(boboMultiReader);
    BrowseResult result = browser.browse(br);

View Full Code Here

  }

  public void testQueryWithScore() throws Exception {
    BrowseRequest br = new BrowseRequest();
    br.setShowExplanation(false);
    QueryParser parser = new QueryParser(Version.LUCENE_43, "color", new StandardAnalyzer(
        Version.LUCENE_43));
    br.setQuery(parser.parse("color:red OR shape:square"));
    br.setCount(10);
    br.setOffset(0);

    br.setSort(new SortField[] { SortField.FIELD_SCORE });
    BrowseResult res = doTest(br, 4, null, new String[] { "1", "7", "2", "5" });
View Full Code Here

  }

  public void testBrowseWithQuery() {
    try {
      BrowseRequest br = new BrowseRequest();
      QueryParser parser = new QueryParser(Version.LUCENE_43, "shape", new StandardAnalyzer(
          Version.LUCENE_43));
      br.setQuery(parser.parse("square OR circle"));
      br.setCount(10);
      br.setOffset(0);

      BrowseSelection sel = new BrowseSelection("color");
      sel.addValue("red");
View Full Code Here

   * @param qs array of strings containing query expressions
   * @param a  analyzer to use when parsing queries
   * @return array of Lucene queries
   */
  private static Query[] createQueries(List<Object> qs, Analyzer a) {
    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, DocMaker.BODY_FIELD, a);
    List<Object> queries = new ArrayList<Object>();
    for (int i = 0; i < qs.size(); i++)  {
      try {
       
        Object query = qs.get(i);
        Query q = null;
        if (query instanceof String) {
          q = qp.parse((String) query);
         
        } else if (query instanceof Query) {
          q = (Query) query;
         
        } else {
View Full Code Here

    }
               
    private int doSearch(String searchPhrase, int maxNumberOfHits, Version luceneVersion) throws NullPointerException, ParseException, IOException {
        LOG.trace("*** Search Phrase: {} ***", searchPhrase);

        QueryParser parser = new QueryParser(luceneVersion, "contents", analyzer);
        Query query = parser.parse(searchPhrase);
        TopScoreDocCollector collector = TopScoreDocCollector.create(maxNumberOfHits, true);
        indexSearcher.search(query, collector);
        hits = collector.topDocs().scoreDocs;
       
        LOG.trace("*** Search generated {} hits ***", hits.length);
View Full Code Here

    Analyzer analyzer = createAnalyzer(srchOpts);
    if (analyzer == null) {
      return null;
    }
    String defField = getDefaultField(srchOpts);
    QueryParser qp = new QueryParser(defField, analyzer);
    Object ckXmlParser = find(srchOpts, "ckXmlParser");
    Object ckWild = find(srchOpts, "ckWild");
    Object ckPosIncr = find(srchOpts, "ckPosIncr");
    Object ckLoExp = find(srchOpts, "ckLoExp");
    Object cbDateRes = find(srchOpts, "cbDateRes");
    DateTools.Resolution resolution = Util.getResolution(getString(cbDateRes, "text"));
    Object cbOp = find(srchOpts, "cbOp");
    Object bqMaxCount = find(srchOpts, "bqMaxCount");
    int maxCount = 1024;
    try {
      maxCount = Integer.parseInt(getString(bqMaxCount, "text"));
    } catch (Exception e) {
      e.printStackTrace();
      showStatus("Invalid BooleanQuery max clause count, using default 1024");
    }
    QueryParser.Operator op;
    BooleanQuery.setMaxClauseCount(maxCount);
    String opString = getString(cbOp, "text");
    if (opString.equalsIgnoreCase("OR")) {
      op = QueryParser.OR_OPERATOR;
    } else {
      op = QueryParser.AND_OPERATOR;
    }
    qp.setAllowLeadingWildcard(getBoolean(ckWild, "selected"));
    qp.setEnablePositionIncrements(getBoolean(ckPosIncr, "selected"));
    qp.setLowercaseExpandedTerms(getBoolean(ckLoExp, "selected"));
    qp.setDateResolution(resolution);
    qp.setDefaultOperator(op);
    if (getBoolean(ckXmlParser, "selected")) {
     
      CoreParser cp = createParser(defField,analyzer);
      Query q = cp.parse(new ByteArrayInputStream(queryString.getBytes("UTF-8")));
      return q;
    } else {
      return qp.parse(queryString);
    }
  }
View Full Code Here

        String realQuery = queryStr.substring(start, end);
        LOG.debug("Realquery [{0}]", realQuery);
        String superQueryStr = getMatchText(realQuery);
        LOG.debug("Parseable sub query [{0}]", superQueryStr);
        String key = _prefixToSub + _subQueryIndex;
        QueryParser newParser = getNewParser();
        Query query = newParser.parse(superQueryStr);
        if (!isSameGroupName(query)) {
          throw new ParseException("Super query [" + superQueryStr + "] cannot reference more than one column family.");
        }
        if (_superSearch) {
          query = newSuperQuery(query);
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryparser.classic.QueryParser$LookaheadSuccess

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.