Copied to clipboard

Flag this post as spam?

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


  • David Armitage 510 posts 2082 karma points
    Apr 14, 2023 @ 09:52
    David Armitage
    0

    Umbraco 11| Examine Exact Phrase Term Search

    Hi,

    I am really struggling to get an exact phase (2 words) to work against a plain text field.

    So I have 3 pages. I am searching against a field called metaDescription (Text Area).

    I am using the external index and I can see the 3 pages are indexed. Just the default that Umbraco does. Nothing custom abaout this. I can see the field data is indexed as expected through the Umbraco Examine backend

    Page 1: metaData = Test Page

    Page 2: metaData = Test Page

    Page 3: metaData = Page

    When I am searching the phrase "Test Page" all 3 pages come back every time. No matter what I try it always seems to be doing a multi word search.

    I have tried each of the following plus a load of variations along the way... They all return the exact same data - all 3 pages.

    var searcher = index.Searcher;
    var criteria = searcher.CreateQuery(IndexTypes.Content, BooleanOperation.And);
    var examineQuery = criteria.NodeTypeAlias(ContentPage.ModelTypeAlias);
    

    /

    examineQuery.And().Field("metaDescription", "Test Page");
    
    examineQuery.And().Field("metaDescription", "\"Test Page\"");
    
    examineQuery.And().Field("metaDescription", "\"^Test Page$\"");
    

    I also tried a few examples from other posts. Like this for example. https://our.umbraco.com/forum/using-umbraco-and-getting-started/80250-searching-for-phrases-using-examine

    examineQuery.And().Field("metaDescription", new ExactPhraseExamineValue("Test Page".ToLower()));
    

    This returned no results.

    Is there a bug with Umbraco 11 getting exact term searching to work. I dont remember having these problems with Umbraco 7 and 8. I have tied for most of the day with this one.

    I am sure with the older versions this just worked out of the box.

    examineQuery.And().Field("metaDescription", "Test Page");
    

    And if you wanted to split the words then you did exactly that and passed in the array.

    I know I could create a custom index and stip out the space between the indexed words. This wont really work through since I am trying to index a block of text rather than something short like the node name. I would prefer not to fiddle with how the content is indexed.

    Any help would be much appreciated.

    Thanks in advanced.

  • David Armitage 510 posts 2082 karma points
    May 11, 2023 @ 05:53
    David Armitage
    0

    Anyone any ideas on this? Do we know if its a bug.

    I want to avoid changing my code to use a raw lucene query which is starting to look like might be the best option.

  • Sarah Giblett 1 post 73 karma points
    Oct 18, 2023 @ 17:13
    Sarah Giblett
    1

    I've also been having this issue. I tried this which didn't work

    examineQuery.And().Field("metaDescription", "Test Page".Escape());
    

    What did work for me was

    examineQuery.And().NativeQuery("+metaDescription:\"^Test Page$\"");
    
  • 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