本文整理汇总了C#中ElasticsearchCRUD.Model.SearchModel.Search类的典型用法代码示例。如果您正苦于以下问题:C# Search类的具体用法?C# Search怎么用?C# Search使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Search类属于ElasticsearchCRUD.Model.SearchModel命名空间,在下文中一共展示了Search类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}