Skip to content

Instantly share code, notes, and snippets.

Last active January 20, 2021 17:06
What would you like to do?
Update field in Lucene / Examine index (Umbraco 8 v8 -specific)
var index = (LuceneIndex)ExamineManager.Instance.Indexes.Where(f => f.Name == "ExternalIndex").FirstOrDefault();
// Get the IndexWriter
var writer = index.GetIndexWriter();
var searcher = (BaseLuceneSearcher)index.GetSearcher();
// perform search to get the doc from the index based on node id
Term term = new Term("id", "1082"); // Term to get node by id
var q = new TermQuery(term);
var sres = searcher.GetLuceneSearcher().Search(q, 1);
var doc = searcher.GetLuceneSearcher().Doc(sres.ScoreDocs.First().Doc);
doc.Add(new Field("testing", "Hallo world mamma", Field.Store.YES, Field.Index.ANALYZED));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment