[U] public async Task Urls()
        {
            var index = "indexx";

            await POST($"/_msearch")
            .Fluent(c => c.MultiSearch(s => s))
            .Request(c => c.MultiSearch(new MultiSearchRequest()))
            .FluentAsync(c => c.MultiSearchAsync(s => s))
            .RequestAsync(c => c.MultiSearchAsync(new MultiSearchRequest()))
            ;

            await POST($"/{index}/_msearch")
            .Fluent(c => c.MultiSearch(s => s.Index(index)))
            .Request(c => c.MultiSearch(new MultiSearchRequest(index)))
            .FluentAsync(c => c.MultiSearchAsync(s => s.Index(index)))
            .RequestAsync(c => c.MultiSearchAsync(new MultiSearchRequest(index)))
            ;

            await POST($"/{index}/doc/_msearch")
            .Fluent(c => c.MultiSearch(s => s.Index(index).Type <CommitActivity>()))
            .Request(c => c.MultiSearch(new MultiSearchRequest(index, TypeName.From <CommitActivity>())))
            .FluentAsync(c => c.MultiSearchAsync(s => s.Index(index).Type(typeof(CommitActivity))))
            .RequestAsync(c => c.MultiSearchAsync(new MultiSearchRequest(index, typeof(CommitActivity))))
            ;
        }
Ejemplo n.º 2
0
        protected override Instance _invoke(Instance thisInstance, string methodName, params Instance[] args)
        {
            Wrapped thisObj;

            if (!TryUnwrap <Wrapped>(thisInstance, out thisObj))
            {
                throw new NotSupportedException("Unwrapping is not supported");
            }

            var rawArgs = getUnwrappedArgs(args);

            var info = getMethodInfo(methodName, thisInstance.IsShared, rawArgs);


            if (thisInstance.IsShared)
            {
                throw new NotImplementedException("Static call");
            }

            var result = info.Invoke(thisObj, rawArgs);

            if (info.ReturnType == typeof(void))
            {
                throw new NotImplementedException("Void return");
            }

            var returnType = Assembly.ResolveType(TypeName.From(info.ReturnType));

            return(returnType.Wrap(result));
        }
        // public async Task<bool> CreateMappingIfNoExists<T>(string indexName
        // , Func<PutMappingDescriptor<T>, IPutMappingRequest> selector) where T : class
        // {
        //     var log = _loggerFac.CreateLogger<ElasticsearchService>();
        //     var types = Types.Parse(typeName);
        //     var exists = await _elasticClient.TypeExistsAsync(Indices.Index(indexName), typeName);
        //     if (exists.Exists)
        //     {
        //         log.LogWarning("index:{0},type:{1}已经存在", indexName, typeName);
        //         return await Task.FromResult(true);
        //     }
        //     PutMappingRequest indexMappings = new PutMappingRequest(indexName,typeName);

        //     var putMapping = await _elasticClient.MapAsync<T>((des) =>
        //     {
        //         return selector(des);
        //     });
        //     log.LogInformation(putMapping.DebugInformation);
        //     if (putMapping.Acknowledged)
        //     {
        //         log.LogInformation("index:{0},type:{1},创建成功", indexName, typeName);
        //         return await Task.FromResult(false);
        //     }
        //     else
        //     {
        //         log.LogError(putMapping.ServerError.ToString());
        //         log.LogError(putMapping.OriginalException.ToString());
        //         return await Task.FromResult(false);
        //     }
        // }


        public async Task <ICreateResponse> CreateDocument <T>(string indexName, T t) where T : class
        {
            var log = _loggerFac.CreateLogger <ElasticsearchService>();

            if (t == null)
            {
                log.LogError("bulk 参数不能为空。");
                return(null);
            }
            IndexRequest <T> request = new IndexRequest <T>(indexName, TypeName.From <T>())
            {
                Document = t
            };

            var createResponse = await _elasticClient.CreateDocumentAsync <T>(t);

            log.LogInformation(createResponse.DebugInformation);
            if (createResponse.ApiCall.Success)
            {
                log.LogInformation("index:{0},type:{1},创建成功", createResponse.Index, createResponse.Type);
                return(createResponse);
            }
            else
            {
                log.LogError(createResponse.ServerError.ToString());
                log.LogError(createResponse.OriginalException.ToString());
                return(null);
            }
        }
Ejemplo n.º 4
0
        /** === An example with requests */
        [U] public void UsingWithRequests()
        {
            /* Given the following CLR type that describes a document */
            var project = new Project {
                Name = "hello-world"
            };

            /** we can see an example of how `DocumentPath` helps your describe your requests more tersely */
            var request = new IndexRequest <Project>(2)
            {
                Document = project
            };

            request = new IndexRequest <Project>(project)
            {
            };

            /** when comparing with the full blown constructor and passing document manually,
             * `DocumentPath<T>`'s benefits become apparent.
             */
            request = new IndexRequest <Project>(IndexName.From <Project>(), TypeName.From <Project>(), 2)
            {
                Document = project
            };
        }
Ejemplo n.º 5
0
        [U] public async Task Urls()
        {
            var index = "indexx";

            await POST($"/_mpercolate")
            .Fluent(c => c.MultiPercolate(s => s))
            .Request(c => c.MultiPercolate(new MultiPercolateRequest()))
            .FluentAsync(c => c.MultiPercolateAsync(s => s))
            .RequestAsync(c => c.MultiPercolateAsync(new MultiPercolateRequest()))
            ;

            await POST($"/{index}/_mpercolate")
            .Fluent(c => c.MultiPercolate(s => s.Index(index)))
            .Request(c => c.MultiPercolate(new MultiPercolateRequest(index)))
            .FluentAsync(c => c.MultiPercolateAsync(s => s.Index(index)))
            .RequestAsync(c => c.MultiPercolateAsync(new MultiPercolateRequest(index)))
            ;

            await POST($"/{index}/commits/_mpercolate")
            .Fluent(c => c.MultiPercolate(s => s.Index(index).Type <CommitActivity>()))
            .Request(c => c.MultiPercolate(new MultiPercolateRequest(index, TypeName.From <CommitActivity>())))
            .FluentAsync(c => c.MultiPercolateAsync(s => s.Index(index).Type(typeof(CommitActivity))))
            .RequestAsync(c => c.MultiPercolateAsync(new MultiPercolateRequest(index, typeof(CommitActivity))))
            ;
        }
Ejemplo n.º 6
0
 [U] public async Task Urls()
 {
     await PUT($"/project/project/_mapping")
     .Fluent(c => c.Map <Project>(m => m))
     .Request(c => c.Map(new PutMappingRequest("project", TypeName.From <Project>())))
     .Request(c => c.Map(new PutMappingRequest <Project>()))
     .FluentAsync(c => c.MapAsync <Project>(m => m))
     .RequestAsync(c => c.MapAsync(new PutMappingRequest("project", "project")))
     .RequestAsync(c => c.MapAsync(new PutMappingRequest <Project>()))
     ;
 }
