Package org.apache.lucene.analysis.core

Examples of org.apache.lucene.analysis.core.WhitespaceAnalyzer


  @Test
  public void testLuceneSpecialCharacter()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    /*
     * Test special tilde character
     */
 
View Full Code Here


  @Test
  public void testPhraseQuery()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    final Query q = npq("a", "simple", "literal").setDatatype("ws")
                    .getLuceneProxyQuery();
    this._assertSirenQuery(config, q, "ws(\"a simple literal\")");
View Full Code Here

  @Test
  public void testTwigQueryDatatype()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    dts.put(JSONDatatype.JSON_FIELD, new StandardAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    // json:field is always applied on the top level node of the twig.
    final Query q = twq(1).root(ntq("aaa"))
View Full Code Here

  @Test
  public void testTwigQueryDatatypeOnRoot()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    // json:field is always applied on the top level node of the twig.
    final Query q = twq(1).root(ntq("AAA").setDatatype("ws"))
                          .with(ntq("b").setDatatype("ws"))
View Full Code Here

  @Test
  public void testTwigComplement2()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    dts.put(JSONDatatype.JSON_FIELD, new StandardAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    final Query bq = bq(must(
      twq(1)
View Full Code Here

  @Test
  public void testTwigQueryLineFeed()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> dts = new HashMap<String, Analyzer>();
    dts.put(XSDDatatype.XSD_STRING, new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    dts.put("ws", new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dts);

    final Query bq = bq(must(
      twq(1)
            .with(ntq("literal"))), must(
View Full Code Here

  @Override
  protected void configure() throws IOException {
    final AnyURIAnalyzer uriAnalyzer = new AnyURIAnalyzer(TEST_VERSION_CURRENT);
    final TupleAnalyzer tupleAnalyzer = new TupleAnalyzer(TEST_VERSION_CURRENT,
      new WhitespaceAnalyzer(TEST_VERSION_CURRENT), uriAnalyzer);
    tupleAnalyzer.registerDatatype(XSDDatatype.XSD_ANY_URI.toCharArray(), uriAnalyzer);
    this.setAnalyzer(tupleAnalyzer);
    this.setPostingsFormat(PostingsFormatType.RANDOM);
  }
View Full Code Here

   */
  @Test
  public void testLanguage2()
  throws Exception {
    _a.registerDatatype("en".toCharArray(), new StandardAnalyzer(TEST_VERSION_CURRENT));
    _a.registerDatatype("fr".toCharArray(), new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
    this.assertAnalyzesTo(_a, "\"Test Test2\"@en <aaa> \"Test Test2\"@fr",
      new String[] { "test", "test2", "aaa", "Test", "Test2" },
      new String[] { "<ALPHANUM>", "<ALPHANUM>", "word", "word", "word" });
    _a.clearDatatypes();
  }
View Full Code Here

  }

  @Test
  public void testAlreadyRegisteredAnalyzer()
  throws Exception {
    _a.registerDatatype("en".toCharArray(), new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
    // this analyzer is not used, as the datatype "en" is already to an analyzer
    _a.registerDatatype("en".toCharArray(), new StandardAnalyzer(TEST_VERSION_CURRENT));
    this.assertAnalyzesTo(_a, "\"Test tesT2\"@en", new String[] { "Test", "tesT2" }, new String[] { "word", "word" });
    _a.clearDatatypes();
  }
View Full Code Here

  }

  private Map<String, Analyzer> getDatatypeAnalyzers() {
    final Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
    analyzers.put(XSDDatatype.XSD_STRING, new StandardAnalyzer(Version.LUCENE_40));
    analyzers.put(JSONDatatype.JSON_FIELD, new WhitespaceAnalyzer(Version.LUCENE_40));
    return analyzers;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.core.WhitespaceAnalyzer

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.