I am searching for new How does this do the same query using LINQ? Any attempt I have made here is: UPDATE I'm sure I find something very simple. Definitely with all the work done in the new search API, this easy-to-use case was not ignored ... right? As an alternative solution, I use the default Unfortunately, I have to resort to the existing API until I understand it. I want to update this question with my findings. Update 2 Class me the I have tried all the predicate builders did not work, however, with Sitcom 7 ships a Sitecore.ContentSearch "LINQ to Sitecore" API in Sitcom. It is my understanding that Sitcom has advised to use the new LINQ API on the existing
Sitecore.Search API, however, I am struggling to perform the simplest of queries. For example, the following search code:
"Hello World" . Using the
Sitecore.Search API, the term "hello world" is usually a
query parser , resulting in "hello" or "world" The documents that match the word will be
var results = SearchContext.GetQueryable & lt; MyResultItem & gt; (); Var word = searchTerm.Split (''); // Supported exception results = results are not. Where (R = & gt; Anyone (T = & gt; R. content. Canton (R)); // close, but performs an "and" between words, and // does not appear to properly predict the documents. (Different words as a result) {results = results.Where (r = & gt; r.Content.Contains (t)); }
sitecore_web_index current search manager, however, that does not work.
Sitecore.ContentSearch.Utilities.LinqHelper class that partially solves the problem. You can use it to create a query dynamically similar to
BooleanQuery in Lucin.net, however, this option is limited and it adds some additional overhead.
PredicateBuilder did its own tricks.
using Sitecore.ContentSearch; Using Sitecore.ContentSearch.Linq; Using Sitecore.ContentSearch.SearchTypes; Using Sitecore.ContentSearch.Utilities; // Sitcom 7 (Update 1+): Using Sitecore.ContentSearch.Linq.Utilities; ... var index = ContentSearchManager.GetIndex ("sitecore_web_index"); (Var reference = index.CreateSearchContext ()) using {var predicate = PredicateBuilder.True & lt; SearchResultItem & gt; (); Foreign words (word in word T. sample ('')) {var tempTerm = t; Predicate = predicate.or (p = & gt; p.Content.Contains (tempTerm)); } Var Results = Reference.GetTable & lt; SearchResultItem & gt; (). (Predicate) .GetResults (); ...}
No comments:
Post a Comment