Search in sources :

Example 46 with StandardAnalyzer

use of org.apache.lucene.analysis.standard.StandardAnalyzer in project geode by apache.

the class PartitionedRepositoryManagerJUnitTest method createIndexAndRepoManager.

protected void createIndexAndRepoManager() {
    fileAndChunkRegion = Mockito.mock(PartitionedRegion.class);
    fileDataStore = Mockito.mock(PartitionedRegionDataStore.class);
    when(fileAndChunkRegion.getDataStore()).thenReturn(fileDataStore);
    when(fileAndChunkRegion.getTotalNumberOfBuckets()).thenReturn(113);
    when(fileAndChunkRegion.getFullPath()).thenReturn("FileRegion");
    indexStats = Mockito.mock(LuceneIndexStats.class);
    fileSystemStats = Mockito.mock(FileSystemStats.class);
    indexForPR = Mockito.mock(LuceneIndexForPartitionedRegion.class);
    when(((LuceneIndexForPartitionedRegion) indexForPR).getFileAndChunkRegion()).thenReturn(fileAndChunkRegion);
    when(((LuceneIndexForPartitionedRegion) indexForPR).getFileSystemStats()).thenReturn(fileSystemStats);
    when(indexForPR.getIndexStats()).thenReturn(indexStats);
    when(indexForPR.getAnalyzer()).thenReturn(new StandardAnalyzer());
    when(indexForPR.getCache()).thenReturn(cache);
    when(indexForPR.getRegionPath()).thenReturn("/testRegion");
    repoManager = new PartitionedRepositoryManager(indexForPR, serializer);
    repoManager.setUserRegionForRepositoryManager();
    repoManager.allowRepositoryComputation();
}
Also used : PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) FileSystemStats(org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore)

Example 47 with StandardAnalyzer

use of org.apache.lucene.analysis.standard.StandardAnalyzer in project geode by apache.

the class RawLuceneRepositoryManagerJUnitTest method createIndexAndRepoManager.

protected void createIndexAndRepoManager() {
    LuceneServiceImpl.luceneIndexFactory = new LuceneRawIndexFactory();
    indexStats = Mockito.mock(LuceneIndexStats.class);
    indexForPR = Mockito.mock(LuceneRawIndex.class);
    when(indexForPR.getIndexStats()).thenReturn(indexStats);
    when(indexForPR.getAnalyzer()).thenReturn(new StandardAnalyzer());
    when(indexForPR.getCache()).thenReturn(cache);
    when(indexForPR.getRegionPath()).thenReturn("/testRegion");
    when(indexForPR.withPersistence()).thenReturn(true);
    repoManager = new RawLuceneRepositoryManager(indexForPR, serializer);
    repoManager.setUserRegionForRepositoryManager();
    repoManager.allowRepositoryComputation();
}
Also used : StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer)

Example 48 with StandardAnalyzer

use of org.apache.lucene.analysis.standard.StandardAnalyzer in project geode by apache.

the class LuceneIndexCommandsDUnitTest method createIndex.

private void createIndex(final VM vm1) {
    vm1.invoke(() -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        Map<String, Analyzer> fieldAnalyzers = new HashMap();
        fieldAnalyzers.put("field1", new StandardAnalyzer());
        fieldAnalyzers.put("field2", new KeywordAnalyzer());
        fieldAnalyzers.put("field3", null);
        luceneService.createIndexFactory().setFields(fieldAnalyzers).create(INDEX_NAME, REGION_NAME);
        createRegion();
    });
}
Also used : KeywordAnalyzer(org.apache.lucene.analysis.core.KeywordAnalyzer) HashMap(java.util.HashMap) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) KeywordAnalyzer(org.apache.lucene.analysis.core.KeywordAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) LuceneService(org.apache.geode.cache.lucene.LuceneService)

Example 49 with StandardAnalyzer

use of org.apache.lucene.analysis.standard.StandardAnalyzer in project jackrabbit by apache.

the class IndexMigrationTest method testMigration.

public void testMigration() throws Exception {
    List<Document> docs = new ArrayList<Document>();
    docs.add(createDocument("ab", "a"));
    docs.add(createDocument("a", "b"));
    docs.add(createDocument("abcd", "c"));
    docs.add(createDocument("abc", "d"));
    DirectoryManager dirMgr = new RAMDirectoryManager();
    PersistentIndex idx = new PersistentIndex("index", new StandardAnalyzer(Version.LUCENE_36), Similarity.getDefault(), new DocNumberCache(100), new IndexingQueue(new IndexingQueueStore(new RAMDirectory())), dirMgr, 0);
    idx.addDocuments(docs.toArray(new Document[docs.size()]));
    idx.commit();
    IndexMigration.migrate(idx, dirMgr, SEP_CHAR);
}
Also used : RAMDirectoryManager(org.apache.jackrabbit.core.query.lucene.directory.RAMDirectoryManager) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) ArrayList(java.util.ArrayList) DirectoryManager(org.apache.jackrabbit.core.query.lucene.directory.DirectoryManager) RAMDirectoryManager(org.apache.jackrabbit.core.query.lucene.directory.RAMDirectoryManager) Document(org.apache.lucene.document.Document) RAMDirectory(org.apache.lucene.store.RAMDirectory)

Example 50 with StandardAnalyzer

use of org.apache.lucene.analysis.standard.StandardAnalyzer in project lucene-solr by apache.

the class SimpleQQParser method parse.

/* (non-Javadoc)
   * @see org.apache.lucene.benchmark.quality.QualityQueryParser#parse(org.apache.lucene.benchmark.quality.QualityQuery)
   */
@Override
public Query parse(QualityQuery qq) throws ParseException {
    QueryParser qp = queryParser.get();
    if (qp == null) {
        qp = new QueryParser(indexField, new StandardAnalyzer());
        queryParser.set(qp);
    }
    BooleanQuery.Builder bq = new BooleanQuery.Builder();
    for (int i = 0; i < qqNames.length; i++) bq.add(qp.parse(QueryParserBase.escape(qq.getValue(qqNames[i]))), BooleanClause.Occur.SHOULD);
    return bq.build();
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) QueryParser(org.apache.lucene.queryparser.classic.QueryParser) QualityQueryParser(org.apache.lucene.benchmark.quality.QualityQueryParser) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer)

Aggregations

StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)112 Analyzer (org.apache.lucene.analysis.Analyzer)37 IndexWriter (org.apache.lucene.index.IndexWriter)36 Document (org.apache.lucene.document.Document)29 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)29 IndexSearcher (org.apache.lucene.search.IndexSearcher)24 Term (org.apache.lucene.index.Term)22 RAMDirectory (org.apache.lucene.store.RAMDirectory)21 Test (org.junit.Test)21 Query (org.apache.lucene.search.Query)20 BooleanQuery (org.apache.lucene.search.BooleanQuery)19 TermQuery (org.apache.lucene.search.TermQuery)19 IOException (java.io.IOException)16 Before (org.junit.Before)15 IndexReader (org.apache.lucene.index.IndexReader)14 HashMap (java.util.HashMap)13 Field (org.apache.lucene.document.Field)13 ArrayList (java.util.ArrayList)12 QueryParser (org.apache.lucene.queryparser.classic.QueryParser)12 Directory (org.apache.lucene.store.Directory)12