Lucene in 5 minutes.

本文将介绍如何使用Lucene库在应用程序中轻松实现全文搜索功能。通过简单的步骤,包括创建索引、构建查询、搜索结果及显示结果,用户能在5分钟内掌握Lucene的基本应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Lucene in 5 minutes


Now updated for Lucene 4.0!

Lucene makes it easy to add full-text search capability to your application. In fact, its so easy, I'm going to show you how in 5 minutes!

1. Index

For this simple case, we're going to create an in-memory index from some strings.

StandardAnalyzer analyzer  =  new StandardAnalyzer (Version. LUCENE_40 ) ;
Directory index  =  new RAMDirectory ( ) ;

IndexWriterConfig config  =  new IndexWriterConfig (Version. LUCENE_40, analyzer ) ;

IndexWriter w  =  new IndexWriter (index, config ) ;
addDoc (w,  "Lucene in Action""193398817" ) ;
addDoc (w,  "Lucene for Dummies""55320055Z" ) ;
addDoc (w,  "Managing Gigabytes""55063554A" ) ;
addDoc (w,  "The Art of Computer Science""9900333X" ) ;
w. close ( ) ;
 

addDoc() is what actually adds documents to the index:

private  static  void addDoc (IndexWriter w,  String title,  String isbn )  throws IOException  {
   Document doc  =  new  Document ( ) ;
  doc. add ( new  TextField ( "title", title,  Field. Store. YES ) ) ;
  doc. add ( new StringField ( "isbn", isbn,  Field. Store. YES ) ) ;
  w. addDocument (doc ) ;
}
 

Note the use of TextField for content we want tokenized, and StringField for id fields and the like, which we don't want tokenized.

2. Query

We read the query from stdin, parse it and build a lucene Query out of it.

String querystr  = args. length  >  0  ? args [ 0 ]  :  "lucene" ;
Query q  =  new QueryParser (Version. LUCENE_40"title", analyzer ). parse (querystr ) ;
 

 

3. Search

Using the Query we create a Searcher to search the index. Then a TopScoreDocCollector is instantiated to collect the top 10 scoring hits.

int hitsPerPage  =  10 ;
IndexReader reader  = IndexReader. open (index ) ;
IndexSearcher searcher  =  new IndexSearcher (reader ) ;
TopScoreDocCollector collector  = TopScoreDocCollector. create (hitsPerPage,  true ) ;
searcher. search (q, collector ) ;
ScoreDoc [ ] hits  = collector. topDocs ( ). scoreDocs ;
 

 

4. Display

Now that we have results from our search, we display the results to the user.

System. out. println ( "Found "  + hits. length  +  " hits." ) ;
for ( int i = 0 ;i <hits. length ;++i )  {
     int docId  = hits [i ]. doc ;
     Document d  = searcher. doc (docId ) ;
     System. out. println ( (+  1 )  +  ". "  + d. get ( "isbn" )  +  "\t"  + d. get ( "title" ) ) ;
}
 



Here's the app in its entirety. Download HelloLucene.java

 

import  org.apache.lucene.analysis.standard.StandardAnalyzer ;
import  org.apache.lucene.document.Document ;
import  org.apache.lucene.document.Field ;
import  org.apache.lucene.document.StringField ;
import  org.apache.lucene.document.TextField ;
import  org.apache.lucene.index.DirectoryReader ;
import  org.apache.lucene.index.IndexReader ;
import  org.apache.lucene.index.IndexWriter ;
import  org.apache.lucene.index.IndexWriterConfig ;
import  org.apache.lucene.queryparser.classic.ParseException ;
import  org.apache.lucene.queryparser.classic.QueryParser ;
import  org.apache.lucene.search.IndexSearcher ;
import  org.apache.lucene.search.Query ;
import  org.apache.lucene.search.ScoreDoc ;
import  org.apache.lucene.search.TopScoreDocCollector ;
import  org.apache.lucene.store.Directory ;
import  org.apache.lucene.store.RAMDirectory ;
import  org.apache.lucene.util.Version ;

import  java.io.IOException ;

