Be aware that recent versions of Umbraco keep a writelock open on the index for performance reasons. This means that the index cannot be read by other processes unless you touch the web.config.
You could expose the Umbraco examine index data via webapi and in that webapi some querying. Then your non umbraco site can make calls to webapi in site a and get any data you require.
See https://our.umbraco.org/documentation/Reference/WebApi/ then in your method you would add the querying code and take in some search parameters for the data you want. I would suggest you send back your own poco type list of the data rather than ISearchResult.
private ApiSearchResponse SearchTalent(ModelSearch searchParams, string talentGenderAlias)
{
var criteria = SearchHelper.GetSearchDictionary(searchParams.ToDictionary(), talentGenderAlias);
SetPublicFilter(criteria);
//try
//{
string generatedQuery;
var talents = _boardService.SearchTalent(criteria, out generatedQuery);
var searchResponse = new ApiSearchResponse();
searchResponse.ResultCount = talents.Items.Count;
searchResponse.Board = talents;
searchResponse.GeneratedQuery = generatedQuery;
searchResponse.Success = true;
SanitizeSearchQuery(searchResponse);
return searchResponse;
}
The board service has some code that looks like
var externalCriteria = _externalSearcher.CreateSearchCriteria(IndexTypes.Content);
IBooleanOperation query = externalCriteria.OrderBy(Constants.DocTypesProperties.Talent.FirstName);
if (searchFields.ContainsKey(Constants.Examine.NodeTypeAlias))
{
query = externalCriteria.NodeTypeAlias(fields[Constants.Examine.NodeTypeAlias]);
fields.Remove(Constants.Examine.NodeTypeAlias); //dont want the nodetypealias twice in search query
}
ExamineHelper.BuildRangeQuery(query, fields);
generatedQuery = externalCriteria.ToString(); //just here for debugging purposes
var results = _externalSearcher.Search(query.Compile());
return results;
Basically there are 2 pieces to this puzzle the first bit is the webapi, look at the docs and just create simple webapi that returns some mock list of objects. Next create your search class using examine see the docs and perform search and return results.
Reading Examine Index from a separate VS Project
I've got a Visual Studio (VS) solution with two VS Project (Project A comes with the Umbraco site and Project B is a just a normal MVC site.
Was wondering if there's a way I can read the the Examine Index (that will be available in Project A) within Project B?
Might need something that read the index with a directory.
Appreciate any help
Thanks
Hi JLon,
In Umbraco project we have config folder, in this folder ExamineIndex.config file. There are you can change folder of index files.
More info:
https://our.umbraco.org/Documentation/Reference/Searching/Examine/full-configuration
Thanks, Alex
Be aware that recent versions of Umbraco keep a writelock open on the index for performance reasons. This means that the index cannot be read by other processes unless you touch the web.config.
Kindly see http://issues.umbraco.org/issue/U4-6321 for an explanation.
Regards
Ver
Jlon,
You could expose the Umbraco examine index data via webapi and in that webapi some querying. Then your non umbraco site can make calls to webapi in site a and get any data you require.
Regards
Ismail
Hi Ismail,
Looking for the same thing too. Any idea how do you do that?
Thanks
Jeric,
See https://our.umbraco.org/documentation/Reference/WebApi/ then in your method you would add the querying code and take in some search parameters for the data you want. I would suggest you send back your own poco type list of the data rather than ISearchResult.
Regards
Ismail
Ismail,
Any sample codes? kind of confuse a little
Thanks
Read the first link i sent regarding how to create webapi https://our.umbraco.org/documentation/Reference/WebApi/ with umbraco then read examine docs see https://our.umbraco.org/Documentation/Reference/Searching/Examine/index which details how you query. I have some code not included all of it but
Web api bit
The board service has some code that looks like
Basically there are 2 pieces to this puzzle the first bit is the webapi, look at the docs and just create simple webapi that returns some mock list of objects. Next create your search class using examine see the docs and perform search and return results.
Regards
Ismail
Thanks Ismail, will try it out
Cheers
is working on a reply...