Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jay 425 posts 652 karma points
    May 10, 2015 @ 21:25
    Jay
    0

    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

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    May 10, 2015 @ 22:50
    Alex Skrypnyk
    0

    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

  • Veronica Burd 76 posts 201 karma points
    May 11, 2015 @ 08:19
    Veronica Burd
    0

    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

     

     

     

     

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 11, 2015 @ 10:19
    Ismail Mayat
    0

    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

  • Jeric 122 posts 192 karma points
    May 11, 2015 @ 10:55
    Jeric
    0

    Hi Ismail,

    Looking for the same thing too. Any idea how do you do that?

    Thanks

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 11, 2015 @ 11:33
    Ismail Mayat
    0

    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

     

     

  • Jay 425 posts 652 karma points
    May 11, 2015 @ 21:22
    Jay
    0

    Ismail,

    Any sample codes? kind of confuse a little

    Thanks

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 12, 2015 @ 10:30
    Ismail Mayat
    0

    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

            [HttpGet]
            public ApiSearchResponse SearchMaleTalent([FromUri] ModelSearch searchParams)
            {
                return SearchTalent(searchParams, Constants.MediaTypes.TalentMale);
            }
    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.  

    Regards

    Ismail

  • Jeric 122 posts 192 karma points
    May 12, 2015 @ 23:03
    Jeric
    0

    Thanks Ismail, will try it out

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft