Sunday, 20 August 2017

Implement Sitecore Solr Simple Search in 5 mins

Follow the below steps to search by item name

  1.  you just need to add references of the Solr content Seach from visual studio
  2.  Add the below code in your class file as a method

     List<SearchResultItem> results;

            using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext())
            {
                var predicate = PredicateBuilder.True<SearchResultItem>();
    
                // must have this (.and) if you want o query specific path then enable below line
                //predicate = predicate.And(p => p.Paths.Contains(FolderItem.ID));
    
                // must have this (.and)
                predicate = predicate.And(p => p.Name == searchTerm);
    
                results = context.GetQueryable<SearchResultItem>().Where(predicate).ToList();
            }
  3.  Finally, Rebuild indexes from Sitecore control panel

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...