Beispiel #1
0
        public void CorrectParamsAreIncluded()
        {
            var condition  = new PrefixCondition("some test text", "testfield", 6);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(prefix field=testfield boost=6 'some test text')"));
        }
        public void CorrectParamsAreIncluded()
        {
            var condition = new PrefixCondition("some test text", "testfield", 6);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(prefix field=testfield boost=6 'some test text')"));
        }
Beispiel #3
0
        public string ToWhereClause(int skip, int take)
        {
            if (skip > Conditions.Count())
            {
                return(string.Empty);
            }
            if (Conditions.IsEmpty())
            {
                return(PrefixCondition);
            }

            var whereClause = new StringBuilder();

            if (!PrefixCondition.IsEmpty())
            {
                whereClause.Append($"({PrefixCondition}) AND (");
            }

            var relevantConditions = Conditions
                                     .Skip(skip)
                                     .Take(take)
                                     .ToList();

            foreach (var condition in relevantConditions)
            {
                whereClause.Append($"({condition}) OR ");
            }

            if (PrefixCondition.IsEmpty())
            {
                whereClause.ReplaceLastOccurrence(" OR ", string.Empty);
            }
            else
            {
                whereClause.ReplaceLastOccurrence(" OR ", ")");
            }

            return(whereClause.ToString());
        }