/// <summary> /// 对ArticleIndex进行各项操作 /// </summary> /// <param name="articleID">文章ID</param> /// <param name="operateType">操作类型0 新增索引,1更新索引,2删除索引</param> /// <returns></returns> public string InsertData(string articleID, int operateType) { try { //if (ArticleHelper.ExistDataBystate(articleID, 1)) //{ ArticleIndex articleIndex = new ArticleIndex(); articleIndex.ArticleID = articleID; articleIndex.IsLock = 0; articleIndex.Operation = operateType; if (ExistData(articleID)) { Assistant.Update(articleIndex, new string[] { "Operation" }); } else { Assistant.Insert(articleIndex); } //} return(articleID); } catch (Exception ex) { throw ex; } }
public void GivenIHaveCreatedAnArticleDefinitionWithAnIndexForAManufacturer() { var x = _articleController.Post(new Models.Creators.ArticleDefinitionCreationRequest()); _manufacturerIndex = new ArticleIndex(Guid.NewGuid(), IndexType.Manufacturer); _articleDefinition = _articleController.Index(_articleDefinition.EntityId, _manufacturerIndex); }
public ArticleDefinition Index(Guid articleDefinitionId, ArticleIndex index) { var article = _articleDefinitionRepository.Load(articleDefinitionId); article.AddIndex(index); _articleDefinitionRepository.Save(article); //where should the repository save go? return(article); }
public void AddedIndexRaisesNewIndexEvent() { //setup var ad = new ArticleDefinition(); var indexRef = Guid.NewGuid(); var index = new ArticleIndex(indexRef, IndexType.Manufacturer); var indexAddedEvent = ad.AddIndex(index); Assert.IsInstanceOfType(indexAddedEvent, typeof(IndexAddedEvent)); }
private void ActualTestCase(IDocumentStore store) { var lorem = new[] { "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper, leo sit amet auctor aliquam, erat ligula dictum eros", " Aliquam eleifend, dui vitae fermentum bibendum, nunc sem tempus risus, posuere interdum arcu diam sit amet sem", " Suspendisse a nunc rutrum, rutrum arcu ut, tempor est." }; var index = new ArticleIndex(); store.ExecuteIndex(index); using (var session = store.OpenSession()) { for (int i = 0; i < 10; i++) { var article = new Article() { Name = "Art/" + i, ArticleBody = lorem[i % 3] }; session.Store(article, "articles/" + i); } session.SaveChanges(); } Indexes.WaitForIndexing((DocumentStore)store); using (var session = store.OpenSession()) { var oldRequests = session.Advanced.NumberOfRequests; var moreLikeThisLazy = session.Query <Article, ArticleIndex>() .MoreLikeThis(f => f.UsingDocument(x => x.Id == "articles/0").WithOptions(new MoreLikeThisOptions { MinimumTermFrequency = 0, MinimumDocumentFrequency = 0 })) .Lazily(); Assert.Equal(oldRequests, session.Advanced.NumberOfRequests); Assert.NotEmpty(moreLikeThisLazy.Value); Assert.Equal(oldRequests + 1, session.Advanced.NumberOfRequests); } }
/// <summary> /// 给一组文件建立索引 /// </summary> /// <param name="articleIDs">一组文章ID的集合</param> /// <returns></returns> public int InsertData(List <string> articleIDs) { int count = 0; if (articleIDs != null && articleIDs.Count > 0) { foreach (string id in articleIDs) { ArticleIndex articleIndex = new ArticleIndex(); articleIndex.ArticleID = id; articleIndex.IsLock = 0; articleIndex.Operation = 1; Assistant.Insert(articleIndex); count++; } } return(count); }
private void BuildIndex(Context context, string packageFile, CancellationToken token) { _logger.LogInformation($"{nameof(BuildIndex)}: packageFile={packageFile}"); byte[] bytes = File.ReadAllBytes(packageFile); ArticlePayload articlePayload = bytes.ToArticlePayload((ArticleId)"id"); IReadOnlyList <WordCount> wordCounts = new ArticlePackageIndexBuilder().Build(articlePayload); ArticleManifest articleManifest = articlePayload.ReadManifest(); var articleIndex = new ArticleIndex { ArticleId = articleManifest.ArticleId, WordIndexes = wordCounts, }; context.Queue.Enqueue(articleIndex); }
public void GivenIHaveAddedAnArticleIndexForXB() { _modelIndex = new ArticleIndex(Guid.NewGuid(), IndexType.ModelFamily); _articleDefinition = _articleController.Index(_articleDefinition.EntityId, _modelIndex); }
public IndexAddedEvent(ArticleIndex index) { ArticleIndex = index; }
public IDomainEvent AddIndex(ArticleIndex index) { _indexes.Add(index); return(new IndexAddedEvent(index)); }