Ejemplo n.º 1
0
        public void TestUpdate()
        {
            var s = new UpdateDescriptor <ElasticSearchProject>()
                    .Script("ctx._source.counter += count")
                    .Params(p => p
                            .Add("count", 4)
                            );
            var json     = TestElasticClient.Serialize(s);
            var expected = @"  {
	      script: ""ctx._source.counter += count"",
	      params: {
	        count: 4
	      }
	    }"    ;

            Assert.True(json.JsonEquals(expected), json);
        }
Ejemplo n.º 2
0
        public void TestSort()
        {
            var s = new SearchDescriptor <ElasticSearchProject>()
                    .From(0)
                    .Size(10)
                    .Fields(e => e.Id, e => e.Name)
                    .SortAscending(e => e.LOC);
            var json     = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10, 
					sort: {
						""loc"": ""asc""
					},
					fields: [""id"", ""name""]
				}"                ;

            Assert.True(json.JsonEquals(expected));
        }
Ejemplo n.º 3
0
        public void TestBasics()
        {
            var s = new SearchDescriptor <ElasticSearchProject>()
                    .Skip(0)
                    .Take(10)
                    .Explain()
                    .Version()
                    .MinScore(0.4);
            var json     = TestElasticClient.Serialize(s);
            var expected = @"{ 
				from: 0, size: 10,
				explain: true, 
				version: true,
				min_score: 0.4
			}"            ;

            Assert.True(json.JsonEquals(expected));
        }
Ejemplo n.º 4
0
        public void TestFromSize()
        {
            var s = new SearchDescriptor <ElasticSearchProject>()
                    .From(0)
                    .Size(10)
                    .Query(q => q.Term(f => f.Name.Suffix("sort"), "value"));
            var json     = TestElasticClient.Serialize(s);
            var expected = @"{ from: 0, size: 10,
            query: {
          term: {
            ""name.sort"": {
              value: ""value""
            }
          }
        }
      }";

            Assert.True(json.JsonEquals(expected), json);
        }
Ejemplo n.º 5
0
        public void TestSort()
        {
            var s = new SearchDescriptor <ElasticSearchProject>()
                    .From(0)
                    .Size(10)
                    .Sort(sort => sort
                          .OnField(e => e.Name)
                          .MissingLast()
                          .Descending()
                          );
            var json     = TestElasticClient.Serialize(s);
            var expected = @"  {
		  from: 0,
		  size: 10,
		  sort: {
			name: {
			  missing: ""_last"",
			  order: ""desc""
			}
		  }
		}"        ;

            Assert.True(json.JsonEquals(expected), json);
        }
Ejemplo n.º 6
0
        protected void JsonNotEquals(object o, MethodBase method, string fileName = null)
        {
            var json = TestElasticClient.Serialize(o);

            this.JsonNotEquals(json, method, fileName);
        }