anchor.diff:              // Map each document to a TargetRecord
               header.TargetRecords <- docs.Documents
                                       |> Seq.filter (fun r -> r.[Constants.IdField] <> header.SourceRecordId)
  +                                    |> Seq.filter (fun r -> 
  +                                        // If duplicate detection is used with DistinctBy then do a second pass filtering to ensure
  +                                        // that the source record is not picked up. This can happen when source record is not the 
  +                                        // best match for the search profile
  +                                        if isNotBlank profileQuery.DistinctBy then
  +                                            r.[profileQuery.DistinctBy] <> record.[profileQuery.DistinctBy]
  +                                        else true
  +                                    )
                                       |> Seq.mapi 
                                              (fun i result -> 
                                              new TargetRecord(TargetId = i + 1, 
  
positive.code:             match indexService.IsIndexOnline(indexName) with
              | Ok(writer) -> 
                  match writer.Settings.SearchProfiles.TryGetValue(body.ProfileName) with
                  | true, _ -> 
                      let jobId = Guid.NewGuid()
                      requestProcessor.Post(jobId, writer, body)
                      return jobId
                  | _ -> return! fail <| UnknownSearchProfile(indexName, body.ProfileName)
              | Fail(error) -> return! fail error
  
negative.code:             | Ok(_) -> ()
              | Fail(error) -> Logger.Log error
      
      let duplicateRecordCheck (req : DuplicateDetectionRequest, record : Dictionary<string, string>, session : Session, profileQuery : SearchQuery) = 
          let query = 
              new SearchQuery(session.IndexName, String.Empty, SearchProfile = session.ProfileName, 
                              Columns = [| session.DisplayFieldName |], ReturnFlatResult = true, ReturnScore = true)
  