{"id":285319,"date":"2017-04-21T11:01:54","date_gmt":"2017-04-21T07:01:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285319"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285319","title":{"rendered":"LinqToSolr \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c LINQ \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Solr"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e78\/023\/24a\/e7802324a21723e5d27c230e3e85b4f0.jpg\" alt=\"image\"\/><br \/>  \u0412 \u0441\u0438\u043b\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 Solr, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a Solr \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 LINQ \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0448\u0435\u0440\u0441\u0442\u0438\u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432, \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043c\u043d\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u043e\u0431\u0449\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043d\u0435\u0442. \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438, <a href=\"https:\/\/github.com\/SolrNet\/SolrNet\/tree\/linq\/SolrNet.LINQ\">\u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/a> \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Solr.NET (\u0438 \u0441\u043a\u0435\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <a href=\"https:\/\/groups.google.com\/forum\/#!msg\/solrnet\/YVCp4UN-J0U\/6mrYBWII1csJ\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/a> \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430).<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0441\u0442\u0430\u043b\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f <a href=\"https:\/\/www.nuget.org\/packages\/LinqToSolr\/\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LinqToSolr<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IQueriable&lt;&gt; \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Solr API \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b Enumerable<\/h3>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:  <\/p>\n<ul>\n<li>Where<\/li>\n<li>First<\/li>\n<li>FirstOrDefault<\/li>\n<li>Select<\/li>\n<li>GroupBy<\/li>\n<li><i>GroupByFacets<\/i> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Facets<\/li>\n<li>Take<\/li>\n<li>Skip<\/li>\n<li>OrderBy<\/li>\n<li>ThenBy<\/li>\n<li>OrderByDescending<\/li>\n<li>ThenByDescending<\/li>\n<\/ul>\n<h3>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c Solr.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 Solr \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:  <\/p>\n<pre><code>public class MyProduct{          [JsonProperty(&quot;ProductId&quot;)]  \t public int Id{get;set;}  \t public string Name{get;set}   \t public string Group{get;set}          public double Price {get;set;}          public bool IsDeleted{get;set} } <\/code><\/pre>\n<p>  \u0412\u044b\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 Solr, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f Id, Name, Group, Price \u0438 IsDeleted. \u041f\u0440\u0438 \u0441\u0438\u043b\u044c\u043d\u043e\u043c \u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c JsonProperty, \u0442\u043e\u0447\u0431\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u044f Id).<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e:  <\/p>\n<pre><code>var config = new LinqToSolrRequestConfiguration(&quot;http:\/\/localhost:1433\/&quot;) .MapIndexFor&lt;MyProduct&gt;(&quot;MyProductIndex&quot;); <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u0438\u043c? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u043a Solr.<br \/>  \u0414\u0430\u043b\u0435\u0435, \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044e \u043d\u0430\u0448\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0421\u043e\u043b\u0430\u0440. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2014 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c. \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u0442\u043e\u0432\u0430.<\/p>\n<p>  \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c \u0441\u0435\u0440\u0432\u0438\u0441  <\/p>\n<pre><code>var service = new LinqToSolrService(config); <\/code><\/pre>\n<p>  \u0412\u0441\u0435. \u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Linq \u043a Solr.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  <\/p>\n<h4>\u041c\u0435\u0442\u043e\u0434 FirstOrDefault<\/h4>\n<p>  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().FirstOrDefalult(x=&gt; x.Id == 1); <\/code><\/pre>\n<h4>\u041c\u0435\u0442\u043e\u0434 Where<\/h4>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt;x.Group == &quot;Group1&quot;).ToList(); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 linq \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt;x.Group.Contains(&quot;roup&quot;)).ToList();  service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt;x.Group.StartsWith(&quot;Gro&quot;)).ToList();  service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt;x.Group.EndsWith(&quot;up1&quot;)).ToList(); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435  <\/p>\n<pre><code>var groupsArr= new[] { &quot;Group1&quot;, &quot;Group2&quot;, &quot;Group3&quot; }; service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; groupsArr.Contains(x.Group)).ToList(); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0441 \u00ab\u0431\u043e\u043b\u044c\u0448\u0435-\u043c\u0435\u043d\u044c\u0448\u0435\u00bb  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; x.Price &gt;= 500 && x.Price &lt; 1000).ToList(); <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e Where  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;() .Where(x=&gt; !x.IsDeleted) .Where(x=&gt;x.Name.Contains(&quot;somepartofthename&quot;)) .ToList(); <\/code><\/pre>\n<h4>\u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b<\/h4>\n<p>  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;() .Where(x=&gt; !x.IsDeleted) .OrderByDescending(x=&gt; x.Group) \/\/ DESC .ThenBy(x=&gt;x.Name) \/\/ ASC .ToList(); <\/code><\/pre>\n<h4>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e<\/h4>\n<p>  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; !x.IsDeleted).Take(100).Skip(400).ToList(); <\/code><\/pre>\n<h4>\u041c\u0435\u0442\u043e\u0434 Select<\/h4>\n<p>  <\/p>\n<pre><code>\/\/\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435 service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; !x.IsDeleted).Select(x=&gt; x.Name).ToList();  \/\/\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439 \u0432 dynamic-\u043e\u0431\u044a\u0435\u043a\u0442 service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; !x.IsDeleted).Select(x=&gt; new {x.Name, x.Group}).ToList(); <\/code><\/pre>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Facets<\/h4>\n<p>  <\/p>\n<pre><code>service.AsQueriable&lt;MyProduct&gt;().Where(x=&gt; !x.IsDeleted).GroupByFacets(x=&gt;x.Name, x=&gt;x.Group).ToList(); <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c Solr \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u043c 2 \u0433\u0440\u0443\u043f\u043f\u044b \u2014 Name \u0438 Group.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GroupBy \u043c\u0435\u0442\u043e\u0434. \u041e\u043d \u0436\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u043e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b. \u0427\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u2014 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0430\u043c. Facets \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c 2 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. GroupBy \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442, \u043f\u043e\u043c\u0438\u043c\u043e \u0433\u0440\u0443\u043f\u043f, \u0438 \u0441\u0430\u043c\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0443\u0436\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0430\u043c.<\/p>\n<h4>\u041e\u0442\u043b\u0430\u0434\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h4>\n<p>  \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0442\u0432\u0435\u0442. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 LastResponse. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Solr. \u041f\u043b\u044e\u0441, \u0442\u0430\u043c \u0436\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d Url \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (LastRequestUrl), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0435\u0437\u0435\u0440\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Solr.<\/p>\n<h3>\u0421\u0435\u0440\u0432\u0438\u0441<\/h3>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c LinqToSolrService \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 LinqToSolrService.  <\/p>\n<pre><code>public class MySolrService : LinqToSolrService  {     public MySolrService(LinqToSolrRequestConfiguration config) : base (config)     {    }      public IQueryable&lt;MyProduct&gt; NotDeleted()     {             return AsQueryable&lt;MyProduct&gt;().Where(x=&gt; !x.IsDeleted);     }      public ICollection&lt;MyProduct&gt; GetProducts(params int[] ids)     {             return NotDeleted().Where(x=&gt; ids.Contains(x.Id)).OrderBy(x=&gt;x.Name).ToList();     }      public MyProduct GetProduct(id)     {             return NotDeleted().FirstOrDefault(x=&gt; x.Id == id);     }      public string[] GetGroups(id)     {             return NotDeleted().GroupBy(x=&gt; x.Group).ToArray();     } } <\/code><\/pre>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u043e\u043c\u0443-\u0442\u043e, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u0437\u0443\u0435\u0442 Solr \u0432 .NET \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0438 \u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<br \/>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u0430\u043c\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. <br \/>  \u0412 \u043f\u043b\u0430\u043d\u0430\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Boost, Proximity \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/327002\/\"> https:\/\/habrahabr.ru\/post\/327002\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e78\/023\/24a\/e7802324a21723e5d27c230e3e85b4f0.jpg\" alt=\"image\"\/><br \/>  \u0412 \u0441\u0438\u043b\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 Solr, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a Solr \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 LINQ \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0448\u0435\u0440\u0441\u0442\u0438\u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432, \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043c\u043d\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u043e\u0431\u0449\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043d\u0435\u0442. \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438, <a href=\"https:\/\/github.com\/SolrNet\/SolrNet\/tree\/linq\/SolrNet.LINQ\">\u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/a> \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Solr.NET (\u0438 \u0441\u043a\u0435\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <a href=\"https:\/\/groups.google.com\/forum\/#!msg\/solrnet\/YVCp4UN-J0U\/6mrYBWII1csJ\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/a> \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430).<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0441\u0442\u0430\u043b\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f <a href=\"https:\/\/www.nuget.org\/packages\/LinqToSolr\/\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LinqToSolr<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IQueriable&lt;&gt; \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Solr API \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-285319","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=285319"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285319\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}