Ejemplo n.º 7
0
        public async Task <TermVectorsModel> TermVectors(string queryString, double lat, double lng)
        {
            var client           = GetClient();
            var searchDescriptor = new SearchDescriptor <Place>();
            var dumper           = new NestDescriptorDumper(client.RequestResponseSerializer);

            #region Search
            QueryContainerDescriptor <Place> queryContainer = new QueryContainerDescriptor <Place>();
            var query = queryContainer.Bool(b =>
                                            b.Should(
                                                q => q.Match(m => m.Field(f => f.Name).Query(queryString)),
                                                q => q.Match(m => m.Field(f => f.Vicinity).Query(queryString))
                                                )
                                            );

            Func <SortDescriptor <Place>, SortDescriptor <Place> > SortByGeo =
                (SortDescriptor <Place> s) => s.GeoDistance(g =>
                                                            g.Field(f => f.Geometry.Location)
                                                            .DistanceType(GeoDistanceType.Arc)
                                                            .Unit(DistanceUnit.Kilometers)
                                                            .Order(SortOrder.Ascending)
                                                            .Points(new GeoLocation(lat, lng)));

            Func <SortDescriptor <Place>, IPromise <IList <ISort> > > sort = s => SortByGeo(s.Descending(SortSpecialField.Score).Descending(d => d.Rating));

            searchDescriptor
            .Index <Place>()
            .Query(x => query)
            .Sort(sort)
            .ScriptFields(x =>
                          x.ScriptField("distance", s => s.Source($"doc['geometry.location'].arcDistance({lat},{lng})")))
            .Take(10)
            .Source(true)
            ;
            #endregion

            var results = await client.SearchAsync <Place>(searchDescriptor);

            var model = ToSearchPlaces(results.Hits).First();

            var term = new TermVectorsDescriptor <Place>(IndexName.From <Place>(), TypeName.From <Place>());
            term.Index <Place>()
            .Id(Id.From(model))
            .Fields(tf => tf.Vicinity, tf => tf.Name)
            ;

            var sss = dumper.Dump <TermVectorsDescriptor <Place> >(term);

            var termVectorsResult = await client.TermVectorsAsync <Place>(term);

            return(ToTermVectorsModel(termVectorsResult, model));
        }
Ejemplo n.º 8
0
        //
        // Details
        //

        static bool TryGetKey(Type declaredType, out DurableTypeKey key)
        {
            var value =
                declaredType.GetCustomAttribute <DurablePrefixAttribute>()?.Prefix
                ?? declaredType.Assembly.GetCustomAttribute <DurablePrefixAttribute>()?.Prefix
                ?? "";

            key = DurablePrefix.TryFrom(value, out var prefix)
        ? DurableTypeKey.From(prefix, TypeName.From(declaredType))
        : null;

            return(key != null);
        }
        public async Task LocationIsOfTypeGeoPoint()
        {
            var response = await ElasticClient()
                           .GetMappingAsync <CoffeeLocation>();

            var actual = response.Indices[IndexName].Mappings[TypeName.From <CoffeeLocation>()]
                         .Properties
                         .FirstOrDefault(x => x.Key == "location")
                         .Value
                         .GetType();

            Assert.AreEqual(typeof(GeoPointProperty), actual);
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                db.Genre.Add(genre);
                db.SaveChanges();
                ElasticsearchHelper.EsClient().Index <Genre>(genre,
                                                             id => id.Index("genres")
                                                             .Type(TypeName.From <Genre>())
                                                             .Id(genre.Id)
                                                             .Refresh(Elasticsearch.Net.Refresh.True));
                return(RedirectToAction("Index"));
            }

            return(View(genre));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Get the specified id.
        /// </summary>
        /// <returns>The get.</returns>
        /// <param name="id">Identifier.</param>
        public User Get(int id)
        {
            IGetResponse <User> response;
            IGetRequest         request = new GetRequest(Configuration.IndexName, TypeName.From <User>(), new Id(id));

            response = Client.Get <User>(request);

            if (response.Found)
            {
                return(response.Source);
            }
            else
            {
                return(null);
            }
        }
        public async Task CreateDataDemo()
        {
            ConnectionSettings settings = new ConnectionSettings(new Uri("http://localhost:9200"));

            settings.DefaultIndex("sample");
            ElasticClient esClient = new ElasticClient(settings);

            List <Question> _lstQuestion = new List <Question>();

            _lstQuestion.Add(new Question {
                Id = 1, Body = "Huy là sinh viên đại học", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 2, Body = "Tèo đang học mỹ thuật", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 3, Body = "Tí đang đi du lịch tại Mỹ Tho", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 4, Body = "Tú đang du học ở Mỹ", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 5, Body = "VN đang đá bóng ở sân Mỹ Đình", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 6, Body = "bạn Đại học ở Mỹ Tho", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 7, Body = "bạn học tên Nguyễn Văn Mỹ", Score = 1, CreationDate = DateTime.Now
            });

            _lstQuestion.Add(new Question {
                Id = 8, Body = "Làm thế nào bạn phân biệt được mùi dầu thơm ban đầu, hương chính, hương nền", Score = 1, CreationDate = DateTime.Now
            });
            _lstQuestion.Add(new Question {
                Id = 9, Body = "Nước hoa có khác nhau giữa người này với người khác không? Vì sao?", Score = 1, CreationDate = DateTime.Now
            });

            foreach (var item in _lstQuestion)
            {
                await esClient.IndexAsync <Question>(item, i => i
                                                     .Index("sample")
                                                     .Type(TypeName.From <Question>())
                                                     .Id(item.Id)
                                                     .Refresh(Elasticsearch.Net.Refresh.True));
            }
        }
        public async Task <string> Create(string quesID, string body)
        {
            Question question = new Question();

            question.Id           = Int32.Parse(quesID);
            question.Score        = 1;
            question.CreationDate = DateTime.Now;
            question.Body         = body;

            var response = await _client.IndexAsync <Question>(question, x => x
                                                               .Index("sample")
                                                               .Type(TypeName.From <Question>())
                                                               .Id(question.Id)
                                                               .Refresh(Elasticsearch.Net.Refresh.True));

            return(response.Id.ToString());
        }
