Reputation: 37
I want to start using "lucene" to query "Umbraco" content ,
What is the easiest way to get it up and running.
I tried using easy search "lucene wrapper",
It is working but i am not getting any results from the query,
I try to delete ExamineIndexes from /App_Data/TEMP
But Umbraco do not create new ExamineIndexes file
I am using Umbraco version 7.1.8
And c#
I am trying to query the examineindexes: at the front end
Upvotes: 0
Views: 853
Reputation: 1021
Examine
is a Lucene
implementation for Umbraco.
Taken from the Umbraco documentation, the following steps should help you get going with searching with Examine
and Umbraco:
To create a searchable index we need to create 3 things: an Indexer a Searcher and an Index Set.
Open ~/Config/ExamineSettings.config and add an indexer under the 'ExamineIndexProviders/providers' section (in this example it is named ExternalIndexer):
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
In the same file (~/Config/ExamineSettings.config) add a searcher under the 'ExamineSearchProviders/providers' section (in this example it is named ExternalSearcher):
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
In the same file we'll change the default search provider to the one we've created, set defaultProvider="ExternalSearcher"
Open ~/Config/ExamineIndex.config and add an index set (in this example it is named ExternalIndexSet
):
<IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />
We have a searchable index configured using Examine. Examine will detect that the index doesn't exist on the file system yet so the index will be rebuilt during application startup. Once that happens the index will automatically stay up to date with the data in Umbraco.
In razor macros there's a Search
method on the DynamicNode
model which will return a DynamicNodeList
:
@if (!string.IsNullOrEmpty(Request.QueryString["query"]))
{
<ul>
@foreach (var result in Umbraco.Search(Request.QueryString["query"]))
{
<li>
<a href="@result.Url">@result.Name</a>
</li>
}
</ul>
}
Upvotes: 1