public static List <long> QueryDocuments(Application app, string documentsDir) { logger.Info("Execute document query..."); List <long> documentIdList = new List <long>(); string filePath = documentsDir + "\\query.json"; if (File.Exists(filePath)) { logger.Info("Query File found: " + filePath); string inputJSON = File.ReadAllText(filePath); IList <JToken> jTokens = JToken.Parse(inputJSON)["contents"].Children().ToList(); foreach (JToken jToken in jTokens) { Content content = jToken.ToObject <Content>(); DocumentType documentType = app.Core.DocumentTypes.Find(content.documentType); if (documentType == null) { throw new Exception("Document type was not found"); } DocumentQuery documentQuery = app.Core.CreateDocumentQuery(); documentQuery.AddDisplayColumn(DisplayColumnType.AuthorName); documentQuery.AddDisplayColumn(DisplayColumnType.DocumentDate); documentQuery.AddDisplayColumn(DisplayColumnType.ArchivalDate); documentQuery.AddDocumentType(documentType); KeywordRecordType keywordRecordType = documentType.KeywordRecordTypes[0]; foreach (var kt in keywordRecordType.KeywordTypes) { if (content.keywords.ContainsKey(kt.Name)) { switch (kt.DataType) { case KeywordDataType.AlphaNumeric: documentQuery.AddKeyword(kt.CreateKeyword(content.keywords[kt.Name])); break; case KeywordDataType.Currency: case KeywordDataType.SpecificCurrency: case KeywordDataType.Numeric20: documentQuery.AddKeyword(kt.CreateKeyword(decimal.Parse(content.keywords[kt.Name]))); break; case KeywordDataType.Date: case KeywordDataType.DateTime: documentQuery.AddKeyword(kt.CreateKeyword(DateTime.Parse(content.keywords[kt.Name]))); break; case KeywordDataType.FloatingPoint: documentQuery.AddKeyword(kt.CreateKeyword(double.Parse(content.keywords[kt.Name]))); break; case KeywordDataType.Numeric9: documentQuery.AddKeyword(kt.CreateKeyword(long.Parse(content.keywords[kt.Name]))); break; } } } using (QueryResult queryResults = documentQuery.ExecuteQueryResults(long.MaxValue)) { logger.Info("Number of " + content.documentType + " Documents Found: " + queryResults.QueryResultItems.Count().ToString()); foreach (QueryResultItem queryResultItem in queryResults.QueryResultItems) { if (!documentIdList.Contains(queryResultItem.Document.ID)) { documentIdList.Add(queryResultItem.Document.ID); } logger.Info(string.Format("Document ID: {0}", queryResultItem.Document.ID.ToString())); logger.Info(string.Format("Author: {0}, Document Date: {1}, Archival Date: {2}", queryResultItem.DisplayColumns[0].Value.ToString(), DateTime.Parse(queryResultItem.DisplayColumns[1].Value.ToString()).ToShortDateString(), DateTime.Parse(queryResultItem.DisplayColumns[2].Value.ToString()).ToShortDateString())); foreach (var keyword in queryResultItem.Document.KeywordRecords[0].Keywords) { logger.Info(keyword.KeywordType.Name + " : " + keyword.Value.ToString()); } logger.Info(""); } } } } logger.Info(""); return(documentIdList); }