Copied to clipboard

Flag this post as spam?

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


  • Max 80 posts 437 karma points
    Aug 03, 2017 @ 13:20
    Max
    0

    EntityResource.search -- query argument and searchfrom argument

    The following documentation from the code base umbraco.resources.js is not exactly complete and maybe incorrect or in need of a revision.

    Does anyone have a working example or improved documentation on usage... I had this working previously looking up a specific subset of media items for a custom property editor..and now after a recent core update it does not seem to work... I am trying to debug it to determine if its an Examine issue, data structure issue, or umbraco resource issue.

    /**
             * @ngdoc method
             * @name umbraco.resources.entityResource#search
             * @methodOf umbraco.resources.entityResource
             *
             * @description
             * Gets an array of entities, given a lucene query and a type
             *
             * ##usage
             * <pre>
             * entityResource.search("news", "Media")
             *    .then(function(mediaArray) {
             *        var myDoc = mediaArray; 
             *        alert('they are here!');
             *    });
             * </pre> 
             * 
             * @param {String} Query search query 
             * @param {String} Type type of conten to search        
             * @returns {Promise} resourcePromise object containing the entity array.
             *
             */
            search: function (query, type, searchFrom, canceler) {....
    

    The example of my code that used to work:

    var searchFrom = { metaData: { contentType: "folder" } };
    
    $q.all({
    getfolder: entityResource.search("features", "Media", searchFrom)
                            .then(function (result) {
                            if (result.length > 0) {
                                return result[0].id;
                            }
    
                            return null;
                        }),
    ...}).then(function(results){ ....});
    

    Error message:

    " ↵ ↵Mapping types: ↵IEnumerable1 -> IEnumerable1 ↵System.Collections.Generic.IEnumerable1[[Examine.SearchResult, Examine, Version=0.1.84.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.IEnumerable1[[Umbraco.Web.Models.ContentEditing.EntityBasic, umbraco, Version=1.0.6396.36631, Culture=neutral, PublicKeyToken=null]] ↵ ↵Destination path: ↵IEnumerable1 ↵ ↵Source value: ↵Examine.LuceneEngine.SearchResults+<Skip>d__26" ExceptionType : "AutoMapper.AutoMapperMappingException" InnerException : {Message: "An error has occurred.",…} ExceptionMessage : "Object reference not set to an instance of an object." ExceptionType : "System.NullReferenceException" Message : "An error has occurred." StackTrace : " at Examine.OrderedDictionary2.System.Collections.Generic.IDictionary

    When I changed the search method to:

    entityResource.getAll("Media", searchFrom);

    I get the error response 500:

    )]}', {Message: "An error has occurred.", ExceptionMessage: "Expression expected",…} ExceptionMessage : "Expression expected" ExceptionType : "Umbraco.Core.Dynamics.ParseException" Message : "An error has occurred." StackTrace : " at Umbraco.Web.Dynamics.ExpressionParser1.ParsePrimaryStart() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParsePrimary() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseUnary() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseMultiplicative() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseAdditive() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseComparison() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseLogicalAnd() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseLogicalOr() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.ParseExpression() ↵ at Umbraco.Web.Dynamics.ExpressionParser1.Parse(Type resultType) ↵ at Umbraco.Web.Dynamics.DynamicExpression.ParseLambda[T](ParameterExpression[] parameters, Type resultType, String expression, Boolean convertDynamicNullToBooleanFalse, Object[] values) ↵ at Umbraco.Web.Dynamics.DynamicQueryable.Where[T](IQueryable source, String predicate, Object[] values) ↵ at Umbraco.Web.Dynamics.DynamicQueryable.Where[T](IQueryable1 source, String predicate, Object[] values) ↵ at Umbraco.Web.Editors.EntityController.ExecutePostFilter[T](IEnumerable1 entities, String postFilter, IDictionary2 postFilterParams) ↵ at Umbraco.Web.Editors.EntityController.GetResultForAll(UmbracoEntityTypes entityType, String postFilter, IDictionary2 postFilterParams) ↵ at lambda_method(Closure , Object , Object[] ) ↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass10.9(Object instance, Object[] methodParameters) ↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) ↵--- End of stack trace from previous location where exception was thrown --- ↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() ↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ↵ at System.Web.Http.Controllers.ApiControllerActionInvoker.

Please Sign in or register to post replies

Write your reply to:

Draft