Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.KeywordAnalyzer


  @Test
  public void testSearchSimiliarity() throws Exception {
    deploy3Indices();
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo: bar");
    final Hits hits = client.search(query, new String[] { INDEX2 });
    assertNotNull(hits);
    assertEquals(4, hits.getHits().size());
    for (final Hit hit : hits.getHits()) {
      LOG.info(hit.getNode() + " -- " + hit.getScore() + " -- " + hit.getDocId());
View Full Code Here


    client.close();
  }

  @Test
  public void testNonExistentShard() throws Exception {
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo: bar");
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    try {
      client.search(query, new String[] { "doesNotExist" });
      fail("Should have failed.");
    } catch (KattaException e) {
View Full Code Here

  @Test
  public void testIndexPattern() throws Exception {
    deploy3Indices();
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo: bar");
    final Hits hits = client.search(query, new String[] { "index[2-3]+" });
    assertNotNull(hits);
    for (final Hit hit : hits.getHits()) {
      writeToLog(hit);
    }
View Full Code Here

        docFreq.addNumDocs(23);
        // docFreq.
        return docFreq;
      }
    };
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo: bar");
    client.search(query, new String[] { INDEX_NAME }, 10, null);
    // client.search(query, new String[] { INDEX_NAME }, 10, new Sort(new
    // SortField("foo", SortField.STRING)));
    client.close();
  }
View Full Code Here

  throws CorruptIndexException, LockObtainFailedException, IOException {
    // Make sure we use a MergePolicy which merges segments in-order and thus
    // keeps the doc IDs ordered as well (this is crucial for the taxonomy
    // index).
    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_30,
        new KeywordAnalyzer()).setOpenMode(openMode).setMergePolicy(
        new LogByteSizeMergePolicy());
    indexWriter = new IndexWriter(directory, config);
  }
View Full Code Here

    AnalyzerAttribute analyzerAttr = config
        .addAttribute(AnalyzerAttribute.class);

    Assert.assertTrue(null == analyzerAttr.getAnalyzer());
    Assert.assertTrue(null == config.get(ConfigurationKeys.ANALYZER));
    Analyzer analyzer = new KeywordAnalyzer();
    analyzerAttr.setAnalyzer(analyzer);
    Assert.assertTrue(analyzer == analyzerAttr.getAnalyzer());
    Assert.assertTrue(analyzer == config.get(ConfigurationKeys.ANALYZER));

    DateResolutionAttribute dateResAttr = config
View Full Code Here

    assertQueryEquals("term term term", null, "term term term");
    assertQueryEquals("t�rm term term", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false),
        "t�rm term term");
    assertQueryEquals("�mlaut", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false), "�mlaut");

    assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
    assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");

    assertQueryEquals("a AND b", null, "+a +b");
    assertQueryEquals("(a AND b)", null, "+a +b");
    assertQueryEquals("c OR (a AND b)", null, "c (+a +b)");
View Full Code Here

  public void testSimple() throws Exception {
    assertQueryEquals("term term term", null, "term term term");
    assertQueryEquals("türm term term", new MockAnalyzer(random), "türm term term");
    assertQueryEquals("ümlaut", new MockAnalyzer(random), "ümlaut");

    assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
    assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");

    assertQueryEquals("a AND b", null, "+a +b");
    assertQueryEquals("(a AND b)", null, "+a +b");
    assertQueryEquals("c OR (a AND b)", null, "c (+a +b)");
    assertQueryEquals("a AND NOT b", null, "+a -b");
View Full Code Here

   
    private static void initIndex(Directory directory, int nDocs, boolean create, String contents2) throws IOException {
        IndexWriter indexWriter=null;
       
        try {
            indexWriter=new IndexWriter(directory, new KeywordAnalyzer(), create);
           
            for (int i=0; i<nDocs; i++) {
                indexWriter.addDocument(createDocument("doc" + i, contents2));
            }
        } finally {
View Full Code Here

   
    private static void initIndex(Directory directory, int nDocs, boolean create, String contents2) throws IOException {
        IndexWriter indexWriter=null;
       
        try {
            indexWriter=new IndexWriter(directory, new KeywordAnalyzer(), create);
           
            for (int i=0; i<nDocs; i++) {
                indexWriter.addDocument(createDocument("doc" + i, contents2));
            }
        } finally {
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.KeywordAnalyzer

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.