• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SearchModel.Search类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ElasticsearchCRUD.Model.SearchModel.Search的典型用法代码示例。如果您正苦于以下问题:C# Search类的具体用法?C# Search怎么用?C# Search使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Search类属于ElasticsearchCRUD.Model.SearchModel命名空间,在下文中一共展示了Search类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits

        public void SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits()
        {
            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new TermsBucketAggregation("test_min", "lift")
                    {
                        Order= new OrderAgg("childAggSum", OrderEnum.asc),
                        Aggs = new List<IAggs>
                        {
                            new SumMetricAggregation("childAggSum", "lift"),
                            new AvgMetricAggregation("childAggAvg", "lift"),
                            new GlobalBucketAggregation("test")
                        }
                    }
                }
            };

            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 bucketchildAggSum = aggResult.Buckets[0].GetSingleMetricSubAggregationValue<double>("childAggSum");
                var bucketchildAggAvg = aggResult.Buckets[0].GetSingleMetricSubAggregationValue<double>("childAggAvg");
                Assert.AreEqual(1, aggResult.Buckets[0].DocCount);
                Assert.AreEqual(1.7, bucketchildAggSum);
                Assert.AreEqual(1.7, bucketchildAggAvg);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:31,代码来源:GlobalBucketAggregationTests.cs


示例2: 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


示例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: 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


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: SearchQueryQueryStringQuery

        public void SearchQueryQueryStringQuery()
        {
            var search = new Search { Query = new Query(new QueryStringQuery("one document")) };

            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,代码行数:11,代码来源:SearchQueryQueryStringQueryTest.cs


示例16: SearchQueryConstantScoreQueryWithQuery

        public void SearchQueryConstantScoreQueryWithQuery()
        {
            var search = new Search { Query = new Query(new ConstantScoreQuery(new TermQuery("name", "two")){Boost = 2.0}) };

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


示例17: 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


示例18: SearchQueryMatchPhasePrefixTest

        public void SearchQueryMatchPhasePrefixTest()
        {
            var search = new Search { Query = new Query(new MatchPhasePrefixQuery("name", "one") { MaxExpansions = 500, Boost = 1.1, MinimumShouldMatch = "50%", 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


示例19: SearchQueryMultiMatchAllTest

        public void SearchQueryMultiMatchAllTest()
        {
            var search = new Search { Query = new Query(new MultiMatchQuery("document") { MultiMatchType = MultiMatchType.most_fields, TieBreaker = 0.5, Fields = new List<string> { "name", "details" } }) };

            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


示例20: SearchAggAvgAggregationNoHits

        public void SearchAggAvgAggregationNoHits()
        {
            var search = new Search { Aggs = new List<IAggs>{ new AvgMetricAggregation("test_avg", "lift") }};

            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>("test_avg");
                Assert.AreEqual("2.33", Math.Round(aggResult, 2).ToString(CultureInfo.InvariantCulture));
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:12,代码来源:SearchAggStructureTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Common.SigmaResultType类代码示例发布时间:2022-05-24
下一篇:
C# Ekona.sFolder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap