Examples of WhitespaceAnalyzer


Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

  }

  public void testFarsiRangeCollating() throws Exception {

    RAMDirectory ramDir = new RAMDirectory();
    IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
        IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
        Field.Index.NOT_ANALYZED));
    iw.addDocument(doc);
    iw.close();
    IndexSearcher is = new IndexSearcher(ramDir, true);

    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new WhitespaceAnalyzer());

    // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
    // RuleBasedCollator. However, the Arabic Locale seems to order the
    // Farsi
    // characters properly.
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

        + "}", "{" + getDate(startDate, resolution) + " TO "
        + getDate(endDate, resolution) + "}");
  }

  public void testEscaped() throws Exception {
    Analyzer a = new WhitespaceAnalyzer();

    /*
     * assertQueryEquals("\\[brackets", a, "\\[brackets");
     * assertQueryEquals("\\[brackets", null, "brackets");
     * assertQueryEquals("\\\\", a, "\\\\"); assertQueryEquals("\\+blah", a,
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

    // LUCENE-1189
    assertQueryEquals("(\"a\\\\\") or (\"b\")", a, "a\\ or b");
  }

  public void testQueryStringEscaping() throws Exception {
    Analyzer a = new WhitespaceAnalyzer();

    assertEscapedQueryEquals("a-b:c", a, "a\\-b\\:c");
    assertEscapedQueryEquals("a+b:c", a, "a\\+b\\:c");
    assertEscapedQueryEquals("a:b:c", a, "a\\:b\\:c");
    assertEscapedQueryEquals("a\\b:c", a, "a\\\\b\\:c");
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

    assertQueryNodeException("secret AND illegal) AND access:confidential");   
  }

  public void testCustomQueryParserWildcard() {
    try {
      new QPTestParser(new WhitespaceAnalyzer()).parse("a?t", "contents");
      fail("Wildcard queries should not be allowed");
    } catch (QueryNodeException expected) {
      // expected exception
    }
  }
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

    }
  }

  public void testCustomQueryParserFuzzy() throws Exception {
    try {
      new QPTestParser(new WhitespaceAnalyzer()).parse("xunit~", "contents");
      fail("Fuzzy queries should not be allowed");
    } catch (QueryNodeException expected) {
      // expected exception
    }
  }
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

  public void testBooleanQuery() throws Exception {
    BooleanQuery.setMaxClauseCount(2);
    try {
      StandardQueryParser qp = new StandardQueryParser();
      qp.setAnalyzer(new WhitespaceAnalyzer());

      qp.parse("one two three", "field");
      fail("ParseException expected due to too many boolean clauses");
    } catch (QueryNodeException expected) {
      // too many boolean clauses, so ParseException is expected
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

  /**
   * This test differs from TestPrecedenceQueryParser
   */
  public void testPrecedence() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new WhitespaceAnalyzer());

    Query query1 = qp.parse("A AND B OR C AND D", "field");
    Query query2 = qp.parse("+A +B +C +D", "field");

    assertEquals(query1, query2);
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

  }

  public void testLocalDateFormat() throws IOException, QueryNodeException {

    RAMDirectory ramDir = new RAMDirectory();
    IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
        IndexWriter.MaxFieldLength.LIMITED);
    addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
    addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
    iw.close();
    IndexSearcher is = new IndexSearcher(ramDir, true);
View Full Code Here

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

    }
  }

  public void testMatchAllDocs() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new WhitespaceAnalyzer());

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

Examples of org.apache.lucene.analysis.WhitespaceAnalyzer

  }

  private void assertHits(int expected, String query, IndexSearcher is)
      throws IOException, QueryNodeException {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new WhitespaceAnalyzer());
    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
TOP
Copyright © 2018 www.massapi.com. 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.