I'm pretty new to Umbraco and I'm trying to get a more advanced search on the go.
I've managed to implement a simple site search using the default ExternalIndexer, but I'm looking to create another search that uses my own Indexer.
I've updated my ExamineSettings.config and ExamineIndex.config files and verified my new index is working as intended by using the Examine Management tab and running searches using my new search indexer that appears under 'Searchers'.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Examine.LuceneEngine.SearchCriteria;
@{
var query = Request.QueryString["query"];
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MySearchSearcher"];
var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
var searchQuery = searchCriteria.Field("nodeName", query.Boost(5)).Or().Field("nodeName", query.Fuzzy()).And().OrderByDescending("createDate");
var searchResults = searcher.Search(searchQuery.Compile());
if(searchResults.Any())
{
<ul>
@foreach (var result in searchResults)
{
<li>
@result.Id;
</li>
}
</ul>
}
}
This renders the ID of expected results, but when I try to use @result.nodeName or @result.Url, I get a compiler error message:
CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments
How can I output and render other values, including custom doctype fields?
Had no idea it returned results in a different format from normal and that the code to output it was different as a result. They should really add that to the original help file!
Lucene Search Query
Hi guys,
I'm pretty new to Umbraco and I'm trying to get a more advanced search on the go.
I've managed to implement a simple site search using the default ExternalIndexer, but I'm looking to create another search that uses my own Indexer.
I've updated my ExamineSettings.config and ExamineIndex.config files and verified my new index is working as intended by using the Examine Management tab and running searches using my new search indexer that appears under 'Searchers'.
I have a simple Partial View setup, using the code from the Fluent API section of the quick start guide, however, I can't seem to render anything other than the node Id.
Here's my Partial View code:
This renders the ID of expected results, but when I try to use @result.nodeName or @result.Url, I get a compiler error message:
How can I output and render other values, including custom doctype fields?
.Search() returns an ISearchResults object.
You should be able to access these properties similar to how you would a dictionary.
E.g.
Just note that if the property doesn't exist then it'll throw an exception. You can use
If you don't want to debug you can print out all the fields and their values:
This is just what I was looking for, thanks!
Had no idea it returned results in a different format from normal and that the code to output it was different as a result. They should really add that to the original help file!
Thanks!
is working on a reply...