-
Notifications
You must be signed in to change notification settings - Fork 0
Linq provider to solrnet
#Linq Provider to Solrnet
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; -
DefaultField Equals query:
var linqQuery = from doc in solr.AsQueryable() where doc.DefaultFieldEquals("aa") select doc;
- AND / OR:
var linqQuery = from doc in solr.AsQueryable() where doc.DefaultField("aa") && (doc.Price >= 1 || doc.Price <= 11) select doc;
-
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;` -
Pagination
var linqQuery = (from doc in solr.AsQueryable() where (doc.Price >= priceVal || doc.Timestamp >= dt) select doc).Pagination(10,15);
- Sort
var linqQuery = from doc in solr.AsQueryable() where (doc.Price >= priceVal || doc.Timestamp >= dt) orderby doc.Id, doc.Price descending select doc;
-
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;