Ejemplo n.º 14
0
        IEnumerable <FlowKey> ReadResumeFlows(JArray json)
        {
            foreach (var typeItem in json)
            {
                if (typeItem is JArray multiInstance)
                {
                    var type = _context.Area.GetFlow(TypeName.From(multiInstance[0].Value <string>()));

                    foreach (var idItem in multiInstance.Skip(1))
                    {
                        yield return(FlowKey.From(type, Id.From(idItem.Value <string>())));
                    }
                }
                else
                {
                    yield return(FlowKey.From(typeItem.Value <string>(), _context.Area));
                }
            }
        }
Ejemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Id,Title,Description,CreatedDate,GenreId")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                movie.CreatedDate = DateTime.Now;
                db.Movie.Add(movie);
                db.SaveChanges();

                ElasticsearchHelper.EsClient().Index <Movie>(movie,
                                                             id => id.Index("movies")
                                                             .Type(TypeName.From <Movie>())
                                                             .Id(movie.Id)
                                                             .Refresh(Elasticsearch.Net.Refresh.True));

                return(RedirectToAction("Index"));
            }
            ViewBag.GenreID = new SelectList(db.Genre, "ID", "Name", movie.GenreId);
            return(View(movie));
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            EsNode   = new Uri("http://localhost:9200/");
            EsConfig = new ConnectionSettings(EsNode);
            EsClient = new ElasticClient(EsConfig);

            var settings = new IndexSettings {
                NumberOfReplicas = 1, NumberOfShards = 2
            };

            var indexConfig = new IndexState
            {
                Settings = settings
            };

            if (!EsClient.IndexExists("onlinefoodbooking").Exists)
            {
                EsClient.CreateIndex("onlinefoodbooking", c => c
                                     .InitializeUsing(indexConfig)
                                     .Mappings(m => m.Map <FoodMenu>(mp => mp.AutoMap())));
            }
            OnlineFoodBookingElasticEntities ctx = new OnlineFoodBookingElasticEntities();

            foreach (var item in ctx.FoodMenus)
            {
                FoodMenu studentEsObj = new FoodMenu
                {
                    FoodId   = item.FoodId,
                    FoodItem = item.FoodItem,
                    Price    = item.Price,
                };
                var response = EsClient.IndexAsync <FoodMenu>(studentEsObj, i => i
                                                              .Index("onlinefoodbooking")
                                                              .Type(TypeName.From <FoodMenu>())
                                                              .Id(item.FoodId)
                                                              .Refresh(Elasticsearch.Net.Refresh.True));
            }
        }
