> ## 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

> 
**Overview**
- Searches TM content within a single Translation Memory (TM), matching against source and/or target segment text, with optional metadata filters.

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

**Query modes**
- The operator (`sourceOperator|targetOperator`) defaults to `CONTAINS` for every query mode (the same default as the TM search UI). Use `IS` to match the whole segment.
- Exact query (plain text, no wildcard markers, regex disabled): if `sourceOperator|targetOperator=IS|IS_NOT` (exact mode) the whole field must (not) match exactly; if `CONTAINS|DOES_NOT_CONTAIN` (contains mode) the text may appear anywhere within the field.
- Wildcard query (`sourceUseRegex|targetUseRegex=false`): uses `?` (single character) and `*` (multi-character) placeholders. Both expand within a single word only (they never cross whitespace) and may appear anywhere in the word — e.g. `trans*` matches `translation`/`transfer`; `*orning` and `mor*ng` match `morning`; `tr?nslate` matches `translate`/`trenslate`. Limits: max 5 `*` and 10 `?` per query.
- Regex query (`sourceUseRegex|targetUseRegex=true`): with `CONTAINS` (default) `REGEXP` searches for substrings (not whole-word by default); with `IS` the expression must match the whole segment. The engine is Lucene's automaton engine (Elasticsearch fleet: EU on 8.19.x pending reindex, other envs on 9.4.x — Lucene 9–10), not PCRE: it supports `\w`, `\W`, `\d`, `\D`, `\s`, `\S` but not word boundaries `\b`/`\B`, look-around, or back-references. Unicode property classes (`\p{L}`, `\P{Nd}`, …) are broadened internally and re-validated exactly, so e.g. `\p{L}\.\p{L}\.` returns correct results. A construct the engine cannot evaluate returns "Unsupported regular expression"; a malformed expression returns "Invalid regular expression". Prefer wildcard queries for word-based matching.

**CONTAINS / IS semantics (non-regex queries)**
- `CONTAINS` is a phrase (substring) match: the query text must appear in the segment as one contiguous sequence, in the given word order. It is not an "any word" match — e.g. `small car` matches `the small car is red` but neither `small blue car` nor `car small`.
- `IS` requires the whole segment to equal the query (after whitespace normalization).
- Matching is case-insensitive unless `sourceMatchCase|targetMatchCase=true`.
- Double quotes have no special meaning here (unlike the `search` and `wildCardSearch` endpoints) — they are searched as literal characters, so `"small car"` only matches segments that actually contain the quote characters. Do not wrap the query in quotes; `CONTAINS` already performs phrase matching.
- A query may end or start in the middle of a word only when at least one other word of the query matches a whole word — e.g. `good morn` matches `good morning`, but `morn` alone does not. Use a wildcard (`morn*`) for partial-word matching.
- Languages written without spaces (Chinese, Japanese, Korean, Thai) are matched as a contiguous character sequence as well.

**Metadata filters**
- `filters` accepts multiple metadata filter criteria (projects, domain, subdomains, ...); AND logic is applied across them.

**Plan gating**
- This is a Business/Enterprise (or legacy Ultimate/Enterprise) feature. When the caller's organization is not entitled to it, the response is `501 Not Implemented` with `errorCode: TRANS_MEMORY_SEARCH_NOT_ENABLED` — distinct from an unimplemented endpoint — so callers can tell "not entitled" apart from "not built".

**Defaults & limitations**
- Whitespace is normalized; the wildcard processor can filter out Phrase tags.
- Even wildcard results are post-filtered to enforce correct word order.
- A single query is capped at 10,000 matches. If more than 10,000 segments match, only the first 10,000 are returned and `totalElements` will not exceed that cap.

**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.
- Non-regex queries first retrieve candidate segments sharing at least one word with the query (for Chinese/Japanese: at least one character), then validate each candidate against the exact query sequence. All candidates are validated to compute `totalElements`, so queries consisting of very common words or characters can be slow on large TMs.
- If the search exceeds the time limit (about 1 minute), the response is `400 Bad Request` ("Search query for this TM takes too long..."); refine the query or add filters.




## OpenAPI

````yaml /openapi/phrase-tms-v1.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: '1'
  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: Connections
  - 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: Metabase
  - 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: Segment
  - name: Segmentation Rules
  - name: Service
  - name: Setup
  - name: Spell Check
  - name: SubDomain
  - name: Supported Languages
  - name: Term Base
  - name: Translation
  - name: Translation Memory
  - name: User
  - name: User Profile
  - name: Vendor
  - name: Webhook
  - name: Workflow Step
  - name: XML Assistant
