Copied to clipboard

Flag this post as spam?

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


  • Alan Kurdmark 8 posts 99 karma points
    Sep 26, 2022 @ 06:39
    Alan Kurdmark
    0

    Searching for ExternalIndex result

    Hello,

    I was wondering if there is a way to search for the ExternalIndex result when implementing a search function. The list result here is what I want to get when searching

    When I implement search I just get the fields of the results instead. This is what I get instead

  • Per Bolmstedt 84 posts 380 karma points
    Sep 28, 2022 @ 11:04
    Per Bolmstedt
    100

    This is not only possible, but pretty standard.

            if (!examineManager.TryGetIndex("ExternalIndex", out var index))
            {
                // ...
            }
            var searcher = index.Searcher;
            var query = searcher.CreateQuery("content"); 
            var currentCulture = CurrentThread.CurrentCulture.Name.ToLower();
            var searchFields = "pagetitle_{0},[...]";
            var terms = query.GroupedOr(string.Format(searchFields, currentCulture).Split(','), searchTerm);
            terms.Execute();
    

    Please note that the External Index only contains nodes that are published to all languages. There is some reasoning behind this that I don't fully follow. And it can probably be remedied by configuring the indexer.

  • Alan Kurdmark 8 posts 99 karma points
    Sep 28, 2022 @ 11:17
    Alan Kurdmark
    0

    Thanks a lot for the answer!

    I had one other question if you wouldn't mind. Is there a way to implement a XOR query with Examine or is it only possible through raw Lucene?

  • Per Bolmstedt 84 posts 380 karma points
    Sep 28, 2022 @ 11:27
    Per Bolmstedt
    1

    I believe so, using GroupedOr or GroupedAnd. But the documentation is spotty (to say the least), so I recommend some exploring. Examine is a third-party (nominally, at least) search library on top of Lucene, so usually a combination of Umbraco docs + Examine docs + Lucene docs is necessary.

  • Alan Kurdmark 8 posts 99 karma points
    Sep 29, 2022 @ 07:25
    Alan Kurdmark
    1

    That worked like a charm! The documentation was a bit spotty but with some testing it did the job. Thank you so much!

Please Sign in or register to post replies

Write your reply to:

Draft