Ejemplo n.º 17
0
        [U] public void UsingWithRequests()
        {
            var project = new Project {
                Name = "hello-world"
            };

            /** Here we can see and example how DocumentPath helps your describe your requests more tersely */
            var request = new IndexRequest <Project>(2)
            {
                Document = project
            };

            request = new IndexRequest <Project>(project)
            {
            };

            /** when comparing with the full blown constructor and passing document manually
             * DocumentPath&lt;T&gt;'s benefits become apparent.
             */
            request = new IndexRequest <Project>(IndexName.From <Project>(), TypeName.From <Project>(), 2)
            {
                Document = project
            };
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Removes a page from the index.
 /// </summary>
 public async Task RemovePageAsync(Page page)
 {
     await _client.DeleteAsync(new DeleteRequest(PAGE_INDEX, TypeName.From <PageDocument>(), page.Id));
 }
        public async Task CustomIndexAndTypeName()
        {
            var indexName = "custom-index";

            using (var store = new UserStoreFixture <ExtendedUser>(ElasticServerUrl, indexName, true, true))
            {
                var user = new ExtendedUser(UserId, UserName);

                user.Roles.UnionWith(new[] { "hello" });

                await store.CreateAsync(user);

                var response = store.Client.Get <ExtendedUser>(new GetRequest(indexName, TypeName.From <ExtendedUser>(), user.Id));

                Assert.NotNull(response.Source);
                Assert.Equal(response.Source.UserName, user.UserName);
            }
        }
Ejemplo n.º 20
0
        [U] public async Task Urls()
        {
            var project = new Project {
                Name = "NEST"
            };

            await PUT("/project/project/1/_create")
            .Fluent(c => c.Create <object>(new { }, i => i.Index(typeof(Project)).Type(typeof(Project)).Id(1)))
            .Request(c => c.Create(new CreateRequest <object>("project", "project", 1)
            {
                Document = new { }
            }))
            .FluentAsync(c => c.CreateAsync <object>(new {}, i => i.Index(typeof(Project)).Type(typeof(Project)).Id(1)))
            .RequestAsync(c => c.CreateAsync(new CreateRequest <object>(IndexName.From <Project>(), TypeName.From <Project>(), 1)
            {
                Document = new { }
            }))
            ;

            await PUT("/project/project/NEST/_create")
            .Fluent(c => c.Create(project))
            .Request(c => c.Create(new CreateRequest <Project>(project)))
            .Request(c => c.Create(new CreateRequest <Project>(project, "project", "project", "NEST")
            {
                Document = project
            }))
            .FluentAsync(c => c.CreateAsync(project))
            .RequestAsync(c => c.CreateAsync(new CreateRequest <Project>(project)))
            .RequestAsync(c => c.CreateAsync(new CreateRequest <Project>(project, "project", "project", "NEST")
            {
                Document = project
            }))
            ;

            await PUT("/different-projects/project/elasticsearch/_create")
            .Request(c => c.Create(new CreateRequest <Project>("different-projects", "project", "elasticsearch")
            {
                Document = project
            }))
            .Request(c => c.Create(new CreateRequest <Project>(project, "different-projects", "project", "elasticsearch")))
            .RequestAsync(c => c.CreateAsync(new CreateRequest <Project>(project, "different-projects", "project", "elasticsearch")))
            .RequestAsync(c => c.CreateAsync(new CreateRequest <Project>("different-projects", "project", "elasticsearch")
            {
                Document = project
            }))
            ;
        }
Ejemplo n.º 21
0
        [U] public async Task Urls()
        {
            var project = new Project {
                Name = "NEST"
            };

            await POST("/project/project")
            .Fluent(c => c.Index(project, i => i.Id(null)))
            .Request(c => c.Index(new IndexRequest <Project>("project", "project")
            {
                Document = project
            }))
            .FluentAsync(c => c.IndexAsync(project, i => i.Id(null)))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(typeof(Project), TypeName.From <Project>())
            {
                Document = project
            }))
            ;

            await PUT("/project/project/NEST")
            .Fluent(c => c.Index(project))
            .Request(c => c.Index(new IndexRequest <Project>("project", "project", "NEST")
            {
                Document = project
            }))
            .Request(c => c.Index(new IndexRequest <Project>(project)))
            .FluentAsync(c => c.IndexAsync(project))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(project)))
            ;
        }
 /// <summary>
 /// Inserts the index.
 /// </summary>
 /// <param name="indexItemId">The index item identifier.</param>
 /// <returns>Response object with details</returns>
 public IDeleteResponse DeleteIndex(Id indexItemId)
 {
     return(this.elasticClient.Delete(new DeleteRequest(this.indexTablename, TypeName.From <TEntity>(), indexItemId)));
 }