public  class HelloLucene  {
   public  static  void main ( String [ ] args )  throws  IOExceptionParseException  {
     // 0. Specify the analyzer for tokenizing text.
     //    The same analyzer should be used for indexing and searching
    StandardAnalyzer analyzer  =  new StandardAnalyzer (Version. LUCENE_40 ) ;

     // 1. create the index
    Directory index  =  new RAMDirectory ( ) ;

    IndexWriterConfig config  =  new IndexWriterConfig (Version. LUCENE_40, analyzer ) ;

    IndexWriter w  =  new IndexWriter (index, config ) ;
    addDoc (w,  "Lucene in Action""193398817" ) ;
    addDoc (w,  "Lucene for Dummies""55320055Z" ) ;
    addDoc (w,  "Managing Gigabytes""55063554A" ) ;
    addDoc (w,  "The Art of Computer Science""9900333X" ) ;
    w. close ( ) ;

     // 2. query
     String querystr  = args. length  >  0  ? args [ 0 ]  :  "lucene" ;

     // the "title" arg specifies the default field to use
     // when no field is explicitly specified in the query.
    Query q  =  new QueryParser (Version. LUCENE_40"title", analyzer ). parse (querystr ) ;

     // 3. search
     int hitsPerPage  =  10 ;
    IndexReader reader  = DirectoryReader. open (index ) ;
    IndexSearcher searcher  =  new IndexSearcher (reader ) ;
    TopScoreDocCollector collector  = TopScoreDocCollector. create (hitsPerPage, true ) ;
    searcher. search (q, collector ) ;
    ScoreDoc [ ] hits  = collector. topDocs ( ). scoreDocs ;
    
     // 4. display results
     System. out. println ( "Found "  + hits. length  +  " hits." ) ;
     for ( int i = 0 ;i <hits. length ;++i )  {
       int docId  = hits [i ]. doc ;
       Document d  = searcher. doc (docId ) ;
       System. out. println ( (+  1 )  +  ". "  + d. get ( "isbn" )  +  "\t"  + d. get ( "title" ) ) ;
     }

     // reader can only be closed when there
     // is no need to access the documents any more.
    reader. close ( ) ;
   }

