当前位置: 首页>>代码示例>>Java>>正文


Java Version.LUCENE_4_9属性代码示例

本文整理汇总了Java中org.apache.lucene.util.Version.LUCENE_4_9属性的典型用法代码示例。如果您正苦于以下问题:Java Version.LUCENE_4_9属性的具体用法?Java Version.LUCENE_4_9怎么用?Java Version.LUCENE_4_9使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.lucene.util.Version的用法示例。


在下文中一共展示了Version.LUCENE_4_9属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LuceneService

public LuceneService() {
    try {
        this.keySerializer = new ObjectMapper();
        keySerializer.setVisibility(
                keySerializer.getSerializationConfig().
                        getDefaultVisibilityChecker().
                        withFieldVisibility(JsonAutoDetect.Visibility.ANY).
                        withGetterVisibility(JsonAutoDetect.Visibility.NONE).
                        withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)
        );

        indexDirectory = new RAMDirectory();
        analyzer = new StandardAnalyzer(Version.LUCENE_4_9);

        IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        indexWriter = new IndexWriter(indexDirectory, iwc);
        commit();
    } catch (IOException e) {
        throw new IndexingException(errorMessage(
                "could not create full-text index", 0), e);
    } catch (VirtualMachineError vme) {
        handleVirtualMachineError(vme);
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:25,代码来源:LuceneService.java

示例2: deleteIndexesByField

@Override
public void deleteIndexesByField(String field) {
    if (!isNullOrEmpty(field)) {
        try {
            Query query;
            QueryParser parser = new QueryParser(Version.LUCENE_4_9, field, analyzer);
            parser.setAllowLeadingWildcard(true);
            try {
                query = parser.parse("*");
            } catch (ParseException e) {
                throw new IndexingException(errorMessage(
                        "could not remove full-text index for value " + field, 0));
            }

            synchronized (this) {
                indexWriter.deleteDocuments(query);
                commit();
            }
        } catch (IOException ioe) {
            throw new IndexingException(errorMessage(
                    "could not remove full-text index for value " + field, 0));
        } catch (VirtualMachineError vme) {
            handleVirtualMachineError(vme);
        }
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:26,代码来源:LuceneService.java

示例3: init

public void init(String db, String uri, String lucene) {

    	Dataset ds = TDBFactory.createDataset(db);
        
        // Lucene configuration
        try {
            Directory luceneDir = FSDirectory.open(new File(lucene));
            EntityDefinition entDef = new EntityDefinition("comment", "text", RDFS.comment);
            // Set uid in order to remove index entries automatically
            entDef.setUidField("uid");
            StandardAnalyzer stAn = new StandardAnalyzer(Version.LUCENE_4_9);
            dataset = TextDatasetFactory.createLucene(ds, luceneDir, entDef, stAn);
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        baseURI = uri;
        servers = new ArrayList<>();
        tdQueue = new PriorityQueue<ThingDescription>();
        loadTDQueue();
    }
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:23,代码来源:ThingDirectory.java

示例4: drop

@Override
public void drop() {
    try {
        indexDirectory = new RAMDirectory();
        analyzer = new StandardAnalyzer(Version.LUCENE_4_9);

        IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        indexWriter = new IndexWriter(indexDirectory, iwc);
        commit();
    } catch (IOException e) {
        throw new IndexingException(errorMessage(
                "could not drop full-text index", 0), e);
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:15,代码来源:LuceneService.java

示例5: searchByIndex

@Override
public Set<NitriteId> searchByIndex(String field, String searchString) {
    IndexReader indexReader = null;
    try {
        QueryParser parser = new QueryParser(Version.LUCENE_4_9, field, analyzer);
        parser.setAllowLeadingWildcard(true);
        Query query = parser.parse("*" + searchString + "*");

        indexReader = DirectoryReader.open(indexDirectory);
        IndexSearcher indexSearcher = new IndexSearcher(indexReader);

        TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_SEARCH, true);
        indexSearcher.search(query, collector);

        TopDocs hits = collector.topDocs(0, MAX_SEARCH);

        Set<NitriteId> keySet = new LinkedHashSet<>();
        if (hits != null) {
            ScoreDoc[] scoreDocs = hits.scoreDocs;
            if (scoreDocs != null) {
                for (ScoreDoc scoreDoc : scoreDocs) {
                    Document document = indexSearcher.doc(scoreDoc.doc);
                    String jsonId = document.get(CONTENT_ID);
                    NitriteId nitriteId = keySerializer.readValue(jsonId, NitriteId.class);
                    keySet.add(nitriteId);
                }
            }
        }

        return keySet;
    } catch (IOException | ParseException e) {
        throw new IndexingException(errorMessage(
                "could not search on full-text index", 0), e);
    } finally {
        try {
            if (indexReader != null) indexReader.close();
        } catch (IOException ignored) {
            // ignored
        }
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:41,代码来源:LuceneService.java


注:本文中的org.apache.lucene.util.Version.LUCENE_4_9属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。