Ejemplo n.º 23
0
 public async Task Consume(ConsumeContext <PhotoRemovedEvent> context)
 {
     await _client.DeleteAsync(new DeleteRequest(IndexName.From <PhotoSearchModel>(), TypeName.From <PhotoSearchModel>(), Id.From(new PhotoSearchModel()
     {
         OriginalUrl = context.Message.OriginalUrl,
         PhotoId = context.Message.PhotoId,
         ProductId = context.Message.ProductId
     })));
 }
        public async Task importExcel(string path)
        {
            ConnectionSettings settings = new ConnectionSettings(new Uri(_urlAPI));

            settings.DefaultIndex("sample");
            ElasticClient esClient = new ElasticClient(settings);

            //Create COM Objects. Create a COM object for everything that is referenced
            Excel.Application xlApp       = new Excel.Application();
            Excel.Workbook    xlWorkbook  = xlApp.Workbooks.Open(path);//@"D:\HDHUY-DATA\DATA-THUE\HOI DAP_THUE VA HOA DON CHUNG TU 2018.xlsx"
            Excel._Worksheet  xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range       xlRange     = xlWorksheet.UsedRange;

            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;

            //iterate over the rows and columns and print to the console as it appears in the file
            //excel is not zero based!!
            Console.OutputEncoding = UTF8Encoding.UTF8;
            for (int i = 2; i <= rowCount; i++)
            {
                int j = 2;
                //for (int j = 2; j <= colCount; j++)
                //{
                ////new line
                //if (j == 1)
                //    Console.Write("\r\n");

                //write the value to the console
                if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null)
                {
                    Console.Write(xlRange.Cells[i, 1].Value2.ToString() + "\t" + xlRange.Cells[i, j].Value2.ToString() + "\r\n");

                    Question question = new Question();
                    question.Id           = i;
                    question.Score        = 1;
                    question.CreationDate = DateTime.Now;
                    question.Body         = xlRange.Cells[i, j].Value2.ToString();
                    await esClient.IndexAsync <Question>(question, x => x
                                                         .Index("sample")
                                                         .Type(TypeName.From <Question>())
                                                         .Id(question.Id)
                                                         .Refresh(Elasticsearch.Net.Refresh.True));
                }
            }

            //cleanup
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //rule of thumb for releasing com objects:
            //  never use two dots, all COM objects must be referenced and released individually
            //  ex: [somthing].[something].[something] is bad

            //release com objects to fully kill excel process from running in the background
            Marshal.ReleaseComObject(xlRange);
            Marshal.ReleaseComObject(xlWorksheet);

            //close and release
            xlWorkbook.Close();
            Marshal.ReleaseComObject(xlWorkbook);

            //quit and release
            xlApp.Quit();
            Marshal.ReleaseComObject(xlApp);
        }
