public void UpdatePackage(Package package) { // Just update the provided package using (Trace.Activity(String.Format(CultureInfo.CurrentCulture, "Updating Lucene Index for: {0} {1} [PackageKey:{2}]", package.PackageRegistration.Id, package.Version, package.Key))) { EnsureIndexWriter(creatingIndex: false); var indexEntity = new PackageIndexEntity(package); var updateTerm = new Term("PackageRegistrationKey", package.PackageRegistrationKey.ToString(CultureInfo.InvariantCulture)); if (package.Listed) { Trace.Information(String.Format(CultureInfo.CurrentCulture, "Updating Document: {0}", updateTerm.ToString())); _indexWriter.UpdateDocument(updateTerm, indexEntity.ToDocument()); } else { Trace.Information(String.Format(CultureInfo.CurrentCulture, "Deleting Document: {0}", updateTerm.ToString())); _indexWriter.DeleteDocuments(updateTerm); } _indexWriter.Commit(); } }
public void UpdatePackage(Package package) { if (_getShouldAutoUpdate()) { var packageRegistrationKey = package.PackageRegistrationKey; var updateTerm = new Term("PackageRegistrationKey", packageRegistrationKey.ToString(CultureInfo.InvariantCulture)); if (!package.IsLatest || !package.IsLatestStable) { // Someone passed us in a version which was e.g. just unlisted? Or just not the latest version which is what we want to index. Doesn't really matter. We'll find one to index. package = _packageRepository.GetAll() .Where(p => (p.IsLatest || p.IsLatestStable) && p.PackageRegistrationKey == packageRegistrationKey) .Include(p => p.PackageRegistration) .Include(p => p.PackageRegistration.Owners) .Include(p => p.SupportedFrameworks) .FirstOrDefault(); } // Just update the provided package using (Trace.Activity(String.Format(CultureInfo.CurrentCulture, "Updating Document: {0}", updateTerm.ToString()))) { EnsureIndexWriter(creatingIndex: false); if (package != null) { var indexEntity = new PackageIndexEntity(package); Trace.Information(String.Format(CultureInfo.CurrentCulture, "Updating Lucene Index for: {0} {1} [PackageKey:{2}]", package.PackageRegistration.Id, package.Version, package.Key)); _indexWriter.UpdateDocument(updateTerm, indexEntity.ToDocument()); } else { Trace.Information(String.Format(CultureInfo.CurrentCulture, "Deleting Document: {0}", updateTerm.ToString())); _indexWriter.DeleteDocuments(updateTerm); } _indexWriter.Commit(); } } }
public virtual void TestToString() { Term term = new Term("foo", new BytesRef(new[] { unchecked((byte)0xff), unchecked((byte)0xfe) })); Assert.AreEqual("foo:[ff fe]", term.ToString()); }
public virtual void TestToString() { Term term = new Term("foo", new BytesRef(new[] { unchecked ((byte)0xff), unchecked ((byte)0xfe) })); Assert.AreEqual("foo:[ff fe]", term.ToString()); }
public void UpdatePackage(Package package) { var packageRegistrationKey = package.PackageRegistrationKey; // We can't just update that one document. Someone might have unlisted, and therefore changed the IsLatest(Stable) // flags. Update the whole registration, and all curated feeds var packagesForIndexing = GetPackages(lastIndexTime: null, package: package); packagesForIndexing.AddRange(GetCuratedPackages(lastIndexTime: null, package: package)); // Just update the provided package var updateTerm = new Term("PackageRegistrationKey", packageRegistrationKey.ToString(CultureInfo.InvariantCulture)); using (Trace.Activity(String.Format(CultureInfo.CurrentCulture, "Updating Document: {0}", updateTerm.ToString()))) { EnsureIndexWriter(creatingIndex: false); // This will delete existing documents AddPackages(packagesForIndexing, false); _indexWriter.Commit(); } }