Hello guys, i've been trying to get my search bar going but i cannot find how to implement this code in my template:
@using Examine @using Examine.SearchCriteria @{ //Get the values posted from the form var searchTerm = Request.Form["searchTerm"];
//Check if searchQuery is null from the posted form data... if (searchTerm == null) { //If it is null then the form was not posted and the page was visited directly <p>Please use the search box</p>
//Stop all other code running in this Macro return; }
var searcher = ExamineManager.Instance.SearchProviderCollection["RazorSiteSearcher"]; var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or); var query = searchCriteria.GroupedOr(new string[] { "nodeName", "bodyText" }, searchTerm).Compile(); var searchResults = searcher.Search(query); var noResults = searchResults.Count(); <p>You searched for @searchTerm, and found @noResults results</p> <ul class="search-results"> @foreach (var result in searchResults) { <li> <a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a> </li> } </ul> }
P.S: I got this code from the umbraco "Razor CookBook_search" folder.
Hi, given video is paid tutorial so if want then you have to subscribe with 19 EUR per month then you can watch full video. I think so it's not very tuff task to implement the examine search. Please let me know then exact error which you are getting currently.
follow the same steps, as I provided earlier link for configuration. Note: if you are using 4.7.2 then no need to do that because it's already configured.
@{ var searchString = Request["searchstring"]; if (!String.IsNullOrEmpty(searchString)) { var searchProvider = ExamineManager.Instance.DefaultSearchProvider.Name; var searchResults = ExamineManager.Instance.SearchProviderCollection[searchProvider].Search(searchString, true);
foreach (var c in searchResults) { <div> <h3><a href="@umbraco.library.NiceUrl(c.Id)">@c.Fields["nodeName"]</a></h3> </div> } } }
How to implement search code in Umbraco 4.7
Hello guys, i've been trying to get my search bar going but i cannot find how to implement this code in my template:
@using Examine
@using Examine.SearchCriteria
@{
//Get the values posted from the form
var searchTerm = Request.Form["searchTerm"];
//Check if searchQuery is null from the posted form data...
if (searchTerm == null)
{
//If it is null then the form was not posted and the page was visited directly
<p>Please use the search box</p>
//Stop all other code running in this Macro
return;
}
var searcher = ExamineManager.Instance.SearchProviderCollection["RazorSiteSearcher"];
var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
var query = searchCriteria.GroupedOr(new string[] { "nodeName", "bodyText" }, searchTerm).Compile();
var searchResults = searcher.Search(query);
var noResults = searchResults.Count();
<p>You searched for @searchTerm, and found @noResults results</p>
<ul class="search-results">
@foreach (var result in searchResults)
{
<li>
<a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a>
</li>
}
</ul>
}
P.S: I got this code from the umbraco "Razor CookBook_search" folder.
I hope someone can reply as soon as possible!!
Thanks a ton.
Had you configured all required settings?
http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine.aspx/
No. Will do. I will be back in a minute. Thanks a lot
I've been trying to make the examine code work, but the video tutorials on umbraco are very short with little to no info at all. And the page you sent me doesn't really explain well enough. What i want to know is the continuation of this video(setting up a new search index): http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/examine/setting-up-a-new-search-index.aspx
Hi, given video is paid tutorial so if want then you have to subscribe with 19 EUR per month then you can watch full video. I think so it's not very tuff task to implement the examine search. Please let me know then exact error which you are getting currently.
Parwej
e: [email protected]
I have configured everything necessary but i keep on getting this error:
Exception Details: System.Configuration.Provider.ProviderException: Unable to load default search provider
I did the quick test and it's working fine:
follow the same steps, as I provided earlier link for configuration. Note: if you are using 4.7.2 then no need to do that because it's already configured.
Search form:
<form method="post">
<input type="text" id="searchstring" name="searchstring" />
<input type="submit"/>
</form>
Razor script for result:
@using Examine
@using Examine.SearchCriteria
@using UmbracoExamine
@{
var searchString = Request["searchstring"];
if (!String.IsNullOrEmpty(searchString))
{
var searchProvider = ExamineManager.Instance.DefaultSearchProvider.Name;
var searchResults = ExamineManager.Instance.SearchProviderCollection[searchProvider].Search(searchString, true);
foreach (var c in searchResults)
{
<div>
<h3><a href="@umbraco.library.NiceUrl(c.Id)">@c.Fields["nodeName"]</a></h3>
</div>
}
}
}
Please let me know if still not working.
Parwej
[email protected]
is working on a reply...