public void OrderByScoreFieldTranslatesToScoreSortAscending()
        {
            var ordered     = Robots.OrderBy(e => ElasticFields.Score);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.Single(sortOptions, o => o.Ascending && o.Name == "_score");
            Assert.Equal(1, sortOptions.Count);
        }
        public void OrderByTranslatesToSortAscending()
        {
            var ordered     = Robots.OrderBy(e => e.Id);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, "prefix", ordered.Expression).SearchRequest.SortOptions;

            Assert.Single(sortOptions, o => o.Ascending && o.Name == "prefix.id");
            Assert.Equal(1, sortOptions.Count);
        }
        public void OrderByNullableIntSpecifiesIgnoreUnmappedSortOption()
        {
            var ordered     = Robots.OrderBy(e => e.Zone);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.Equal(1, sortOptions.Count);
            Assert.True(sortOptions[0].IgnoreUnmapped);
        }
        public void OrderByDecimalDoesNotSpecifyIgnoreUnmappedSortOption()
        {
            var ordered     = Robots.OrderBy(e => e.EnergyUse);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.Equal(1, sortOptions.Count);
            Assert.False(sortOptions[0].IgnoreUnmapped);
        }
        public void ThenByScoreDescendingTranslatesToSortDescending()
        {
            var ordered     = Robots.OrderBy(o => o.Id).ThenByScoreDescending();
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.True(sortOptions[0].Ascending && sortOptions[0].Name == "id");
            Assert.True(!sortOptions[1].Ascending && sortOptions[1].Name == "_score");
            Assert.Equal(2, sortOptions.Count);
        }
Ejemplo n.º 6
0
        public void OrderByStringSpecifiesUnmappedTypeSortOption()
        {
            var ordered     = Robots.OrderBy(e => e.Name);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.Equal(1, sortOptions.Count);
            Assert.Equal("text", sortOptions[0].UnmappedType);
        }
        public void ThenByDescendingTranslatesToSecondSortDescending()
        {
            var ordered     = Robots.OrderBy(e => e.Id).ThenByDescending(e => e.Name);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.True(sortOptions[0].Ascending && sortOptions[0].Name == "id");
            Assert.True(!sortOptions[1].Ascending && sortOptions[1].Name == "name");
            Assert.Equal(2, sortOptions.Count);
        }
        public void ThenByScoreFieldTranslatesToSecondScoreSortAscending()
        {
            var ordered     = Robots.OrderBy(e => e.Id).ThenBy(e => ElasticFields.Score);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, "prefix", ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.True(sortOptions[0].Ascending && sortOptions[0].Name == "prefix.id");
            Assert.True(sortOptions[1].Ascending && sortOptions[1].Name == "_score");
            Assert.Equal(2, sortOptions.Count);
        }
        public void OrderByWithThenByTwiceTranslatesToThreeSorts()
        {
            var ordered     = Robots.OrderBy(e => e.Id).ThenByScore().ThenBy(e => e.Cost);
            var sortOptions = ElasticQueryTranslator.Translate(Mapping, ordered.Expression).SearchRequest.SortOptions;

            Assert.NotNull(sortOptions);
            Assert.True(sortOptions[0].Ascending && sortOptions[0].Name == "id");
            Assert.True(sortOptions[1].Ascending && sortOptions[1].Name == "_score");
            Assert.True(sortOptions[2].Ascending && sortOptions[2].Name == "cost");
            Assert.Equal(3, sortOptions.Count);
        }