Copied to clipboard

Flag this post as spam?

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


  • Thobias Michel 18 posts 99 karma points
    Mar 23, 2019 @ 11:27
    Thobias Michel
    0

    Searching not working with ContentQuery.Search

    Hi @all,

    i tried to create a search result page and display searchresults. Regarding to the Examine settings page and the result i get on "ExternalIndex" i am expecting to get the same on my search result page.

    My code:

    @if (!string.IsNullOrEmpty(Request.QueryString["query"]))
    {
        <div>Query: @(Request.QueryString["query"])</div>
        {
            var results = Umbraco.ContentQuery.Search(Request.QueryString["query"], 0, 10, out var amount);
    
            <div>amount: @amount</div>
            <ul>
                @foreach (var result in results)
                {
                    <li>
                        <a href="@result.Content.Url">@result.Content.Name</a>
                    </li>
                }
            </ul>
        }
    }
    

    I tried a lot of different parameters, but no results found. Is there any documentation? Or maybe a simple failure on my side?

    Best Thobias

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Mar 23, 2019 @ 13:01
    Alex Skrypnyk
    0

    Hi

    Can you check that Examine works as expected in your project? Can you go to the developers section - Examine management and test queries there. Also, try to rebuild indexes.

    Did you set field aliases in ExamineIndex.config that you are searching for?

    Read more about Examine - https://our.umbraco.com/documentation/Reference/Config/ExamineIndex/

    Thanks,

    Alex

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Mar 23, 2019 @ 14:02
    Sebastiaan Janssen
    101

    Try to provide an empty string for the culture in your Search:

    Umbraco.ContentQuery.Search("test", 0, 10, out var amount, string.Empty);

  • Thobias Michel 18 posts 99 karma points
    Mar 24, 2019 @ 12:05
    Thobias Michel
    0

    Thank you so much! Its working now

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies