當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。