Filter problem with the SDL Trados Translation Memory API

Hi, at the moment I have a problem with the SDL Trados Translation Memory API 3.0. I have developed an easy search test program on basis of the API documentation and the chapter “Run a Filtered Search”.

The search result of my test program is fine without a filter. If I implement a filter then the search result is not correct. The search result is the same as without a filter. I think that the filter functionality does not work correctly in my program but I cannot find an error in my program code.

I have tested the filter functionality via the SDL Trados Studio with the same settings and this filter works fine.

I get only one data record! This result is correct because the system contains two records with the search word "Telefonliste" but only a record of these two data records also contains the condition "Auftragsnummer = 2014U-123".  

Now follows the source code:

using System;

using System.Web.UI;

using Sdl.LanguagePlatform.TranslationMemoryApi;

using Sdl.LanguagePlatform.TranslationMemory;

using Euroscript.WebConcordance.Searchclasses;

using System.Collections.Generic;

namespace Euroscript.WebConcordance

{

    public partial class Search : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            Connector connection = new Connector();

            connection.ConnectTMServer("http://devs-sdl-db:90", "xyz", "abc");

            ServerBasedTranslationMemory tm = connection.tmServer.GetTranslationMemory("/TestTMWebConcordance", TranslationMemoryProperties.Fields);

            ServerBasedTranslationMemoryLanguageDirection langDirection = tm.LanguageDirections.GetLanguageDirection("de-DE", "en-GB");

            SearchSettings sdlSearchSettings = new SearchSettings();

            sdlSearchSettings.Mode = SearchMode.ConcordanceSearch;

            sdlSearchSettings.MinScore = 70;

            sdlSearchSettings.MaxResults = 20;

            sdlSearchSettings.FindPenalty(PenaltyType.FilterPenalty);

            SingleStringFieldValue orderNo = new SingleStringFieldValue("Auftragsnummer");

            orderNo.Value = "2014U-123";

            AtomicExpression orderNoExpression = new AtomicExpression(orderNo, AtomicExpression.Operator.Equal);

            Filter filter = new Filter(orderNoExpression, "testfilder", 0);

            sdlSearchSettings.AddFilter(filter);

            string hitList = "Filter: " + filter.FilterExpression.ToString() + "\n\n";

            SearchResults results = langDirection.SearchText(sdlSearchSettings, "Telefonliste");

            hitList += "Number of hits found: " + results.Count.ToString() + "\n";

            foreach (SearchResult result in results)

            {

                hitList += "\n" + "Source segment: " + result.MemoryTranslationUnit.SourceSegment.ToPlain() + "\n";

                hitList += "Target segment: " + result.MemoryTranslationUnit.TargetSegment.ToPlain() + "\n";

                hitList += "Created on: " + result.MemoryTranslationUnit.SystemFields.CreationDate.ToString() + "\n";

                hitList += "Origin: " + result.MemoryTranslationUnit.Origin.ToString() + "\n";

                hitList += "Match value: " + result.ScoringResult.Match.ToString() + "\n";

                hitList += "Fields:" + "\n";

                foreach (FieldValue field in result.MemoryTranslationUnit.FieldValues)

                {

                    hitList += field.Name + ": " + field.ToString() + "\n";

                }

            }

        }

    }

}

The search result via SDL API program code is not correct, because I get two data records. The second data set is wrong because it contains the entry “Auftragsnummer = 2014U-123” and this is consequently not a correct result for my search with a filter.

I work with the following software:

- Windows 7 Professional SP1

- SDL Trados Studio 2014 SP2 – 11.2.4364.8

- MS Visual Studio Ultimate 2013 Version 12.0.31101.00 Update 4

- MS .NET Framework Version 4.5.51209

- MS Visual C# 2013   06181-004-0449004-02497

Thanks a lot in advance for your support and feedback.

Best regards,

Christian Albrecht