-
Notifications
You must be signed in to change notification settings - Fork 0
Linq provider to solrnet
#Enables query solr in a Linq Syntax#
In order to use just add:
using SolrNet.LINQ;
and for ISolrBasicReadOnlyOperations<T> you can write AsQueryable() getting the
IOrderedQueryable<TData> object
Supporting the following features:
-
Equals:
var linqQuery = from doc in solr.AsQueryable() where doc.Name == "aa" select doc; -
Greater/Smaller Equals
var linqQuery = from doc in solr.AsQueryable() where doc.Price >= 1 && doc.Price <= 10 select doc; -
Not Operator ` var linqQuery = from doc in solr.AsQueryable() where !(doc.Name == "bb") select doc;
4. DefaultField Equals query: var linqQuery = from doc in solr.AsQueryable()
where doc.DefaultFieldEquals("aa")
select doc;
5. AND / OR
var linqQuery = from doc in solr.AsQueryable()
where doc.DefaultField("aa") && (doc.Price >= 1 || doc.Price <= 11)
select doc;
6. Partial Eval
int priceVal = 1;
DateTime dt = new DateTime(2011, 1, 1);
var linqQuery = from doc in solr.AsQueryable()
where (doc.Price >= priceVal || doc.Timestamp >= dt)
select doc;
7. Pagination
var linqQuery = (from doc in solr.AsQueryable()
where (doc.Price >= priceVal || doc.Timestamp >= dt)
select doc).Pagination(10,15);
`
8. Sort
var linqQuery = from doc in solr.AsQueryable() where (doc.Price >= priceVal || doc.Timestamp >= dt) orderby doc.Id, doc.Price descending select doc;
9. Boost
var linqQuery = from doc in solr.AsQueryable() where (doc.Name == "john").Boost(10) select doc;
- Collection Query – Single
var linqQuery = from doc in solr.AsQueryable() where doc.Categories.AnyItem() == "cat1" select doc; - AdditinalParameters
var linqQuery = (from doc in solr.AsQueryable() where (doc.Price >= priceVal || doc.Timestamp >= dt) select doc).AdditinalParameters(new Dictionary<string,string>{{ "queryduration","100"}}; - dynamic fields
var linqQuery = from doc in solr.AsQueryable() where doc.DynamicField("field_1") == "val" select doc;