Copied to clipboard

Flag this post as spam?

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


  • Maff 141 posts 465 karma points
    Feb 08, 2021 @ 15:32
    Maff
    0

    Problem using GroupedNot to exclude fields in Examine

    Hi,

    I'm trying to exclude node Ids from an Examine search using the following code:

    if (!ExamineManager.Instance.TryGetIndex(indexName, out IIndex index)) throw new Exception("Error");
    
    ISearcher searcher = index.GetSearcher();
    
    LuceneSearchQuery criteria = (LuceneSearchQuery)searcher.CreateQuery();
    
    criteria.Field("__NodeTypeAlias", field);
    
    criteria.Field("articleTags", fieldValue);
    
    criteria.GroupedNot(new List<string> {"nodeId", "id", "__NodeId"}, excludedNodeIds.ToArray());
    

    My query looks like this before executing:

    {+__NodeTypeAlias:newsarticle +articleTags:"athlete rights" (-id:1203 -__NodeId:1203)}
    

    Which looks ok to me, but the document with that nodeId is still being returned in the query results.

    I've tried adding the Node Id as a custom field "nodeId" to the Examine index, transforming the node Id to a string and an integer, but still nothing.

    Has anyone been able to do this, or is there an easier way of excluding node Ids from the query?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft