当前位置: 首页>>代码示例>>C#>>正文


C# ElasticsearchContext.IndexTypeExists方法代码示例

本文整理汇总了C#中ElasticsearchContext.IndexTypeExists方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticsearchContext.IndexTypeExists方法的具体用法?C# ElasticsearchContext.IndexTypeExists怎么用?C# ElasticsearchContext.IndexTypeExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElasticsearchContext的用法示例。


在下文中一共展示了ElasticsearchContext.IndexTypeExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchAggTermsBucketAggregationnWithChildrenSubAggNoHits

        public void SearchAggTermsBucketAggregationnWithChildrenSubAggNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new TermsBucketAggregation("test_min", "info")
                    {
                        Aggs = new List<IAggs>
                        {
                            new ChidrenBucketAggregation("childrenAgg", "testobjchildsep")
                            {
                                Aggs = new List<IAggs>
                                {
                                    new TermsBucketAggregation("infoAgg", "info")
                                }
                            }
                        }
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<TestObjParentSep>());
                Assert.IsTrue(context.IndexTypeExists<TestObjChildSep>());

                var items = context.Search<TestObjParentSep>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<TermsBucketAggregationsResult>("test_min");

                Assert.AreEqual(3, aggResult.Buckets[0].DocCount);

            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:34,代码来源:SearchQueryQueryTopChildrenAndChidrenBucketAggregationTests.cs

示例2: SearchQueryBoolQuery

        public void SearchQueryBoolQuery()
        {
            var search = new Search
            {
                Query = new Query(
                    new BoolQuery
                    {
                        Must = new List<IQuery>
                        {
                            new RangeQuery("id") { GreaterThanOrEqualTo = "2", LessThan = "3", LessThanOrEqualTo = "2", GreaterThan = "1" }
                        },
                        MustNot = new List<IQuery>
                        {
                            new RangeQuery("id") {GreaterThan="34"}
                        },
                        Should = new List<IQuery>
                        {
                            new TermQuery("name", "two")
                        },
                        Boost=2.0,
                        DisableCoord= false,
                        MinimumShouldMatch= "2"
                    }
                )
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                Assert.IsTrue(context.IndexTypeExists<SearchTest>());
                var items = context.Search<SearchTest>(search);
                Assert.AreEqual(2, items.PayloadResult.Hits.HitsResult[0].Source.Id);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:34,代码来源:SearchQueryQueryTests.cs

示例3: SearchAggGeohashGridBucketAggregationWithSubAggSignificantTermsBucketAggregationWithNoHits

        public void SearchAggGeohashGridBucketAggregationWithSubAggSignificantTermsBucketAggregationWithNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new GeohashGridBucketAggregation("termsDetails", "location")
                    {
                        Aggs = new List<IAggs>
                        {
                            new SignificantTermsBucketAggregation("testSignificantTermsBucketAggregation", "details")
                        },
                        Precision = 2
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var termsAggResult = items.PayloadResult.Aggregations.GetComplexValue<TermsBucketAggregationsResult>("termsDetails");
                var significantAggResult = termsAggResult.Buckets[0].GetSubAggregationsFromJTokenName<SignificantTermsBucketAggregationsResult>("testSignificantTermsBucketAggregation");
                Assert.AreEqual(3, significantAggResult.Buckets[0].BgCount);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:26,代码来源:SignificantTermsBucketAggregationTests.cs

示例4: SearchAggSignificantTermsBucketAggregationPropertiesSet

        public void SearchAggSignificantTermsBucketAggregationPropertiesSet()
        {
            var search = new Search
            {
                Query = new Query(new MatchAllQuery()),
                Aggs = new List<IAggs>
                {
                    new SignificantTermsBucketAggregation("testSignificantTermsBucketAggregation", "details")
                    {
                        BackgroundFilter= new TermFilter("name", "details"),
                        InformationRetrievalRetrieval = new MutualInformation
                        {
                            BackgroundIsSuperset = false,
                            IncludeNegatives = false
                        },
                        ExecutionHint= ExecutionHint.global_ordinals
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<SignificantTermsBucketAggregationsResult>("testSignificantTermsBucketAggregation");
                Assert.AreEqual(7, aggResult.DocCount);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:28,代码来源:SignificantTermsBucketAggregationTests.cs

示例5: SearchAggDateRangesBucketAggregationKeyedWithNoHits

        public void SearchAggDateRangesBucketAggregationKeyedWithNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new DateRangeBucketAggregation("testRangesBucketAggregation", "dateofdetails", "MM-yyy", new List<RangeAggregationParameter<string>>
                    {
                        new ToRangeAggregationParameter<string>("now-8M/M"),
                        new ToFromRangeAggregationParameter<string>("now-8M/M", "now-10M/M"),
                        new FromRangeAggregationParameter<string>("now-10M/M")
                        {
                            Key = "keyName"
                        }
                    })
                    {
                        Keyed= true
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<RangesNamedBucketAggregationsResult>("testRangesBucketAggregation");
                var test = aggResult.Buckets.GetSubAggregationsFromJTokenName<RangeBucket>("keyName");

                Assert.AreEqual(7, test.DocCount);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:31,代码来源:RangesAggregationTests.cs

示例6: SearchAggGeohashGridBucketAggregationWithTopHitsSubWithNoHits

        public void SearchAggGeohashGridBucketAggregationWithTopHitsSubWithNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
                    {
                        Aggs = new List<IAggs>
                        {
                            new TopHitsMetricAggregation("tophits")
                        }
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
                var topHits = aggResult.Buckets[0].GetSubAggregationsFromJTokenName<TopHitsMetricAggregationsResult<SearchAggTest>>("tophits");
                Assert.AreEqual(3, aggResult.Buckets[0].DocCount);
                Assert.AreEqual(3, topHits.Hits.Total);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:26,代码来源:GeohashGridBucketAggregationTests.cs

示例7: SearchQueryMoreLikeThisQuery

        public void SearchQueryMoreLikeThisQuery()
        {
            var search = new Search
            {
                Query = new Query(
                    new MoreLikeThisQuery
                    {
                        Fields = new List<string> {"moreinfo"},
                        LikeText = "yes one",
                        MinTermFreq = 1,
                        Boost = 50,
                        MinDocFreq = 1,
                        PercentTermsToMatch = 0.01

                    }
                )
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                Assert.IsTrue(context.IndexTypeExists<MoreLikeThisTestDto>());
                var items = context.Search<MoreLikeThisTestDto>(search);
                Assert.AreEqual(2, items.PayloadResult.Hits.Total);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:26,代码来源:SearchQueryFilterTestsMoreLikeThis.cs

示例8: SearchAggFilterBucketAggregationWithChildrenNoHits

        public void SearchAggFilterBucketAggregationWithChildrenNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new FilterBucketAggregation("globalbucket", new GeoDistanceFilter("location", new GeoPoint(32,42), new DistanceUnitKilometer(10000) ))
                    {
                        Aggs = new List<IAggs>
                        {
                            new MaxMetricAggregation("maxAgg", "lift"),
                            new MinMetricAggregation("minAgg", "lift"),
                            new TopHitsMetricAggregation("topHits")
                            {
                                Size = 3
                            }
                        }
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GlobalBucketAggregationsResult>("globalbucket");
                var max = aggResult.GetSingleMetricSubAggregationValue<double>("maxAgg");
                Assert.AreEqual(7, aggResult.DocCount);
                Assert.AreEqual(2.9, max);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:31,代码来源:FilterBucketAggregationAndMissingBucketAggregationTests.cs

示例9: SearchAggScriptedMetricAggregationWithParamsWithNoHits

        public void SearchAggScriptedMetricAggregationWithParamsWithNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new ScriptedMetricAggregation("topScriptedMetricAggregation", "_agg.transactions.add(doc['lift'].value  * _agg.times)")
                    {
                        InitScript= "_agg['transactions'] = []",
                        CombineScript= "script_calculated = 0; for (t in _agg.transactions) { script_calculated += t }; return script_calculated",
                        ReduceScript= "script_calculated = 0; for (a in _aggs) { script_calculated += a }; return script_calculated",
                        Params = new ParamsForScript("_agg")
                        {
                            Params = new List<ScriptParameter>
                            {
                                new ScriptParameter("times", 1.4),
                            }
                        }
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetSingleMetricAggregationValue<double>("topScriptedMetricAggregation");
                Assert.AreEqual(22.82, aggResult);

            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:31,代码来源:ScriptedMetricAggregationTests.cs

示例10: SearchAggTermsBucketAggregationWithSubTopHitsMetricAggregationWithNoHits

        public void SearchAggTermsBucketAggregationWithSubTopHitsMetricAggregationWithNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new TermsBucketAggregation("test_min", "lift")
                    {
                        Aggs = new List<IAggs>
                        {
                            new TopHitsMetricAggregation("topHits")
                            {
                                Size = 5
                            }
                        }
                    }
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchAggTest>());
                var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<TermsBucketAggregationsResult>("test_min");
                var hitsForBucket = aggResult.Buckets[0].GetSubAggregationsFromJTokenName<TopHitsMetricAggregationsResult<SearchAggTest>>("topHits");

                Assert.AreEqual(3, aggResult.Buckets[0].DocCount);
                Assert.AreEqual(2.1, hitsForBucket.Hits.HitsResult[0].Source.Lift);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:30,代码来源:TopHitsAggregationTests.cs

示例11: SearchQueryQueryStringQueryAllProperties

        public void SearchQueryQueryStringQueryAllProperties()
        {
            var search = new Search
            {
                Query = new Query(new QueryStringQuery("one document")
                {
                    AllowLeadingWildcard = true,
                    Analyzer = LanguageAnalyzers.German,
                    AnalyzeWildcard = false,
                    AutoGeneratePhraseQueries = false,
                    Boost = 2.1,
                    DefaultField = "_all",
                    DefaultOperator = QueryDefaultOperator.OR,
                    EnablePositionIncrements = true,
                    Fuzziness = 0.5,
                    FuzzyMaxExpansions = 49,
                    FuzzyPrefixLength = 0,
                    Lenient = false,
                    Locale = "ROOT"
                })
            };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchTest>());
                var items = context.Search<SearchTest>(search);
                Assert.AreEqual(2, items.PayloadResult.Hits.Total);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:29,代码来源:SearchQueryQueryStringQueryTest.cs

示例12: SearchQueryMatchPhaseTest

        public void SearchQueryMatchPhaseTest()
        {
            var search = new Search { Query = new Query(new MatchPhaseQuery("name", "one") { Analyzer = LanguageAnalyzers.German, Slop = 1, Operator = Operator.and, CutoffFrequency = 0.2, ZeroTermsQuery = ZeroTermsQuery.none, Boost = 1.1, Fuzziness = 1 }) };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchTest>());
                var items = context.Search<SearchTest>(search);
                Assert.AreEqual(1, items.PayloadResult.Hits.HitsResult[0].Source.Id);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:11,代码来源:SearchQueryQueryMatchTests.cs

示例13: SaveToElasticsearchStateProvinceIfitDoesNotExist

		public void SaveToElasticsearchStateProvinceIfitDoesNotExist()
		{
			IElasticsearchMappingResolver elasticsearchMappingResolver = new ElasticsearchMappingResolver();
			using (var elasticSearchContext = new ElasticsearchContext("http://localhost:9200/", new ElasticsearchSerializerConfiguration(elasticsearchMappingResolver, true, true)))
			{
				if (!elasticSearchContext.IndexTypeExists<StateProvince>())
				{
					elasticSearchContext.TraceProvider = new ConsoleTraceProvider();
					using (var databaseEfModel = new EfModel())
					{
						int pointer = 0;
						const int interval = 20;
						bool firstRun = true;
						int length = databaseEfModel.StateProvince.Count();

						while (pointer < length)
						{
							_stopwatch.Start();
							var collection =
								databaseEfModel.StateProvince.OrderBy(t => t.StateProvinceID)
									.Skip(pointer)
									.Take(interval)
									.ToList<StateProvince>();
							_stopwatch.Stop();
							Console.WriteLine("Time taken for select {0} Address: {1}", interval, _stopwatch.Elapsed);
							_stopwatch.Reset();

							_stopwatch.Start();
							foreach (var item in collection)
							{
								var ee = item.CountryRegion.Name;
								elasticSearchContext.AddUpdateDocument(item, item.StateProvinceID);
							}

							if (firstRun)
							{
								elasticSearchContext.SaveChangesAndInitMappings();
								firstRun = false;
							}
							else
							{
								elasticSearchContext.SaveChanges();
							}

							_stopwatch.Stop();
							Console.WriteLine("Time taken to insert {0} Address documents: {1}", interval, _stopwatch.Elapsed);
							_stopwatch.Reset();
							pointer = pointer + interval;
							Console.WriteLine("Transferred: {0} items", pointer);
						}
					}
				}
			}
		}
开发者ID:emretiryaki,项目名称:WebSearchWithElasticsearchEntityFrameworkAsPrimary,代码行数:54,代码来源:InitializeSearchEngine.cs

示例14: SearchQueryMatchTest

        public void SearchQueryMatchTest()
        {
            var search = new Search { Query = new Query(new MatchQuery("name", "document one") { Boost = 1.1, Fuzziness = 1 }) };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchTest>());
                var items = context.Search<SearchTest>(search);
                Assert.AreEqual(1, items.PayloadResult.Hits.HitsResult[0].Source.Id);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:11,代码来源:SearchQueryQueryMatchTests.cs

示例15: SearchFilterMatchAllTest

        public void SearchFilterMatchAllTest()
        {
            var search = new Search { Filter = new Filter(new MatchAllFilter { Boost = 1.1 }) };

            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<SearchTest>());
                var items = context.Search<SearchTest>(search);
                Assert.AreEqual(1, items.PayloadResult.Hits.HitsResult[0].Source.Id);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:11,代码来源:SearchQueryFilterTests.cs


注:本文中的ElasticsearchContext.IndexTypeExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。