Translation Memory - delete units by source text and translation text

Hello

I want to delete unit in my translation memory by sourceText and Translation text but I have no idea how to use delete endpoint:

/api/tmservice/tms/{tmId}/tus/{source}/{target}

Can I get example expression to delete Unit by sourceText and translation text

Thx for help

  • Hi Adam,

    You can use the following endpoint to delete translation units with a filter:
    example:
    Method: Delete
    url: /api/tmservice/tms/{tmId}/tus/{source}/{target}?startTuId=0&count=100
    Body:
    {
    "fields": [
    {
    "name": "src",
    "type": "SingleString",
    "values":null
    }
    ],
    "expression": "\"src\" @ \"your source text\""
    }

    for Target text you can use "trg" instead of "src"

    Operators for filtering: = , > , <, >= , <= , != , @ (contains) , !@ (does not contain), ~ (matches), !~ (does not match)

    Suggestion :
    You can test the filter expression before the delete using the filter translation units endpoint :
    Method: Post
    url: /api/tmservice/tms/{tmId}/tus/filter?source=en-gb&target=de-de&startTuId=0&count=100
    Body:
    {
    "fields": [
    {
    "name": "src",
    "type": "SingleString",
    "values":null
    }
    ],
    "expression": "\"src\" @ \"your source text\""
    }

    Change the parameters according to your TM details.

    If you need extra information for filtering let me know.

    Thanks

  • /api/tmservice/tms/061117a7-4f93-41cd-a61c-0db3d75ebe94/tus/filter?source=de-de&target=af-za&startTuId=0&count=100

    {
    "fields": [
    {
    "name": "src",
    "type": "SingleString",
    "values":null
    },
    {
    "name": "trg",
    "type": "SingleString",
    "values":null
    }
    ],
    "expression": "((\"src\"=\"string\") & (\"trg\"=\"string\"))"
    }

    resposne

    {
    "ErrorCode": "CoreError",
    "Message": "Error: System - The data types ntext and varchar are incompatible in the equal to operator. (details: System.Data.SqlClient.SqlException (0x80131904): The data types ntext and varchar are incompatible in the equal to operator.\r\n at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n at System.Data.SqlClient.SqlDataReader.TrySetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)\r\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\r\n at System.Data.SqlClient.SqlDataReader.get_MetaData()\r\n at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\r\n at Sdl.LanguagePlatform.TranslationMemoryImpl.Storage.DbStorage.GetTUsWithAttributesAndContexts(DbCommand retrievalCmd, Boolean returnIdContext, Boolean returnContext, Dictionary`2 attributes, CultureInfo sourceCulture, CultureInfo targetCulture, Boolean cmIsPrecedingFollowing)\r\n at Sdl.LanguagePlatform.TranslationMemoryImpl.Storage.SqlStorage.GetTusFiltered(Int32 tmId, FilterExpression filter, Int32 startAfter, Int32 count, Boolean forward, Boolean idContextMatch, Boolean includeContextContent, TextContextMatchType textContextMatchType, CultureInfo sourceCulture, CultureInfo targetCulture)\r\n at Sdl.LanguagePlatform.TranslationMemoryImpl.TranslationUnitServerFilteringStrategy.Sdl.LanguagePlatform.TranslationMemoryImpl.ITranslationUnitFilteringStrategy.GetTusFiltered(PersistentObjectToken translationMemoryId, RegularIterator iter, FieldDefinitions fieldDefinitions, Boolean includeContextContent, TextContextMatchType textContextMatchType, CultureInfo sourceCulture, CultureInfo targetCulture, Boolean usesIdContextMatch)\r\n at Sdl.LanguagePlatform.TranslationMemoryImpl.ResourceManager.GetTranslationUnits(PersistentObjectToken tmId, RegularIterator iter, Boolean skipOptimize)\r\n at Sdl.LanguagePlatform.TranslationMemoryImpl.API.GetTranslationUnits(Container container, PersistentObjectToken tmId, RegularIterator& iter)\r\nClientConnectionId:08665320-4453-4efe-aadc-22d89a332995\r\nError Number:402,State:1,Class:16)"
    }

  • This was addressed as an issue in TMService in ".../tus/filter" endpoint, it was fixed and will be available with future releases.

    The issue is not reproducing for the 'delete' endpoint.

    Thank you!