I had the same question. But for the time being, I used the default configured external indexes. In my Umbraco 8 test project, this partial snippet is used for searching content of document type "Quotation":
// q = search string from an input field
// Break search into separate terms
// You should check for null or empty string
var _searchTerms = q.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
// I use a loop here so I can optionally remove noise words and such...
foreach (var term in _searchTerms)
{
searchTerms.Add(term);
}
if (searchTerms.Length > 0)
{
if (!ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index) || !(index is IUmbracoIndex umbIndex))
{
throw new InvalidOperationException($"No index found by name ExternalIndex or is not of type {typeof(IUmbracoIndex)}");
}
var searcher = umbIndex.GetSearcher();
if (searcher != null)
{
var qry = searcher.CreateQuery("", BooleanOperation.And)
.Field("__NodeTypeAlias", "quotation");
foreach (var term in searchTerms)
{
qry = qry.Or().Field("quote", term);
}
var results = qry.Execute(10);
if (results != null && results.Count() > 0)
{
// Process results
}
}
}
Hope this helps while they rework the documentation ;)
Where are the Examine config files located in v8?
Hi,
Does anyone know where the ExamineIndex.config and ExamineSettings.config are located in Umbraco 8? I can't find this files.
Also the Examine Management tab only lists the Indexers. The configured (or not?) searchers aren't listed.
I thought examine is now configured in code. The documentation is not yet done as you can see here: https://our.umbraco.com/Documentation/v8documentation
I would look for components with examine in the name in the source code for now.
Try this thread:
https://our.umbraco.com/forum/umbraco-8/95915-umbraco-8-examine-indexes#comment-303736
I had the same question. But for the time being, I used the default configured external indexes. In my Umbraco 8 test project, this partial snippet is used for searching content of document type "Quotation":
Hope this helps while they rework the documentation ;)
This was pretty much what I was looking for. I was failing with TryGetSearcher because there was none, but the way with the index solved it for me!
Do you know how to search multiple document types? e.g quotation and others?
In my example, try adding query criteria like:
is working on a reply...