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


C# SearchDescriptor类代码示例

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


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

示例1: GeoDistanceUsingHashAndOptions

 public void GeoDistanceUsingHashAndOptions()
 {
     var s = new SearchDescriptor<ElasticSearchProject>()
     .From(0)
     .Size(10)
     .QueryRawJson(@"{ raw : ""query""}")
     .FacetGeoDistance("geo1", gd => gd
       .OnValueField(f => f.Origin)
       .PinTo("drm3btev3e86")
       .Unit(GeoUnit.mi)
       .DistanceType(GeoDistance.arc)
     );
       var json = ElasticClient.Serialize(s);
       var expected = @"{ from: 0, size: 10,
       facets :  {
     ""geo1"" :  {
         geo_distance : {
             ""pin.location"" : ""drm3btev3e86"",
             value_field: ""origin"",
             unit: ""mi"",
             distance_type: ""arc""
         }
     }
       }, query : { raw : ""query""}
       }";
       Assert.True(json.JsonEquals(expected), json);
 }
开发者ID:aqbjteddy,项目名称:NEST,代码行数:27,代码来源:GeoDistanceFacetJson.cs

示例2: DateHistogram

        public void DateHistogram()
        {
            var s = new SearchDescriptor<ElasticsearchProject>()
            .From(0)
            .Size(10)
            .QueryRaw(@"{ raw : ""query""}")
            .FacetDateHistogram(h => h
              .OnField(f => f.StartedOn)
              .Interval(DateInterval.Day)
              .Factor(1000)
              );
              var json = TestElasticClient.Serialize(s);
              var expected = @"{ from: 0, size: 10,
              facets :  {
            ""startedOn"" :  {
                date_histogram : {
                    field : ""startedOn"",
                    interval : ""day"",
                    factor: 1000

                }
            }
              }, query : { raw : ""query""}
              }";
              Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:herqueles3,项目名称:elasticsearch-net,代码行数:26,代码来源:DateHistogramFacetJson.cs

示例3: IndicesQuery

 public void IndicesQuery()
 {
     var s = new SearchDescriptor<ElasticSearchProject>()
         .From(0)
         .Size(10)
         .Query(q => q
             .Indices(fz => fz
                 .Indices(new[] { "elasticsearchprojects", "people", "randomindex" })
                 .Query(qq => qq.Term(f => f.Name, "elasticsearch.pm"))
                 .NoMatchQuery(qq => qq.MatchAll())
             )
         );
     var json = ElasticClient.Serialize(s);
     var expected = @"{ from: 0, size: 10, query :
     {
         indices: {
             query: { term : { name : {  value : ""elasticsearch.pm"" }  } },
             no_match_query: {
                 match_all: {}
             },
             indices: [
                 ""elasticsearchprojects"",
                 ""people"",
                 ""randomindex""
             ]
         }
     }}";
     Assert.True(json.JsonEquals(expected), json);
 }
开发者ID:Wigren,项目名称:NEST,代码行数:29,代码来源:IndicesQueryJson.cs

示例4: GeoDistanceFilter

        public void GeoDistanceFilter()
        {
            var s = new SearchDescriptor<ElasticSearchProject>()
                .From(0)
                .Size(10)
                .Filter(filter => filter
                    .Cache(true)
                    .Name("my_geo_filter")
                    .GeoDistance(f=>f.Origin, d=>d
                        .Location(Lat: 40, Lon: -70)
                        .Distance(12, GeoUnit.km)
                        .Optimize(GeoOptimizeBBox.memory)
                    )
                );

            var json = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10,
                filter : {
                    geo_distance: {
                        distance: 12.0,
                        unit: ""km"",
                        optimize_bbox: ""memory"",
                        origin: ""40, -70"",
                        _cache: true,
                        _name: ""my_geo_filter""
                    }
                }
            }";
            Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:nickcanz,项目名称:NEST,代码行数:30,代码来源:GeoDistanceFilterJson.cs

示例5: NumericRangeDates

        public void NumericRangeDates()
        {
            var format = "yyyy/MM/dd";
            var lowerBound = DateTime.UtcNow.AddYears(-1);
            var upperBound = DateTime.UtcNow.AddYears(1);
            var s = new SearchDescriptor<ElasticSearchProject>()
                .From(0)
                .Size(10)
                .Filter(ff => ff
                    .NumericRange(n => n
                        .OnField(f => f.StartedOn)
                        .From(lowerBound, format)
                        .To(upperBound, format)
                        .FromExclusive()
                    )
                );

            var json = ElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10,
                filter : {
                        numeric_range: {
                            ""startedOn"": {
                                from: """ + lowerBound.ToString(format) + @""",
                                to: """ + upperBound.ToString(format) + @""",
                                from_inclusive: false
                            }
                        }

                    }
            }";
            Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:occ,项目名称:NEST,代码行数:32,代码来源:NumericRangeFilterJson.cs

