I am wondering if there is a quick guide on how to extend the Backoffice Search in that manner that custom fields are included. I have browsed the Umbraco forum for quite a while now, but have not found an appropriate answer.
Problem:
I get search results searching for the name:
But do not get results searching for my custom field "code":
I already tried to make changes in the ExaminSettings.config so that the field gets indexed:
and somehow umbraco knows about the existance of the value:
but how can I get it to show the node in the result list?
I have come accross the Examining Examine page about a dozen times by now but, please correct me if I'm wrong, it seems a little over the top for my purpose.
Backoffice search will only search based on name (node name), so no, ootb, the search won't help you, even if you've added those fields to the index.
But, there's always an extension point, albeit not that straightforward.
Basically, you'll have to intercept the current api call and replace it with your own api call. As long as you return the same return value, you'd only need to intercept the call and use your own. I'll see if I can dig up that intercept example.
//Just in case you'd only want to change the search algorithm but keep the current search results presentation, in which case you'do need no custom view
angular.module("umbraco.services").config(["$httpProvider", function ($httpProvider) {
$httpProvider.interceptors.push(function ($q) {
return {
'request': function (request) {
//Redirect any requests for the search engine to our own Solr search engine
if (request.url.startsWith("/umbraco/backoffice/UmbracoApi/Entity/SearchAll")) {
var query = request.url.split("?")[1].split("=")[1];
//console.log("query=" + query);
request.url = "/umbraco/backoffice/X/Api/SearchAll?query=" + query;
}
return request || $q.when(request);
}
};
});
}]);
Only thing left is to create a XApiController, with a SearchAll(string query) function and perform your advanced Examine query to fetch the results
Backoffice Search
Hi there,
I am wondering if there is a quick guide on how to extend the Backoffice Search in that manner that custom fields are included. I have browsed the Umbraco forum for quite a while now, but have not found an appropriate answer.
Problem: I get search results searching for the name:
But do not get results searching for my custom field "code":
I already tried to make changes in the ExaminSettings.config so that the field gets indexed:
and somehow umbraco knows about the existance of the value:
but how can I get it to show the node in the result list?
I have come accross the Examining Examine page about a dozen times by now but, please correct me if I'm wrong, it seems a little over the top for my purpose.
Can anybody help me out?
Thanks
Hi,
Backoffice search will only search based on name (node name), so no, ootb, the search won't help you, even if you've added those fields to the index.
But, there's always an extension point, albeit not that straightforward.
Basically, you'll have to intercept the current api call and replace it with your own api call. As long as you return the same return value, you'd only need to intercept the call and use your own. I'll see if I can dig up that intercept example.
--Dirk
Hi,
Here it goes:
Only thing left is to create a
XApiController
, with aSearchAll(string query)
function and perform your advanced Examine query to fetch the resultsHere's what umbraco does when performing the search: https://github.com/umbraco/Umbraco-CMS/blob/b260f6c6dedc6c8c123de5f2348b4d7f0dcb51bd/src/Umbraco.Web/Editors/EntityController.cs#L97
The idea is to return
IEnumerable<EntityTypeSearchResult>
from your own method and it should work.--Dirk
Thank you very much for your approach. I will give it a try.
is working on a reply...