Exemplo n.º 1
0
        public override void Execute()
        {
            try
            {
                var query = _queryParser.Parse(
                    collections: Collections,
                    q: Q,
                    fields: Fields,
                    select: _select,
                    and: And,
                    or: Or);

                var targetCollectionId = _target.ToHash();
                IEnumerable <IDictionary <string, object> > documents;

                using (var readSession = _sessionFactory.CreateReadSession())
                {
                    documents = readSession.Read(query, _skip, _take).Docs;
                }

                //TODO: Remove this when cc_wat is rebuilt.
                var c = "cc_wat".ToHash();
                foreach (var d in documents)
                {
                    d.TryAdd(SystemFields.CollectionId, c);
                }

                if (_truncate)
                {
                    _sessionFactory.Truncate(targetCollectionId);
                }

                using (var documentWriter = new DocumentWriter(targetCollectionId, _sessionFactory))
                {
                    foreach (var field in _indexFieldNames)
                    {
                        documentWriter.EnsureKeyExists(field);
                    }
                }

                _sessionFactory.SaveAs(
                    targetCollectionId,
                    documents,
                    _indexFieldNames,
                    new HashSet <string>(),
                    _model);
            }
            catch (Exception ex)
            {
                _logger.LogError($"error processing {this} {ex}");
            }
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            try
            {
                var query = _queryParser.Parse(
                    collections: Collections,
                    q: Q,
                    fields: Fields,
                    select: _select,
                    and: And,
                    or: Or);

                var targetCollectionId = _target.ToHash();
                IEnumerable <Document> documents;

                using (var readSession = _sessionFactory.CreateSearchSession(_model))
                {
                    documents = readSession.Search(query, _skip, _take).Documents;
                }

                if (_truncate)
                {
                    _sessionFactory.Truncate(targetCollectionId);
                }

                using (var documentWriter = new DocumentWriter(targetCollectionId, _sessionFactory))
                {
                    foreach (var field in _indexFieldNames)
                    {
                        documentWriter.EnsureKeyExists(field);
                    }
                }

                _sessionFactory.SaveAs(
                    targetCollectionId,
                    documents,
                    _model);
            }
            catch (Exception ex)
            {
                _logger.LogError($"error processing {this} {ex}");
            }
        }