示例6: TestRangeDateFacetKeyField

 public void TestRangeDateFacetKeyField()
 {
     var s = new SearchDescriptor<ElasticSearchProject>()
     .From(0)
     .Size(10)
     .QueryRaw(@"{ raw : ""query""}")
     .FacetRange<DateTime>("needs_a_name", t => t
       .KeyField("field_name")
       .ValueField("another_field_name")
       .Ranges(
     r => r.To(new DateTime(1990, 1, 1).Date)
       )
     );
       var json = TestElasticClient.Serialize(s);
       var expected = @"{ from: 0, size: 10,
       facets :  {
     ""needs_a_name"" : {
         range : {
             key_field : ""field_name"",
             value_field : ""another_field_name"",
             ranges: [
               {
                 to: ""1990-01-01T00:00:00""
               }
             ]
         }
     }
       }, query : { raw : ""query""}
       }";
       Assert.True(json.JsonEquals(expected), json);
 }
开发者ID:romankor,项目名称:NEST,代码行数:31,代码来源:RangeFacetJson.cs

示例7: RangeDoubles

		public void RangeDoubles()
		{
			var s = new SearchDescriptor<ElasticsearchProject>()
				.From(0)
				.Size(10)
				.Query(ff => ff
					.Range(n => n
						.OnField(f => f.LOC)
						.GreaterOrEquals(10.1)
						.LowerOrEquals(20.1)
					)
				);

			var json = TestElasticClient.Serialize(s);
			var expected = @"{ from: 0, size: 10, 
				query : {
						range: {
							""loc"": {
								gte: ""10.1"",
								lte: ""20.1"",
							}
						}

					}
			}";
			Assert.True(json.JsonEquals(expected), json);
		}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:27,代码来源:RangeQueryJson.cs

示例8: QueryFacetGlobal

        public void QueryFacetGlobal()
        {
            var s = new SearchDescriptor<ElasticSearchProject>()
            .From(0)
            .Size(10)
            .Query(@"{ raw : ""query""}")
            .FacetTerm(q=>q
              .OnField(f=>f.Name)
              .Global()
              .FacetFilter(ff=>ff.Exists(f=>f.Name))
            );

              var json = ElasticClient.Serialize(s);
              var expected = @"{ from: 0, size: 10,
              facets :  {
            ""name.sort"" :
            {
              global: true,
              terms: {
                field: ""name.sort""
              },
              facet_filter: {
                exists: { field: ""name"" }
              }
            }
              }, query : { raw : ""query""}
              }";
              Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:Wigren,项目名称:NEST,代码行数:29,代码来源:FacetJson.cs

示例9: TermsFilterWithConditionlessQueryWithCache

        public void TermsFilterWithConditionlessQueryWithCache()
        {
            var s = new SearchDescriptor<ElasticSearchProject>()
                .From(0)
                .Size(10)

                .FacetTerm(ft => ft
                    .FacetFilter(ff => ff.Query(fq => fq.Term("somefield", "")))
                    .AllTerms()
                    .OnField(p=>p.Name)
                );

            var json = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10,
                facets: {
                    name: {
                      terms: {
                        field: ""name"",
                        all_terms: true
                      }
                    }
                  }
            }";
            Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:jayakrishnagopal,项目名称:NEST,代码行数:25,代码来源:TermsFilterJson.cs

示例10: TestFuzzyLikeThisAllQuery

 public void TestFuzzyLikeThisAllQuery()
 {
     var s = new SearchDescriptor<ElasticSearchProject>()
         .From(0)
         .Size(10)
         .Query(q => q
             .FuzzyLikeThis(fz => fz
                 .OnFields(f => f.Name)
                 .LikeText("elasticsearcc")
                 .PrefixLength(3)
                 .MaxQueryTerms(25)
                 .MinimumSimilarity(3)
                 .IgnoreTermFrequency(true)
                 .Boost(1.1)
                 .Analyzer("my_analyzer")
             )
         );
     var json = TestElasticClient.Serialize(s);
     var expected = @"{ from: 0, size: 10, query :
     { flt: {
         fields : [""name"" ],
         like_text : ""elasticsearcc"",
         ignore_tf: true,
         max_query_terms: 25,
         min_similarity: 3,
         prefix_length: 3,
         boost: 1.1,
         analyzer: ""my_analyzer""
     }}}";
     Assert.True(json.JsonEquals(expected), json);
 }
