示例#1
0
        private static Lucene.Net.Search.Query HandleStartsWith(Query query, MethodExpression expression, QueryMetadata metadata, BlittableJsonReaderObject parameters)
        {
            var fieldName = ExtractIndexFieldName(query, parameters, expression.Arguments[0], metadata);

            var(value, valueType) = GetValue(fieldName, query, metadata, parameters, (ValueExpression)expression.Arguments[1]);

            if (valueType != ValueTokenType.String)
            {
                ThrowMethodExpectsArgumentOfTheFollowingType("startsWith", ValueTokenType.String, valueType, metadata.QueryText, parameters);
            }

            var valueAsString = GetValueAsString(value);

            if (string.IsNullOrEmpty(valueAsString))
            {
                valueAsString = LuceneQueryHelper.Asterisk;
            }
            else
            {
                valueAsString += LuceneQueryHelper.Asterisk;
            }

            return(LuceneQueryHelper.Term(fieldName, valueAsString, LuceneTermType.Prefix));
        }
示例#2
0
        private static Lucene.Net.Search.Query HandleExists(Query query, BlittableJsonReaderObject parameters, MethodExpression expression, QueryMetadata metadata)
        {
            var fieldName = ExtractIndexFieldName(query, parameters, expression.Arguments[0], metadata);

            return(LuceneQueryHelper.Term(fieldName, LuceneQueryHelper.Asterisk, LuceneTermType.WildCard));
        }