Пример #1
0
        public static ElasticDocumentVersion GetElasticVersion <T>(this Nest.GetResponse <T> hit) where T : class
        {
            if (!hit.PrimaryTerm.HasValue || !hit.SequenceNumber.HasValue)
            {
                return(ElasticDocumentVersion.Empty);
            }

            return(new ElasticDocumentVersion(hit.PrimaryTerm.Value, hit.SequenceNumber.Value));
        }
Пример #2
0
        public static FindHit <T> ToFindHit <T>(this Nest.GetResponse <T> hit) where T : class
        {
            var versionedDoc = hit.Source as IVersioned;

            if (versionedDoc != null)
            {
                versionedDoc.Version = hit.GetElasticVersion();
            }

            var data = new DataDictionary {
                { ElasticDataKeys.Index, hit.Index }
            };

            return(new FindHit <T>(hit.Id, hit.Source, 0, versionedDoc?.Version ?? null, hit.Routing, data));
        }