This project is read-only.
Support has been added for multiple operators. It supports querying both directly upon the Query<T> type and from within a Where() clause. Currently, the API looks within the Query<T> member's FieldAttributes for any fields marked IsDefault=true to create the default field list. Some of the query operators listed below support specifying an explicit field for the queryString by using the Where() clause. Other operators will soon work within Where(), all will add support for specific fields when querying directly against Query<T>.

The operators that have been developed include the following: with various overloads for each function (not listed here)
public static Query<T> Search<T>(string queryString) Applies native Lucene syntax
public static Query<T> Boost<T>(float factor) Boosts a search phrase
public static Query<T> Like<T>(string phrase, float fuzziness) Applies Fuzzy or Proximity to a search
public static Query<T> Match<T>(string phrase) Applies wildcard matches to search
public static Query<T> StartsWith<T>(string phrase) Finds matches to the prefix of a phrase
public static Query<T> Range<T>(string startRange, string endRange) Finds matches within the a range, inclusive by default
public static Query<T> Between<T>(string from, string to) Finds matches within a range, exclusive
public static Query<T> StartGroup<T>() Begins a query Grouping
public static Query<T> Group<T>(Func<Query<T>, Query<T>> function) Performs a search function within a group
public static Query<T> EndGroup<T>() Ends a query Grouping
public static Query<T> Or<T>(Func<Query<T>, Query<T>> function) Applies OR logic to a set of conditions
public static Query<T> And<T>(Func<Query<T>, Query<T>> function) Applies AND logic to a set of conditions

Code Samples:
NorthwindIndexContext index = new NorthwindIndexContext();

var query = from c in index.Customers.Search("!myField:Jason test~);  // Output: !myField:Jason test~

var query = from c in index.Customers.StartsWith("mar")               // Output: mar*^2.3 OR asdf* (mo?se)
                                     .Or(x => x.StartsWith("asdf")
                                     .Group(x => x.Match("mo?se"));

var query = from c in index.Customers                                 // Output: ContactName:"maria"~0.7
            where c.ContactName.Like("maria", 0.7f)
            select new { Name = c.ContactName, Id = c.CustomerID };

This is in no way a 'stable' release but is a chance for developers to see some of the basics about how the API will work. There are certainly scenarios and types of queries that won't work or will produce unexpected results. Also, Xml commenting is still not anywhere near as thorough as it needs to be, nor is the exception handling and printing. These types of defects will be corrected in future builds.

Also, a lot of the operators currently only support using the default-fields of the type. Applying specific fields to an operation will be supported soon.

Also note that projection and object creation currently only supports translation to string types.

Last edited Apr 2, 2012 at 5:42 PM by stemarie, version 1


No comments yet.