Copied to clipboard

Flag this post as spam?

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


  • Damion 90 posts 324 karma points
    Apr 23, 2020 @ 11:51
    Damion
    0

    Hi,

    Im trying to use Umbraco.ContentQuery in a controller to search for content by name but nothing is returned, is what I have below still valid?

    var v = Umbraco.ContentQuery.Search("my content name", string.Empty); thanks

  • Joep 95 posts 695 karma points
    Apr 23, 2020 @ 15:19
    Joep
    0

    Hi,

    Is there a reason why you give a Empty string as the culture? If not, try doing the search without the string.Empty. var v = Umbraco.ContentQuery.Search("my content name");

    -Joep

  • Harikrishna Parmar 31 posts 207 karma points c-trib
    Apr 23, 2020 @ 15:48
    Harikrishna Parmar
    0

    Hello Damio,

    I umbraco v8, you should try this.

    The syntax you are using is

    var easySearch = Umbraco.ContentQuery.Search("Products", "ExternalIndex");
    

    Which means you are passing in the string "ExternalIndex" to the culture parameter.

    Your options are to change your method call to one of these:

    var easySearch = Umbraco.ContentQuery.Search("Products"); - which by default will query the ExternalIndex

    var easySearch = Umbraco.ContentQuery.Search("Products", indexName: "ExternalIndex"); - to explicitly pass the string "Externalndex" to the right parameter

    var easySearch = Umbraco.ContentQuery.Search("Products", null, "ExternalIndex"); - to pass all parameter values in the correct order

    https://github.com/umbraco/Umbraco-CMS/issues/5789

Please Sign in or register to post replies

Write your reply to:

Draft