   private  static  void addDoc (IndexWriter w,  String title,  String isbn )  throws IOException  {
     Document doc  =  new  Document ( ) ;
    doc. add ( new  TextField ( "title", title,  Field. Store. YES ) ) ;

     // use a string field for isbn because we don't want it tokenized
    doc. add ( new StringField ( "isbn", isbn,  Field. Store. YES ) ) ;
    w. addDocument (doc ) ;
   }
}
To use this app from the command line, type  java HelloLucene <query>
[2025-05-12T16:43:47,345][INFO ][o.e.b.Elasticsearch ] [DESKTOP-A854GSO] version[9.0.1], pid[10096], build[zip/73f7594ea00db50aa7e941e151a5b3985f01e364/2025-04-30T10:07:41.393025990Z], OS[Windows 11/10.0/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/24/24+36-3646] [2025-05-12T16:43:47,356][INFO ][o.e.b.Elasticsearch ] [DESKTOP-A854GSO] JVM home [D:\elasticsearch\elasticsearch-9.0.1\jdk], using bundled JDK [true] [2025-05-12T16:43:47,357][INFO ][o.e.b.Elasticsearch ] [DESKTOP-A854GSO] JVM arguments [-Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j2.formatMsgNoLookups=true, -Djava.locale.providers=CLDR, -Dorg.apache.lucene.vectorization.upperJavaFeatureVersion=24, -Des.distribution.type=zip, -Des.java.type=bundled JDK, --enable-native-access=org.elasticsearch.nativeaccess,org.apache.lucene.core, --enable-native-access=ALL-UNNAMED, --illegal-native-access=deny, -XX:ReplayDataFile=logs/replay_pid%p.log, -Des.entitlements.enabled=true, -XX:+EnableDynamicAgentLoading, -Djdk.attach.allowAttachSelf=true, --patch-module=java.base=lib\entitlement-bridge\elasticsearch-entitlement-bridge-9.0.1.jar, --add-exports=java.base/org.elasticsearch.entitlement.bridge=org.elasticsearch.entitlement,java.logging,java.net.http,java.naming,jdk.net, -XX:+UseG1GC, -Djava.io.tmpdir=C:\Users\鍥AppData\Local\Temp\elasticsearch, --add-modules=jdk.incubator.vector, -Dorg.apache.lucene.store.defaultReadAdvice=normal, -XX:+HeapDumpOnOutOfMemoryError, -XX:+ExitOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m, -Xms7778m, -Xmx7778m, -XX:MaxDirectMemorySize=4078960640, -XX:G1HeapRegionSize=4m, -XX:InitiatingHeapOccupancyPercent=30, -XX:G1ReservePercent=15, --module-path=D:\elasticsearch\elasticsearch-9.0.1\lib, --add-modules=jdk.net, --add-modules=jdk.management.agent, --add-modules=ALL-MODULE-PATH, -Djdk.module.main=org.elasticsearch.server] [2025-05-12T16:43:47,358][INFO ][o.e.b.Elasticsearch ] [DESKTOP-A854GSO] Default Locale [zh_CN] [2025-05-12T16:43:47,528][INFO ][o.e.n.NativeAccess ] [DESKTOP-A854GSO] Using [jdk] native provider and native methods for [Windows] [2025-05-12T16:43:47,660][INFO ][o.a.l.i.v.PanamaVectorizationProvider] [DESKTOP-A854GSO] Java vector incubator API enabled; uses preferredBitSize=256; FMA enabled [2025-05-12T16:43:47,802][INFO ][o.e.b.Elasticsearch ] [DESKTOP-A854GSO] Bootstrapping Entitlements [2025-05-12T16:43:52,351][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [repository-url] [2025-05-12T16:43:52,352][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [rest-root] [2025-05-12T16:43:52,352][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-core] [2025-05-12T16:43:52,353][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-redact] [2025-05-12T16:43:52,353][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [ingest-user-agent] [2025-05-12T16:43:52,353][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-async-search] [2025-05-12T16:43:52,354][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-monitoring] [2025-05-12T16:43:52,354][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [repository-s3] [2025-05-12T16:43:52,354][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-analytics] [2025-05-12T16:43:52,354][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-esql-core] [2025-05-12T16:43:52,355][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-ent-search] [2025-05-12T16:43:52,355][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-autoscaling] [2025-05-12T16:43:52,355][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [lang-painless] [2025-05-12T16:43:52,356][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-ml] [2025-05-12T16:43:52,356][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [lang-mustache] [2025-05-12T16:43:52,356][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [legacy-geo] [2025-05-12T16:43:52,356][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [logsdb] [2025-05-12T16:43:52,357][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-ql] [2025-05-12T16:43:52,357][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [rank-rrf] [2025-05-12T16:43:52,357][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [analysis-common] [2025-05-12T16:43:52,358][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [health-shards-availability] [2025-05-12T16:43:52,358][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [transport-netty4] [2025-05-12T16:43:52,358][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [aggregations] [2025-05-12T16:43:52,358][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [ingest-common] [2025-05-12T16:43:52,359][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [frozen-indices] [2025-05-12T16:43:52,359][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-identity-provider] [2025-05-12T16:43:52,359][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-shutdown] [2025-05-12T16:43:52,359][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-text-structure] [2025-05-12T16:43:52,360][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [snapshot-repo-test-kit] [2025-05-12T16:43:52,360][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [ml-package-loader] [2025-05-12T16:43:52,360][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [kibana] [2025-05-12T16:43:52,360][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [constant-keyword] [2025-05-12T16:43:52,361][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-logstash] [2025-05-12T16:43:52,361][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-ccr] [2025-05-12T16:43:52,361][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-graph] [2025-05-12T16:43:52,361][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [rank-vectors] [2025-05-12T16:43:52,362][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-esql] [2025-05-12T16:43:52,362][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [parent-join] [2025-05-12T16:43:52,362][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [counted-keyword] [2025-05-12T16:43:52,362][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-enrich] [2025-05-12T16:43:52,363][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [repositories-metering-api] [2025-05-12T16:43:52,363][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [transform] [2025-05-12T16:43:52,363][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [repository-azure] [2025-05-12T16:43:52,364][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [dot-prefix-validation] [2025-05-12T16:43:52,364][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [repository-gcs] [2025-05-12T16:43:52,364][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [spatial] [2025-05-12T16:43:52,364][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-otel-data] [2025-05-12T16:43:52,364][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [apm] [2025-05-12T16:43:52,365][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [mapper-extras] [2025-05-12T16:43:52,365][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [mapper-version] [2025-05-12T16:43:52,365][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-rollup] [2025-05-12T16:43:52,365][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [percolator] [2025-05-12T16:43:52,366][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-migrate] [2025-05-12T16:43:52,366][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [data-streams] [2025-05-12T16:43:52,366][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-stack] [2025-05-12T16:43:52,366][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [rank-eval] [2025-05-12T16:43:52,366][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [reindex] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-security] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [blob-cache] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [searchable-snapshots] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-slm] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-geoip-enterprise-downloader] [2025-05-12T16:43:52,367][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [snapshot-based-recoveries] [2025-05-12T16:43:52,368][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-watcher] [2025-05-12T16:43:52,368][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [old-lucene-versions] [2025-05-12T16:43:52,368][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-ilm] [2025-05-12T16:43:52,368][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-inference] [2025-05-12T16:43:52,368][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-voting-only-node] [2025-05-12T16:43:52,369][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-deprecation] [2025-05-12T16:43:52,369][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-fleet] [2025-05-12T16:43:52,369][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-aggregate-metric] [2025-05-12T16:43:52,369][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-downsample] [2025-05-12T16:43:52,369][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-profiling] [2025-05-12T16:43:52,370][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [ingest-geoip] [2025-05-12T16:43:52,370][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-write-load-forecaster] [2025-05-12T16:43:52,370][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [search-business-rules] [2025-05-12T16:43:52,370][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [ingest-attachment] [2025-05-12T16:43:52,370][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [wildcard] [2025-05-12T16:43:52,371][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-apm-data] [2025-05-12T16:43:52,371][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [unsigned-long] [2025-05-12T16:43:52,371][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-sql] [2025-05-12T16:43:52,371][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [runtime-fields-common] [2025-05-12T16:43:52,372][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-async] [2025-05-12T16:43:52,372][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [vector-tile] [2025-05-12T16:43:52,372][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-kql] [2025-05-12T16:43:52,372][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [lang-expression] [2025-05-12T16:43:52,372][INFO ][o.e.p.PluginsService ] [DESKTOP-A854GSO] loaded module [x-pack-eql] [2025-05-12T16:43:54,309][INFO ][o.e.e.NodeEnvironment ] [DESKTOP-A854GSO] using [1] data paths, mounts [[(D:)]], net usable_space [546.3gb], net total_space [953.8gb], types [NTFS] [2025-05-12T16:43:54,310][INFO ][o.e.e.NodeEnvironment ] [DESKTOP-A854GSO] heap size [7.5gb], compressed ordinary object pointers [true] [2025-05-12T16:43:54,399][INFO ][o.e.n.Node ] [DESKTOP-A854GSO] node name [DESKTOP-A854GSO], node ID [oThuyDfhTraitepa21vwPA], cluster name [elasticsearch], roles [ingest, data_frozen, ml, data_hot, transform, data_content, data_warm, master, remote_cluster_client, data, data_cold] [2025-05-12T16:43:57,587][INFO ][o.e.i.r.RecoverySettings ] [DESKTOP-A854GSO] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b] [2025-05-12T16:43:57,830][INFO ][o.e.f.FeatureService ] [DESKTOP-A854GSO] Registered local node features [ES_V_8, ES_V_9, cluster.reroute.ignores_metric_param, cluster.stats.source_modes, linear_retriever_supported, lucene_10_1_upgrade, lucene_10_upgrade, security.queryable_built_in_roles, simulate.ignored.fields] [2025-05-12T16:43:57,873][INFO ][o.e.c.m.DataStreamGlobalRetentionSettings] [DESKTOP-A854GSO] Updated default factory retention to [null] [2025-05-12T16:43:57,874][INFO ][o.e.c.m.DataStreamGlobalRetentionSettings] [DESKTOP-A854GSO] Updated max factory retention to [null] [2025-05-12T16:43:58,428][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [DESKTOP-A854GSO] [controller/15508] [Main.cc@123] controller (64 bit): Version 9.0.1 (Build 5ac89bc732bee2) Copyright (c) 2025 Elasticsearch BV [2025-05-12T16:43:58,907][INFO ][o.e.x.o.OTelPlugin ] [DESKTOP-A854GSO] OTel ingest plugin is enabled [2025-05-12T16:43:58,937][INFO ][o.e.x.c.t.YamlTemplateRegistry] [DESKTOP-A854GSO] OpenTelemetry index template registry is enabled [2025-05-12T16:43:58,953][INFO ][o.e.t.a.APM ] [DESKTOP-A854GSO] Sending apm metrics is disabled [2025-05-12T16:43:58,954][INFO ][o.e.t.a.APM ] [DESKTOP-A854GSO] Sending apm tracing is disabled [2025-05-12T16:43:59,004][INFO ][o.e.x.s.Security ] [DESKTOP-A854GSO] Security is enabled [2025-05-12T16:43:59,379][INFO ][o.e.x.s.a.s.FileRolesStore] [DESKTOP-A854GSO] parsed [0] roles from file [D:\elasticsearch\elasticsearch-9.0.1\config\roles.yml] [2025-05-12T16:44:00,003][INFO ][o.e.x.w.Watcher ] [DESKTOP-A854GSO] Watcher initialized components at 2025-05-12T08:44:00.002Z [2025-05-12T16:44:00,143][INFO ][o.e.x.p.ProfilingPlugin ] [DESKTOP-A854GSO] Profiling is enabled [2025-05-12T16:44:00,162][INFO ][o.e.x.p.ProfilingPlugin ] [DESKTOP-A854GSO] profiling index templates will not be installed or reinstalled [2025-05-12T16:44:00,170][INFO ][o.e.x.a.APMPlugin ] [DESKTOP-A854GSO] APM ingest plugin is enabled [2025-05-12T16:44:00,207][INFO ][o.e.x.c.t.YamlTemplateRegistry] [DESKTOP-A854GSO] apm index template registry is enabled [2025-05-12T16:44:00,764][INFO ][o.e.t.n.NettyAllocator ] [DESKTOP-A854GSO] creating NettyAllocator with the following configs: [name=elasticsearch_configured, chunk_size=1mb, suggested_max_allocation_size=1mb, factors={es.unsafe.use_netty_default_chunk_and_page_size=false, g1gc_enabled=true, g1gc_region_size=4mb}] [2025-05-12T16:44:00,837][INFO ][o.e.d.DiscoveryModule ] [DESKTOP-A854GSO] using discovery type [multi-node] and seed hosts providers [settings] [2025-05-12T16:44:02,474][INFO ][o.e.n.Node ] [DESKTOP-A854GSO] initialized [2025-05-12T16:44:02,475][INFO ][o.e.n.Node ] [DESKTOP-A854GSO] starting ... [2025-05-12T16:44:02,520][INFO ][o.e.x.s.c.f.PersistentCache] [DESKTOP-A854GSO] persistent cache index loaded [2025-05-12T16:44:02,521][INFO ][o.e.x.d.l.DeprecationIndexingComponent] [DESKTOP-A854GSO] deprecation component started [2025-05-12T16:44:02,642][INFO ][o.e.t.TransportService ] [DESKTOP-A854GSO] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} [2025-05-12T16:44:03,031][WARN ][o.e.c.c.ClusterBootstrapService] [DESKTOP-A854GSO] this node is locked into cluster UUID [_h3NONUQTr-ueBQPxrmidA] but [cluster.initial_master_nodes] is set to [DESKTOP-A854GSO]; remove this setting to avoid possible data loss caused by subsequent cluster bootstrap attempts; for further information see https://www.elastic.co/docs/deploy-manage/deploy/self-managed/important-settings-configuration?version=9.0#initial_master_nodes [2025-05-12T16:44:03,176][INFO ][o.e.c.s.MasterService ] [DESKTOP-A854GSO] elected-as-master ([1] nodes joined in term 4)[_FINISH_ELECTION_, {DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}{ELpoXthvShu35FsJ-XSBeA}{DESKTOP-A854GSO}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{9.0.1}{8000099-9009000} completing election], term: 4, version: 98, delta: master node changed {previous [], current [{DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}{ELpoXthvShu35FsJ-XSBeA}{DESKTOP-A854GSO}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{9.0.1}{8000099-9009000}]} [2025-05-12T16:44:03,257][INFO ][o.e.c.s.ClusterApplierService] [DESKTOP-A854GSO] master node changed {previous [], current [{DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}{ELpoXthvShu35FsJ-XSBeA}{DESKTOP-A854GSO}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{9.0.1}{8000099-9009000}]}, term: 4, version: 98, reason: Publication{term=4, version=98} [2025-05-12T16:44:03,312][INFO ][o.e.c.c.NodeJoinExecutor ] [DESKTOP-A854GSO] node-join: [{DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}{ELpoXthvShu35FsJ-XSBeA}{DESKTOP-A854GSO}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{9.0.1}{8000099-9009000}] with reason [completing election] [2025-05-12T16:44:03,317][INFO ][o.e.h.AbstractHttpServerTransport] [DESKTOP-A854GSO] publish_address {192.168.10.4:9200}, bound_addresses {[::]:9200} [2025-05-12T16:44:03,328][INFO ][o.e.x.w.LicensedWriteLoadForecaster] [DESKTOP-A854GSO] license state changed, now [valid] [2025-05-12T16:44:03,341][INFO ][o.e.n.Node ] [DESKTOP-A854GSO] started {DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}{ELpoXthvShu35FsJ-XSBeA}{DESKTOP-A854GSO}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{9.0.1}{8000099-9009000}{ml.allocated_processors_double=16.0, ml.max_jvm_size=8157921280, ml.config_version=12.0.0, xpack.installed=true, transform.config_version=10.0.0, ml.machine_memory=16312721408, ml.allocated_processors=16} [2025-05-12T16:44:03,387][WARN ][o.e.x.i.s.e.a.ElasticInferenceServiceAuthorizationHandler] [DESKTOP-A854GSO] Failed to revoke access to default inference endpoint IDs: [rainbow-sprinkles], error: org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized]; [2025-05-12T16:44:03,738][INFO ][o.e.x.m.MlIndexRollover ] [DESKTOP-A854GSO] ML legacy indices rolled over [2025-05-12T16:44:03,739][INFO ][o.e.x.m.MlAnomaliesIndexUpdate] [DESKTOP-A854GSO] legacy ml anomalies indices rolled over and aliases updated [2025-05-12T16:44:03,751][INFO ][o.e.x.s.a.Realms ] [DESKTOP-A854GSO] license mode is [basic], currently licensed security realms are [reserved/reserved,file/default_file,native/default_native] [2025-05-12T16:44:03,754][INFO ][o.e.l.ClusterStateLicenseService] [DESKTOP-A854GSO] license [c457fd5c-94b5-44ae-ba97-7a8de1c2a152] mode [basic] - valid [2025-05-12T16:44:03,756][INFO ][o.e.c.f.AbstractFileWatchingService] [DESKTOP-A854GSO] starting file watcher ... [2025-05-12T16:44:03,761][INFO ][o.e.c.f.AbstractFileWatchingService] [DESKTOP-A854GSO] file settings service up and running [tid=109] [2025-05-12T16:44:03,762][INFO ][o.e.r.s.FileSettingsService] [DESKTOP-A854GSO] setting file [D:\elasticsearch\elasticsearch-9.0.1\config\operator\settings.json] not found, initializing [file_settings] as empty [2025-05-12T16:44:03,775][INFO ][o.e.g.GatewayService ] [DESKTOP-A854GSO] recovered [3] indices into cluster_state [2025-05-12T16:44:03,878][INFO ][o.e.x.w.LicensedWriteLoadForecaster] [DESKTOP-A854GSO] license state changed, now [not valid] [2025-05-12T16:44:04,273][INFO ][o.e.h.n.s.HealthNodeTaskExecutor] [DESKTOP-A854GSO] Node [{DESKTOP-A854GSO}{oThuyDfhTraitepa21vwPA}] is selected as the current health node. [2025-05-12T16:44:04,277][INFO ][o.e.c.r.a.AllocationService] [DESKTOP-A854GSO] current.health="GREEN" message="Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.ds-.logs-elasticsearch.deprecation-default-2025.05.12-000001][0], [.ds-ilm-history-7-2025.05.12-000001][0], [.security-7][0]]])." previous.health="RED" reason="shards started [[.ds-.logs-elasticsearch.deprecation-default-2025.05.12-000001][0], [.ds-ilm-history-7-2025.05.12-000001][0], [.security-7][0]]" 中文回答
05-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值