java - Generate Lucene segments_N file -
while moving lucene index files server other, forgot move segments_n file (because use pattern *.*
)
unfortunately i've erased original folder, , have these files in directory :
_1rpt.fdt _1rpt.fdx _1rpt.fnm _1rpt.nvd _1rpt.nvm _1rpt.si _1rpt_lucene50_0.doc _1rpt_lucene50_0.dvd _1rpt_lucene50_0.dvm _1rpt_lucene50_0.pos _1rpt_lucene50_0.tim _1rpt_lucene50_0.tip write.lock
i missing segments_42u
file, , without cannot org.apache.lucene.index.checkindex
:
exception in thread "main" org.apache.lucene.index.indexnotfoundexception: no segments* file found in mmapdirectory@/solr-5.3.1/nodes/node1/core/data/index lockfactory=org.apache.lucene.store.nativefslockfactory@119d7047: files: [write.lock, _1rpt.fdt, _1rpt.fdx, _1rpt.fnm, _1rpt.nvd, _1rpt.nvm, _1rpt.si, _1rpt_lucene50_0.doc, _1rpt_lucene50_0.dvd, _1rpt_lucene50_0.dvm, _1rpt_lucene50_0.pos, _1rpt_lucene50_0.tim, _1rpt_lucene50_0.tip] @ org.apache.lucene.index.checkindex.checkindex(checkindex.java:483) @ org.apache.lucene.index.checkindex.domain(checkindex.java:2354) @ org.apache.lucene.index.checkindex.main(checkindex.java:2237)
the index pretty huge (> 800gb) , take weeks rebuild it.
is there way generate missing segment info file ?
thanks lot help.
as ameertawfik has suggested, ask question lucene mailing list, , me solving issue.
here solution, in case else (add lucene-core-x.x.x.jar
classpath) :
package org.apache.lucene.index; import java.io.ioexception; import java.nio.file.path; import java.nio.file.paths; import org.apache.lucene.codecs.codec; import org.apache.lucene.store.directory; import org.apache.lucene.store.iocontext; import org.apache.lucene.store.simplefsdirectory; public class gensegmentinfo { public static void main(string[] args) throws ioexception { codec codec = codec.getdefault(); path mypath = paths.get("/tmp/index"); directory directory = new simplefsdirectory(mypath); //launch first time random segmentid value //then java debug, right segment id //by putting breakpoint on codecutil#checkindexheaderid(...) byte[] segmentid = {88, 55, 58, 78, -21, -55, 102, 99, 123, 34, 85, -38, -70, -120, 102, -67}; segmentinfo info = codec.segmentinfoformat().read(directory, "_1rpt", segmentid, iocontext.read); info.setcodec(codec); segmentinfos infos = new segmentinfos(); segmentcommitinfo commit = new segmentcommitinfo(info, 1, -1, -1, -1); infos.add(commit); infos.commit(directory); } }
Comments
Post a Comment