[
https://issues.apache.org/jira/browse/LUCENENET-534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13877315#comment-13877315
]
ali koyuncu commented on LUCENENET-534:
---------------------------------------
public IndexWriter iw_global { get; set; }
private List<Link> linkList { get; set; }
public List<TGC> tema_groups { get; set; }
private void btnStartService_Click(object sender, EventArgs e)
{
OpenIndexer();
new Thread(new ThreadStart(Start)).Start();
}
public void OpenIndexer()
{
#region Open IndexWriter
this.iw_global = new IndexWriter(lcneFolder, new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), !fiAktifYes.Exists,
IndexWriter.MaxFieldLength.UNLIMITED);
this.iw_global.Commit();
this.iw_global.UseCompoundFile = true;
#endregion
}
public void Start()
{
RAMDirectory idx = new RAMDirectory();
IndexWriter iw = new IndexWriter(idx, new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), true,
IndexWriter.MaxFieldLength.UNLIMITED);
iw.UseCompoundFile = true;
foreach (var link in linkList)
{
iw.AddDocument(doc);
}
iw.Commit();
this.iw_global.AddIndexesNoOptimize(idx);
this.iw_global.Commit();
#region unnecessary code to understand bug
Parallel.ForEach(this.tgs, new ParallelOptions {
MaxDegreeOfParallelism = 12 }, tg =>
{
var send_link_list = new Dictionary<long, Link>();
foreach (var tm in tg.tms)
{
IndexSearcher iSc = new
IndexSearcher(iw.GetReader());
MultiFieldQueryParser Parser = new
MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30,
(string[])this.aList.ToArray(typeof(string)), new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
BooleanQuery.MaxClauseCount = int.MaxValue;
BooleanQuery bq = new BooleanQuery();
Query q =
Parser.Parse(NoSqlDB.Utils.ToIndexEncode(tm.Value));
bq.Add(q, Occur.MUST);
//QueryParser Parser = new
QueryParser(Lucene.Net.Util.Version.LUCENE_30, "full_text", new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
//Query q =
Parser.Parse(NoSqlDB.Utils.ToIndexEncode(tm.Value));
TopDocs results = iSc.Search(bq, null, 100000);
if (results.ScoreDocs.Count() > 0)
{
RAMDirectory idx_tema = new
RAMDirectory();
IndexWriter iw_tema = new
IndexWriter(idx_tema, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30),
true, IndexWriter.MaxFieldLength.UNLIMITED);
iw_tema.UseCompoundFile = true;
foreach (ScoreDoc scoreDoc in
results.ScoreDocs)
{
Document doc =
iSc.Doc(scoreDoc.Doc);
long id =
Convert.ToInt64(doc.Get("id"));
}
}
}
});
#endregion
iw.Dispose();
idx.Dispose();
}
> IndexWriter deletes all files in my global index folder
> -------------------------------------------------------
>
> Key: LUCENENET-534
> URL: https://issues.apache.org/jira/browse/LUCENENET-534
> Project: Lucene.Net
> Issue Type: Bug
> Components: .NET API
> Reporter: ali koyuncu
> Priority: Critical
>
> I process new data list in memory-directory. After that I commit
> memory-directory to disk directrory. After I commit global index writer,I
> see the files isn't combined.So when I reopen the service,indexwriter deletes
> all files in global index folder. I traced codes ,
> "deleter = new IndexFileDeleter(directory, deletionPolicy == null?new
> KeepOnlyLastCommitDeletionPolicy():deletionPolicy, segmentInfos, infoStream,
> docWriter, synced);" in IndexWriter Init method,it deletes all file here.
> I asked it on stackoverlow.
> http://stackoverflow.com/questions/20973121/lucene-net-indexwriter-bug?noredirect=1#comment31536841_20973121
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)