public QueryParserQueryInstance CreateQueryParserQuery(string query, string defaultField, bool allowLeadingWildcard) { var qPq = new QueryParserQuery { AllowLeadingWildcard = allowLeadingWildcard, DefaultField = defaultField, Query = query }; return(new QueryParserQueryInstance(Engine.Object.InstancePrototype, qPq)); }
public SearchArguments GetSearchArguments() { var result = new SearchArguments(); //Determine the Query value. if (this.Query == null || this.Query == Null.Value || this.Query == Undefined.Value) { throw new JavaScriptException(this.Engine, "Error", "The Query property of the argument instance cannot be null or undefined."); } var searchQueryType = this.Query.GetType(); if (searchQueryType.IsSubclassOfRawGeneric(typeof(QueryInstance <>))) { var queryProperty = searchQueryType.GetProperty("Query", BindingFlags.Instance | BindingFlags.Public); result.Query = queryProperty.GetValue(this.Query, null) as Query; } else { var parser = new QueryParserQuery { Query = TypeConverter.ToString(this.Query) }; result.Query = parser; } //Determine the Filter value. var searchFilterType = this.Filter.GetType(); if (searchFilterType.IsSubclassOfRawGeneric(typeof(FilterInstance <>))) { var filterProperty = searchFilterType.GetProperty("Filter", BindingFlags.Instance | BindingFlags.Public); result.Filter = filterProperty.GetValue(this.Filter, null) as Filter; } else { var parser = new QueryParserQuery { Query = TypeConverter.ToString(this.Query) }; result.Filter = new QueryWrapperFilter { Query = parser }; } //Determine the Sort value. if (this.Sort is SortInstance) { result.Sort = (this.Sort as SortInstance).Sort; } else if (TypeUtilities.IsString(this.Sort)) { result.Sort = new Sort { SortFields = new List <SortField> { new SortField { FieldName = this.Sort as string, Type = SortFieldType.String } } }; } if (this.GroupByFields != null && this.GroupByFields.Length > 0) { result.GroupByFields = this.GroupByFields.ElementValues.Select(v => TypeConverter.ToString(v)).ToList(); } if (Skip > 0) { result.Skip = this.Skip; } if (Take > 0) { result.Take = this.Take; } return(result); }