> ## Documentation Index
> Fetch the complete documentation index at: https://developers.phrase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search TM content

> 
Search TM content within a single Translation Memory (TM) with metadata filters.

Interpreting found results
* Searching a TARGET locale → response contains the matching target TUV + the source TUV for that TU.
* Searching a SOURCE locale → response contains the full TU (matching source TUV + all target TUVs).
 One TU counts as a single found item, but the UI should render N <srcTUV, targetTUV> pairs.

Query modes
1) Exact query (plain text without wildcard markers and not regex mode)
   * If `sourceOperator|targetOperator: IS|IS_NOT` (exact mode) → the whole field must (not) match exactly.
   * If `sourceOperator|targetOperator: CONTAINS|DOES_NOT_CONTAIN` (contains mode) → the text may appear anywhere within the field.

2) Wildcard query (`sourceUseRegex|targetUseRegex: false`)
   * Uses '?' (single character) and '*' (multi-character) placeholders.
   * IMPORTANT: '\*' is only supported as a terminal suffix (end of word/token).
     Example: 'trans*' matches 'translation', 'transfer'; 'tr?nslate' matches 'translate'/'trenslate'.

3) Regex query (`sourceUseRegex|targetUseRegex: true`)
   * REGEXP searches for substrings (not whole-word by default).
   * Elasticsearch 8.14.3 / Lucene 9.10 supports \w, \W, \d, \D, \s, \S; word boundaries \b/\B are NOT supported.
     Prefer WILDCARD for word-based matching.

Metadata filters (`filters`)
* You can provide multiple metadata filters (projects, domain, subdomains, ...) - AND logic is applied.

Defaults & limitations
* Whitespace is normalized; WILDCARD processor can filter out Phrase tags.
* Post-filtering: even WILDCARD results are validated to enforce correct word order.
* The single query might be capped at certain limit (currently 10k results)

Execution & performance notes
* REGEXP uses non-analyzed normalized fields; additional post-validation ensures fidelity to the original query text.
* Matching TUVs are collected until `batchSize` is reached; only then are sibling TUVs from the same TU loaded.
* For pagination (changing `index`), ES results are re-processed to keep `totalElements` accurate.




## OpenAPI

````yaml /openapi/phrase-tms-latest.json post /api2/v1/transMemories/{transMemoryUid}/searchContent
openapi: 3.0.0
info:
  description: |-
    Welcome to Phrase's TMS API documentation. 

     Please visit our [help center](https://support.phrase.com/hc/en-us/sections/5709662083612) for more information about the APIs. 

     If you have any questions, please contact [Support](https://support.phrase.com/hc/requests/new). 

     Please, include the `User-Agent` header with the name of your application or project. It might be a good idea to include some sort of contact information as well, so that we can get in touch if necessary. Examples of excellent `User-Agent` headers:
     > User-Agent: Example mobile app (example@phrase.com) <br/> User-Agent: ACME Inc Java 1.8 Client (http://acmeinc.com/contact)
  version: Latest
  title: Phrase TMS API
servers:
  - url: https://cloud.memsource.com/web
security:
  - ApiToken: []
  - OAuth2: []
tags:
  - name: Additional Workflow Step
  - name: Analysis
  - name: Async Request
  - name: Authentication
  - name: Automations
  - name: Bilingual File
  - name: Business Unit
  - name: Buyer
  - name: Client
  - name: Connector
  - name: Conversations
  - name: Cost Center
  - name: Custom Fields
  - name: Custom File Type
  - name: Domain
  - name: Due Date Scheme
  - name: Email Template
  - name: File
  - name: Glossary
  - name: Import settings
  - name: Job
  - name: Language AI
  - name: Language Assets
  - name: Language Quality Assessment
  - name: Machine Translation
  - name: Machine Translation Settings
  - name: Mapping
  - name: Net Rate Scheme
  - name: Notifications
  - name: Price List
  - name: Project
  - name: Project Template
  - name: Provider
  - name: Quality Assurance
  - name: Quality Profile
  - name: Quote
  - name: Reference File
  - name: SCIM
  - name: Segment
  - name: Segmentation Rules
  - name: Service
  - name: Spell Check
  - name: SubDomain
  - name: Supported Languages
  - name: Term Base
  - name: Translation
  - name: Translation Memory
  - name: User
  - name: Vendor
  - name: Webhook
  - name: Workflow Step
  - name: Workflow changes
  - name: XML Assistant
paths:
  /api2/v1/transMemories/{transMemoryUid}/searchContent:
    post:
      tags:
        - Translation Memory
      summary: Search TM content
      description: >

        Search TM content within a single Translation Memory (TM) with metadata
        filters.


        Interpreting found results

        * Searching a TARGET locale → response contains the matching target TUV
        + the source TUV for that TU.

        * Searching a SOURCE locale → response contains the full TU (matching
        source TUV + all target TUVs).
         One TU counts as a single found item, but the UI should render N <srcTUV, targetTUV> pairs.

        Query modes

        1) Exact query (plain text without wildcard markers and not regex mode)
           * If `sourceOperator|targetOperator: IS|IS_NOT` (exact mode) → the whole field must (not) match exactly.
           * If `sourceOperator|targetOperator: CONTAINS|DOES_NOT_CONTAIN` (contains mode) → the text may appear anywhere within the field.

        2) Wildcard query (`sourceUseRegex|targetUseRegex: false`)
           * Uses '?' (single character) and '*' (multi-character) placeholders.
           * IMPORTANT: '\*' is only supported as a terminal suffix (end of word/token).
             Example: 'trans*' matches 'translation', 'transfer'; 'tr?nslate' matches 'translate'/'trenslate'.

        3) Regex query (`sourceUseRegex|targetUseRegex: true`)
           * REGEXP searches for substrings (not whole-word by default).
           * Elasticsearch 8.14.3 / Lucene 9.10 supports \w, \W, \d, \D, \s, \S; word boundaries \b/\B are NOT supported.
             Prefer WILDCARD for word-based matching.

        Metadata filters (`filters`)

        * You can provide multiple metadata filters (projects, domain,
        subdomains, ...) - AND logic is applied.


        Defaults & limitations

        * Whitespace is normalized; WILDCARD processor can filter out Phrase
        tags.

        * Post-filtering: even WILDCARD results are validated to enforce correct
        word order.

        * The single query might be capped at certain limit (currently 10k
        results)


        Execution & performance notes

        * REGEXP uses non-analyzed normalized fields; additional post-validation
        ensures fidelity to the original query text.

        * Matching TUVs are collected until `batchSize` is reached; only then
        are sibling TUVs from the same TU loaded.

        * For pagination (changing `index`), ES results are re-processed to keep
        `totalElements` accurate.
      operationId: searchContent
      parameters:
        - name: transMemoryUid
          in: path
          required: true
          schema:
            type: string
        - name: index
          in: query
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
            default: 0
        - name: batchSize
          in: query
          description: Batch size, accepts values between 1 and 100, default 50
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
            maximum: 100
            default: 50
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchTmContentRequestDtoV1'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchDtoSearchTmContentResponseDtoV1'
        '400':
          description: Bad request
        '401':
          description: Not authorized
        '403':
          description: Forbidden
        '404':
          description: Resource not found
        '405':
          description: Method not allowed
        '408':
          description: Timeout
        '410':
          description: Gone
        '415':
          description: Unsupported media type
        '429':
          description: Too many requests
        '500':
          description: Internal server error
        '501':
          description: Not implemented
