/// <summary> /// Creates an insert operation for the supplied topic /// </summary> /// <param name="document">the topic to create an operation for</param> /// <returns>insert operation</returns> private IndexOperation CreateDocumentInsertOperation(Document document) { this.Log.LogInformation("creating topic insert"); TopicDocument topic = null; if (document is TopicDocument) { topic = (TopicDocument)document; } else { this.Log.LogException("got document that is not a topic document"); } // check if important values are null if (topic == null || string.IsNullOrWhiteSpace(topic.TopicHandle)) { this.Log.LogException("got bad parameters"); } if (topic.TopicTags == null) { topic.TopicTags = new List <string>(); } IndexOperation operation = new IndexOperation(IndexOperationType.Upload, "topicHandle", topic.TopicHandle) .WithProperty("topicTitle", topic.TopicTitle) .WithProperty("topicText", topic.TopicText) .WithProperty("topicTags", topic.TopicTags) .WithProperty("appHandle", topic.AppHandle) .WithProperty("userHandle", topic.UserHandle) .WithProperty("searchWeight", topic.SearchWeight) .WithProperty("topicLastModifiedTime", new DateTimeOffset(topic.TopicLastModifiedTime)); return(operation); }
/// <summary> /// adds a topic to the search index /// </summary> /// <param name="topic">topic to add</param> /// <returns>add topic task</returns> public async Task AddTopic(TopicDocument topic) { await this.AddDocument(topic, this.CreateDocumentInsertOperation); }