Skip to content

Linq provider to solrnet

oshvartz edited this page Nov 12, 2011 · 4 revisions

#Enables query solr in a Linq Syntax#

How To Use

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:

  1. Equals: var linqQuery = from doc in solr.AsQueryable() where doc.Name == "aa" select doc;

  2. Greater/Smaller Equals var linqQuery = from doc in solr.AsQueryable() where doc.Price >= 1 && doc.Price <= 10 select doc;

  3. 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;

  1. Collection Query – Single var linqQuery = from doc in solr.AsQueryable() where doc.Categories.AnyItem() == "cat1" select doc;
  2. AdditinalParameters var linqQuery = (from doc in solr.AsQueryable() where (doc.Price >= priceVal || doc.Timestamp >= dt) select doc).AdditinalParameters(new Dictionary<string,string>{{ "queryduration","100"}};
  3. dynamic fields var linqQuery = from doc in solr.AsQueryable() where doc.DynamicField("field_1") == "val" select doc;

Clone this wiki locally