Ejemplo n.º 25
0
 static AreaTypeInfo TryFrom <TAssignable>(Type type, bool isEvent = false, bool isTopic = false, bool isQuery = false) =>
 typeof(TAssignable).IsAssignableFrom(type)
 ? new AreaTypeInfo(type, TypeName.From(type), isEvent, isTopic, isQuery)
 : null;
Ejemplo n.º 26
0
        [U] public async Task CanIndexUrlIds()
        {
            var id      = "http://my.local/id?qwe=2";
            var escaped = Uri.EscapeDataString(id);

            escaped.Should().NotContain("/").And.NotContain("?");
            var project = new Project {
                Name = "name"
            };

            await PUT($"/project/doc/{escaped}?routing=name")
            .Fluent(c => c.Index(project, i => i.Id(id)))
            .Request(c => c.Index(new IndexRequest <Project>("project", "doc", id)
            {
                Document = project
            }))
            .FluentAsync(c => c.IndexAsync(project, i => i.Id(id)))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(typeof(Project), TypeName.From <Project>(), id)
            {
                Document = project
            }));

            project = new Project {
                Name = id
            };
            await PUT($"/project/doc/{escaped}?routing={escaped}")
            .Fluent(c => c.Index(project, i => i.Id(id)))
            .Request(c => c.Index(new IndexRequest <Project>("project", "doc", id)
            {
                Document = project
            }))
            .FluentAsync(c => c.IndexAsync(project, i => i.Id(id)))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(typeof(Project), TypeName.From <Project>(), id)
            {
                Document = project
            }));
        }
Ejemplo n.º 27
0
        [U] public async Task Urls()
        {
            var project = new Project {
                Name = "NEST"
            };

            await POST("/project/doc?routing=NEST")
            .Fluent(c => c.Index(project, i => i.Id(null)))
            .Request(c => c.Index(new IndexRequest <Project>("project", "doc")
            {
                Document = project
            }))
            .FluentAsync(c => c.IndexAsync(project, i => i.Id(null)))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(typeof(Project), TypeName.From <Project>())
            {
                Document = project
            }));

            //no explicit ID is provided and none can be inferred on the anonymous object so this falls back to a POST to /index/type
            await POST("/project/doc")
            .Fluent(c => c.Index(new { }, i => i.Index(typeof(Project)).Type(typeof(Project))))
            .Request(c => c.Index(new IndexRequest <object>("project", "doc")
            {
                Document = new { }
            }))
            .FluentAsync(c => c.IndexAsync(new { }, i => i.Index(typeof(Project)).Type(typeof(Project))))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <object>(typeof(Project), TypeName.From <Project>())
            {
                Document = new { }
            }));

            await PUT("/project/doc/NEST?routing=NEST")
            .Fluent(c => c.IndexDocument(project))
            .Request(c => c.Index(new IndexRequest <Project>("project", "doc", "NEST")
            {
                Document = project
            }))
            .Request(c => c.Index(new IndexRequest <Project>(project)))
            .FluentAsync(c => c.IndexDocumentAsync(project))
            .RequestAsync(c => c.IndexAsync(new IndexRequest <Project>(project)));
        }
Ejemplo n.º 28
0
 static DurableType CreateType(DurablePrefix prefix, Type declaredType) =>
 new DurableType(
     DurableTypeKey.From(prefix, TypeName.From(declaredType)),
     declaredType);
Ejemplo n.º 29
0
 public WrappedType(InternalAssembly originAssembly)
     : base(TypeName.From(typeof(Wrapped)), originAssembly)
 {
 }
Ejemplo n.º 30
0
 internal static EventType ReadEventType(this EventStoreContext context, ResolvedEvent e) =>
 context.Area.Events.Get(TypeName.From(e.Event.EventType));