public ElasticResult <ElasticChatUser[]> GetAllByUserGuid(string userGuid)
        {
            var searchDescriptor =
                new SearchDescriptor <ElasticChatUser>().Query(q => q.Term(t => t.Field(f => f.UserGuid).Value(userGuid)))
                .Index(_elasticRepository.EsIndex)
                .Type(EsType);

            var responses = _elasticRepository.ExecuteSearchRequestWithScroll(searchDescriptor);

            return(responses.Any(r => !r.Success)
                ? ElasticResult <ElasticChatUser[]> .FailResult(responses.First(r => !r.Success).Message)
                : _entityRepository.GetEntitiesFromElasticResponseWithScroll(responses));
        }
Example #2
0
        public ElasticResult <T[]> GetAll <T>(string esType) where T : class
        {
            var searchDescriptor = new SearchDescriptor <T>().AllIndices().Index(_elasticRepository.EsIndex).Type(esType);

            var responses = _elasticRepository.ExecuteSearchRequestWithScroll(searchDescriptor);

            return(GetEntitiesFromElasticResponseWithScroll(responses));
        }
Example #3
0
        public ElasticResult <ElasticUser[]> SearchByUserName(string userName)
        {
            var searchDescriptor = new SearchDescriptor <ElasticUser>().Query(
                q =>
                q.Regexp(
                    r =>
                    r.Field(fields => fields.UserName)
                    .Value(string.Format(UserNameRegexpFormatString, userName))))
                                   .Index(_elasticRepository.EsIndex)
                                   .Type(EsType);

            var responses = _elasticRepository.ExecuteSearchRequestWithScroll(searchDescriptor);

            return(_entityRepository.GetEntitiesFromElasticResponseWithScroll(responses));
        }