Package org.apache.lucene.queryParser.standard

Examples of org.apache.lucene.queryParser.standard.StandardQueryParser

The syntax for query strings is as follows (copied from the old QueryParser javadoc):

The text parser used by this helper is a {@link StandardSyntaxParser}.

The query node processor used by this helper is a {@link StandardQueryNodeProcessorPipeline}.

The builder used by this helper is a {@link StandardQueryTreeBuilder}.

@see StandardQueryParser @see StandardQueryConfigHandler @see StandardSyntaxParser @see StandardQueryNodeProcessorPipeline @see StandardQueryTreeBuilder


          expectedPositions[i], pos[i]);
    }
  }

  public void testMatchAllDocs() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));

    assertEquals(new MatchAllDocsQuery(), qp.parse("*:*", "field"));
    assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)", "field"));
    BooleanQuery bq = (BooleanQuery) qp.parse("+*:* -*:*", "field");
    assertTrue(bq.getClauses()[0].getQuery() instanceof MatchAllDocsQuery);
    assertTrue(bq.getClauses()[1].getQuery() instanceof MatchAllDocsQuery);
  }
View Full Code Here


    assertTrue(bq.getClauses()[1].getQuery() instanceof MatchAllDocsQuery);
  }

  private void assertHits(int expected, String query, IndexSearcher is)
      throws IOException, QueryNodeException {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
    qp.setLocale(Locale.ENGLISH);

    Query q = qp.parse(query, "date");
    ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
    assertEquals(expected, hits.length);
  }
View Full Code Here

    doc.add(newField("field", "", Field.Store.NO, Field.Index.ANALYZED));
    w.addDocument(doc);
    IndexReader r = IndexReader.open(w, true);
    IndexSearcher s = newSearcher(r);
   
    Query q = new StandardQueryParser(new CannedAnalyzer()).parse("\"a\"", "field");
    assertTrue(q instanceof MultiPhraseQuery);
    assertEquals(1, s.search(q, 10).totalHits);
    s.close();
    r.close();
    w.close();
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.standard.StandardQueryParser

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.