开发者ID:summersk,项目名称:NEST,代码行数:31,代码来源:FuzzyLikeThisQueryJson.cs

示例11: AndFilter

		public void AndFilter()
		{
			var s = new SearchDescriptor<ElasticsearchProject>()
				.From(0)
				.Size(10)
				.Filter(filter=>filter
					.And(
						f=>f.MatchAll(),
						f=>f.Missing(p=>p.LOC)
					)
					
				);
				
			var json = TestElasticClient.Serialize(s);
			var expected = @"{ from: 0, size: 10, 
				filter : {
						""and"": {
							""filters"": [
								{
									""match_all"": {}
								},
								{
									""missing"": {
										""field"": ""loc""
									}
								}
							]
						}
					}
			}";
			Assert.True(json.JsonEquals(expected), json);		
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:32,代码来源:AndFilterJson.cs

示例12: HasChildFilter

		public void HasChildFilter()
		{
			var s = new SearchDescriptor<ElasticsearchProject>().From(0).Size(10)
				.Filter(ff=>ff
					.HasChild<Person>(d=>d
						.Query(q=>q.Term(p=>p.FirstName, "value"))
					)
				);
				
			var json = TestElasticClient.Serialize(s);
			var expected = @"{ from: 0, size: 10, 
				filter : {
					""has_child"": {
					  ""type"": ""person"",
					  ""query"": {
						""term"": {
						  ""firstName"": {
							""value"": ""value""
						  }
						}
					  }
					}
				}
			}";
			Assert.True(json.JsonEquals(expected), json);
		}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:26,代码来源:HasChildFilterJson.cs

示例13: HasChildThisQuery

        public void HasChildThisQuery()
        {
            var s = new SearchDescriptor<ElasticSearchProject>()
                .From(0)
                .Size(10)
                .Query(q => q
                    .HasChild<Person>(fz => fz
                        .Query(qq=>qq.Term(f=>f.FirstName, "john"))
                        .Scope("my_scope")
                        .Score(ChildScoreType.avg)
                    )
                );
            var json = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10, query :
            { has_child: {
                type: ""people"",
                _scope: ""my_scope"",
                score_type: ""avg"",
                query: {
                    term: {
                        firstName: {
                            value: ""john""
                        }
                    }
                }

            }}}";
            Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:hendryluk,项目名称:NEST,代码行数:29,代码来源:HasChildQueryJson.cs

示例14: RangeDatesCustom

        public void RangeDatesCustom()
        {
            var format = "yyyy/MM/dd";
            var lowerBound = DateTime.UtcNow.AddYears(-1);
            var upperBound = DateTime.UtcNow.AddYears(1);
            var s = new SearchDescriptor<ElasticSearchProject>()
                .From(0)
                .Size(10)
                .Query(ff => ff
                    .Range(n => n
                        .OnField(f => f.StartedOn)
                        .From(lowerBound, format)
                        .To(upperBound, format)
                        .FromExclusive()
                    )
                );

            var json = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10,
                query : {
                        range: {
                            ""startedOn"": {
                                from: """ + lowerBound.ToString(format) + @""",
                                to: """ + upperBound.ToString(format) + @""",
                                include_lower: false
                            }
                        }

                    }
            }";
            Assert.True(json.JsonEquals(expected), json + Environment.NewLine + expected);
        }
开发者ID:rmarinho,项目名称:NEST,代码行数:32,代码来源:RangeQueryJson.cs

示例15: QueryFacetScoped

        public void QueryFacetScoped()
        {
            var s = new SearchDescriptor<ElasticsearchProject>()
            .From(0)
            .Size(10)
            .QueryRaw(@"{ raw : ""query""}")
            .FacetTerm(q=>q
              .Scope("some_nested_query")
              .OnField(f=>f.Name)
              .FacetFilter(ff=>ff.Exists(f=>f.Name))
            );

              var json = TestElasticClient.Serialize(s);
              var expected = @"{ from: 0, size: 10,
              facets :  {
            ""name"" :
            {
              _scope: ""some_nested_query"",
              terms: {
                field: ""name""
              },
              facet_filter: {
                exists: { field: ""name"" }
              }
            }
              }, query : { raw : ""query""}
              }";
              Assert.True(json.JsonEquals(expected), json);
        }
开发者ID:herqueles3,项目名称:elasticsearch-net,代码行数:29,代码来源:FacetJson.cs


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