paths:
  /api2/v1/transMemories/{transMemoryUid}/searchContent:
    post:
      tags:
        - Translation Memory
      summary: Search TM content
      description: >

        **Overview**

        - Searches TM content within a single Translation Memory (TM), matching
        against source and/or target segment text, with optional metadata
        filters.


        **Interpreting found results**

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

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


        **Query modes**

        - The operator (`sourceOperator|targetOperator`) defaults to `CONTAINS`
        for every query mode (the same default as the TM search UI). Use `IS` to
        match the whole segment.

        - Exact query (plain text, no wildcard markers, regex disabled): if
        `sourceOperator|targetOperator=IS|IS_NOT` (exact mode) the whole field
        must (not) match exactly; if `CONTAINS|DOES_NOT_CONTAIN` (contains mode)
        the text may appear anywhere within the field.

        - Wildcard query (`sourceUseRegex|targetUseRegex=false`): uses `?`
        (single character) and `*` (multi-character) placeholders. Both expand
        within a single word only (they never cross whitespace) and may appear
        anywhere in the word — e.g. `trans*` matches `translation`/`transfer`;
        `*orning` and `mor*ng` match `morning`; `tr?nslate` matches
        `translate`/`trenslate`. Limits: max 5 `*` and 10 `?` per query.

        - Regex query (`sourceUseRegex|targetUseRegex=true`): with `CONTAINS`
        (default) `REGEXP` searches for substrings (not whole-word by default);
        with `IS` the expression must match the whole segment. The engine is
        Lucene's automaton engine (Elasticsearch fleet: EU on 8.19.x pending
        reindex, other envs on 9.4.x — Lucene 9–10), not PCRE: it supports `\w`,
        `\W`, `\d`, `\D`, `\s`, `\S` but not word boundaries `\b`/`\B`,
        look-around, or back-references. Unicode property classes (`\p{L}`,
        `\P{Nd}`, …) are broadened internally and re-validated exactly, so e.g.
        `\p{L}\.\p{L}\.` returns correct results. A construct the engine cannot
        evaluate returns "Unsupported regular expression"; a malformed
        expression returns "Invalid regular expression". Prefer wildcard queries
        for word-based matching.


        **CONTAINS / IS semantics (non-regex queries)**

        - `CONTAINS` is a phrase (substring) match: the query text must appear
        in the segment as one contiguous sequence, in the given word order. It
        is not an "any word" match — e.g. `small car` matches `the small car is
        red` but neither `small blue car` nor `car small`.

        - `IS` requires the whole segment to equal the query (after whitespace
        normalization).

        - Matching is case-insensitive unless
        `sourceMatchCase|targetMatchCase=true`.

        - Double quotes have no special meaning here (unlike the `search` and
        `wildCardSearch` endpoints) — they are searched as literal characters,
        so `"small car"` only matches segments that actually contain the quote
        characters. Do not wrap the query in quotes; `CONTAINS` already performs
        phrase matching.

        - A query may end or start in the middle of a word only when at least
        one other word of the query matches a whole word — e.g. `good morn`
        matches `good morning`, but `morn` alone does not. Use a wildcard
        (`morn*`) for partial-word matching.

        - Languages written without spaces (Chinese, Japanese, Korean, Thai) are
        matched as a contiguous character sequence as well.


        **Metadata filters**

        - `filters` accepts multiple metadata filter criteria (projects, domain,
        subdomains, ...); AND logic is applied across them.


        **Plan gating**

        - This is a Business/Enterprise (or legacy Ultimate/Enterprise) feature.
        When the caller's organization is not entitled to it, the response is
        `501 Not Implemented` with `errorCode: TRANS_MEMORY_SEARCH_NOT_ENABLED`
        — distinct from an unimplemented endpoint — so callers can tell "not
        entitled" apart from "not built".


        **Defaults & limitations**

        - Whitespace is normalized; the wildcard processor can filter out Phrase
        tags.

        - Even wildcard results are post-filtered to enforce correct word order.

        - A single query is capped at 10,000 matches. If more than 10,000
        segments match, only the first 10,000 are returned and `totalElements`
        will not exceed that cap.


        **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.

        - Non-regex queries first retrieve candidate segments sharing at least
        one word with the query (for Chinese/Japanese: at least one character),
        then validate each candidate against the exact query sequence. All
        candidates are validated to compute `totalElements`, so queries
        consisting of very common words or characters can be slow on large TMs.

        - If the search exceeds the time limit (about 1 minute), the response is
        `400 Bad Request` ("Search query for this TM takes too long..."); refine
        the query or add filters.
      operationId: searchContent
      parameters:
        - name: transMemoryUid
          in: path
          description: Translation memory UID
          required: true
          schema:
            type: string
        - name: index
          in: query
          description: 'Start index for pagination (default: 0)'
          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'
        description: Search TM content request payload
        required: true
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Not authorized
        '403':
          description: Forbidden
        '404':
          description: 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: CONTAINS'
          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: CONTAINS'
          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
    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
    UidReference:
      type: object
      required:
        - uid
      properties:
        uid:
          type: string
          example: 3HYnHHLkTPJfMxBCDbPXFe
          description: Unique identifier of the referenced object
      description: Reference to an object by its unique identifier
  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: {}

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.