public IHttpActionResult UpdateTTLDocuments(string pwd)
        {
            if (pwd == "dxtttldoc")
            {
                var client  = LoadClient();
                var query   = GetRangeQuery();
                var indexes = GetIndexes();
                foreach (var index in indexes)
                {
                    var indexName = IndexResolver.GetIndexName(index.Name);

                    //var results = client.Search<BytesResponse>(indexName, json);
                    //var response = Encoding.UTF8.GetString(results.Body);

                    //do this once query is confirmed and working
                    var results  = client.DeleteByQuery <BytesResponse>(indexName, query);
                    var response = Encoding.UTF8.GetString(results.Body);
                }

                return(Json(new
                {
                    System.Net.HttpStatusCode.OK
                }));
            }

            return(Json(new
            {
                System.Net.HttpStatusCode.NotFound
            }));
        }
Esempio n. 2
0
        public Index GetIndexConfig(string alias)
        {
            var   cacheName   = "DEXTER_INDEX_" + alias;
            Index indexConfig = CacheProvider.Get <Index>(cacheName);

            if (indexConfig != null)
            {
                return(indexConfig);
            }

            indexConfig = FileSystemService.MapFile($"{DEFAULTINDEXFILEPATH}{alias}.index.json").ReadAsJson <Index>();

            var indexAllContentType = indexConfig.ContentTypes.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.Alias));

            if (indexAllContentType != null)
            {
                foreach (var type in indexConfig.ContentTypes.Where(x => !string.IsNullOrWhiteSpace(x.Alias)))
                {
                    type.Properties.AddRange(indexAllContentType.Properties);
                }
            }

            indexConfig.Alias = IndexResolver.GetIndexName(alias);

            CacheProvider.Set(cacheName, indexConfig);

            return(indexConfig);
        }
        public void UpdateTTLDocuments()
        {
            var client  = LoadClient();
            var query   = GetRangeQuery();
            var indexes = GetIndexes();

            foreach (var index in indexes)
            {
                var indexName = IndexResolver.GetIndexName(index.Name);

                //var results = client.Search<BytesResponse>(indexName, json);
                //var response = Encoding.UTF8.GetString(results.Body);

                //do this once query is confirmed and working
                var results  = client.DeleteByQuery <BytesResponse>(indexName, query);
                var response = Encoding.UTF8.GetString(results.Body);
            }
        }