components:
  schemas:
    SearchTmContentRequestDtoV1:
      type: object
      properties:
        filters:
          type: array
          description: >-
            Filter for related metadata (e.g. project, client, ...). It's
            possible to provide multiple filter criteria of same type (AND logic
            applied)
          items:
            $ref: '#/components/schemas/SearchTmContentFilterDtoV1'
        sourceMatchCase:
          type: boolean
          description: If `true`, `sourceQuery` will be considered case-sensitive
        sourceOperator:
          type: string
          description: 'Matching operator for `sourceQuery`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - CONTAINS
            - DOES_NOT_CONTAIN
        sourceQuery:
          type: string
          description: >-
            Query string for source part of segment. Provide either
            `sourceQuery` or `targetQuery` (not both)
        sourceUseRegex:
          type: boolean
          description: If `true`, `sourceQuery` will be considered to be regular expression
        targetLangs:
          type: array
          description: >-
            Target languages/locales of the given TM to search in. Example:
            `en_us`
          items:
            type: string
        targetMatchCase:
          type: boolean
          description: If `true`, `targetQuery` will be considered case-sensitive
        targetOperator:
          type: string
          description: 'Matching operator for `targetQuery`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - CONTAINS
            - DOES_NOT_CONTAIN
        targetQuery:
          type: string
          description: >-
            Query string for target part of segment. Provide either
            `sourceQuery` or `targetQuery` (not both)
        targetUseRegex:
          type: boolean
          description: If `true`, `targetQuery` will be considered to be regular expression
        tuId:
          type: string
          description: ID of the translation unit
    BatchDtoSearchTmContentResponseDtoV1:
      type: object
      properties:
        batchSize:
          type: integer
          format: int32
        content:
          type: array
          items:
            $ref: '#/components/schemas/SearchTmContentResponseDtoV1'
        currentIndex:
          type: integer
          format: int32
        hasMore:
          type: boolean
        totalElements:
          type: integer
          format: int32
    SearchTmContentFilterDtoV1:
      type: object
      properties:
        clients:
          type: array
          description: Clients
          items:
            $ref: '#/components/schemas/UidReference'
        clientsOperator:
          type: string
          description: 'Matching operator for `clients`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
        createdByUsers:
          type: array
          items:
            $ref: '#/components/schemas/UidReference'
        createdByUsersOperator:
          type: string
          description: 'Matching operator for `createdByUsers`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
        createdFrom:
          type: string
          format: date-time
          description: >-
            Use ISO8601 date and time format (e.g. `2025-11-03T14:42:59Z`).
            Leave empty if searching for "is before", provide both from/to if
            searching "is" or "is within"
        createdTo:
          type: string
          format: date-time
          description: >-
            Use ISO8601 date and time format (e.g. `2025-11-03T14:42:59Z`).
            Leave empty if searching for "is after", provide both from/to if
            searching "is" or "is within"
        domains:
          type: array
          description: Domains
          items:
            $ref: '#/components/schemas/UidReference'
        domainsOperator:
          type: string
          description: 'Matching operator for `domains`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
        filename:
          type: string
          description: Original file
        filenameOperator:
          type: string
          description: 'Matching operator for `filename`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - CONTAINS
            - DOES_NOT_CONTAIN
        keyName:
          type: string
          description: Context key name (AKA Segment key or Segment ID)
        keyNameOperator:
          type: string
          description: 'Matching operator for `keyName`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - CONTAINS
            - DOES_NOT_CONTAIN
        lastModifiedFrom:
          type: string
          format: date-time
          description: >-
            Use ISO8601 date and time format (e.g. `2025-11-03T14:42:59Z`).
            Leave empty if searching for "is before", provide both from/to if
            searching "is" or "is within"
        lastModifiedTo:
          type: string
          format: date-time
          description: >-
            Use ISO8601 date and time format (e.g. `2025-11-03T14:42:59Z`).
            Leave empty if searching for "is after", provide both from/to if
            searching "is" or "is within"
        modifiedByUsers:
          type: array
          items:
            $ref: '#/components/schemas/UidReference'
        modifiedByUsersOperator:
          type: string
          description: 'Matching operator for `modifiedByUsers`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
        projects:
          type: array
          description: Original project
          items:
            $ref: '#/components/schemas/UidReference'
        projectsOperator:
          type: string
          description: 'Matching operator for `projects`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
        subdomains:
          type: array
          description: Subdomains
          items:
            $ref: '#/components/schemas/UidReference'
        subdomainsOperator:
          type: string
          description: 'Matching operator for `subdomains`. Default: IS'
          enum:
            - IS
            - IS_NOT
            - IS_ANY_OF
            - IS_NONE_OF
    SearchTmContentResponseDtoV1:
      type: object
      properties:
        srcTuv:
          $ref: '#/components/schemas/SearchTmContentResponseDtoTuv'
        targetLocaleToTuv:
          type: object
          description: Target locale to translation unit variant mapping
          additionalProperties:
            $ref: '#/components/schemas/SearchTmContentResponseDtoTuv'
        tmName:
          type: string
          description: Translation memory name
        tmUid:
          type: string
          description: Translation memory UID
        tuId:
          type: string
          description: ID of the translation unit
    UidReference:
      type: object
      required:
        - uid
      properties:
        uid:
          type: string
    SearchTmContentResponseDtoTuv:
      type: object
      properties:
        client:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        createdAt:
          type: string
          format: date-time
          description: Created timestamp
        createdBy:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        ctxSegmentKey:
          type: string
          description: Context key name (AKA Segment key or Segment ID)
        domain:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        filename:
          type: string
          description: Original file
        locale:
          type: string
          description: Locale of TUV
        modifiedAt:
          type: string
          format: date-time
          description: Last modified timestamp
        modifiedBy:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        nextSegmentKey:
          type: string
          description: Next segment text
        previousSegmentKey:
          type: string
          description: Previous segment text
        project:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        subdomain:
          $ref: '#/components/schemas/SearchTmContentResponseDtoIdentifiableObject'
        text:
          type: string
          description: Text value of TUV
        textMatches:
          type: array
          description: All indices of matches in text
          items:
            $ref: '#/components/schemas/SearchTmContentResponseDtoMatchIndices'
      description: |-
        Represents a single Translation unit variant
         (e.g. single translation of a source & target pair)
    SearchTmContentResponseDtoIdentifiableObject:
      type: object
      properties:
        name:
          type: string
          description: Name of the project/user/... or an identification of it if not found
        uid:
          type: string
          description: UID of the project/user/... if found
      description: |-
        Represents for example a user or project object.
         UID provided only if the resource is known
    SearchTmContentResponseDtoMatchIndices:
      type: object
      properties:
        endIndex:
          type: integer
          format: int32
          description: End of the match (exclusive)
        startIndex:
          type: integer
          format: int32
          description: Start of the match (inclusive)
      description: Indices of matched text
  securitySchemes:
    ApiToken:
      description: >-
        Get a token from `auth/login` [endpoint](#operation/login) and then pass
        it in the `Authorization` HTTP header in every subsequent API call. For
        more information visit our [help
        center](https://support.phrase.com/hc/en-us/articles/5709662181404-API-Authentication-TMS-#token-0-0).
      type: apiKey
      name: Authorization
      in: header
    OAuth2:
      description: >-
        A standard OAuth 2.0 authorization code flow. For more information visit
        our [help
        center](https://support.phrase.com/hc/en-us/articles/5709662181404-API-Authentication-TMS-#oauth-2-0-0-1).
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://cloud.memsource.com/web/oauth/authorize
          tokenUrl: https://cloud.memsource.com/web/oauth/token
          scopes: {}

````