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

# Wildcard search

> 
**Overview**
- Searches a single translation memory via Elasticsearch wildcard queries and returns up to `count` matches.

**Query semantics**
- `query` supports `*` (multi-character, single-token) and `?` (single-character) wildcards. Queries map directly to ES `query_string`, so ordering is flexible and Boolean operators from user input are ignored.
- If `query` is omitted or blank, the service falls back to `*`, which matches any source segment.

**Query examples**
Imagine having segment: `Good morning`
Query:
- `good morn*` → matches `Good morning`.
- `morn* good` → matches `Good morning` (word order ignored in contains mode).
- `goof morn*` → also matches `Good morning` because any matching token is sufficient.
- `*` → matches any TM segment.
- `"good morn*"` → treated literally; returns no results unless the segment actually contains the quotes.
- ``Good morning`` (no quotes) → matches `Good morning`.

**Request limits**
- `count` must be between `1` and `50` (default `15`).
- `offset` must be ≥ `0` (default `0`).
- `sourceLang` must be a valid locale; `targetLangs` is optional (defaults to the TM target locales when omitted).

**Scoring and ordering**
- Backend returns both `grossScore` (raw) and `score` (penalty-adjusted, never negative).
- Ordering priority: `score DESC`, `grossScore DESC`, TM order ASC, modified or created timestamp DESC, source TUV ID ASC.

**Target handling**
- Hits without targets in the requested locales are filtered out.
- Multiple requested target locales produce multiple ordered target records per hit.

**Validation & errors**
- Invalid locales, `count`/`offset` outside allowed bounds, or missing TM access rights yield `400`/`403`.
- Because no total size is returned, clients should consider using `offset + count` to detect pagination end (empty page ⇒ done).




## OpenAPI

````yaml /openapi/phrase-tms-v1.json post /api2/v1/transMemories/{transMemoryUid}/wildCardSearch
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: 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: XML Assistant
paths:
  /api2/v1/transMemories/{transMemoryUid}/wildCardSearch:
    post:
      tags:
        - Translation Memory
      summary: Wildcard search
      description: >

        **Overview**

        - Searches a single translation memory via Elasticsearch wildcard
        queries and returns up to `count` matches.


        **Query semantics**

        - `query` supports `*` (multi-character, single-token) and `?`
        (single-character) wildcards. Queries map directly to ES `query_string`,
        so ordering is flexible and Boolean operators from user input are
        ignored.

        - If `query` is omitted or blank, the service falls back to `*`, which
        matches any source segment.


        **Query examples**

        Imagine having segment: `Good morning`

        Query:

        - `good morn*` → matches `Good morning`.

        - `morn* good` → matches `Good morning` (word order ignored in contains
        mode).

        - `goof morn*` → also matches `Good morning` because any matching token
        is sufficient.

        - `*` → matches any TM segment.

        - `"good morn*"` → treated literally; returns no results unless the
        segment actually contains the quotes.

        - ``Good morning`` (no quotes) → matches `Good morning`.


        **Request limits**

        - `count` must be between `1` and `50` (default `15`).

        - `offset` must be ≥ `0` (default `0`).

        - `sourceLang` must be a valid locale; `targetLangs` is optional
        (defaults to the TM target locales when omitted).


        **Scoring and ordering**

        - Backend returns both `grossScore` (raw) and `score` (penalty-adjusted,
        never negative).

        - Ordering priority: `score DESC`, `grossScore DESC`, TM order ASC,
        modified or created timestamp DESC, source TUV ID ASC.


        **Target handling**

        - Hits without targets in the requested locales are filtered out.

        - Multiple requested target locales produce multiple ordered target
        records per hit.


        **Validation & errors**

        - Invalid locales, `count`/`offset` outside allowed bounds, or missing
        TM access rights yield `400`/`403`.

        - Because no total size is returned, clients should consider using
        `offset + count` to detect pagination end (empty page ⇒ done).
      operationId: wildcardSearch
      parameters:
        - name: transMemoryUid
          in: path
          description: Translation memory UID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WildCardSearchRequestDtoV1'
        description: Wildcard search request
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponseListTmDtoV1'
        '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:
    WildCardSearchRequestDtoV1:
      type: object
      required:
        - sourceLang
      properties:
        count:
          type: integer
          format: int32
          description: Maximum number of results to return (1-50, default 15)
          minimum: 1
          maximum: 50
        offset:
          type: integer
          format: int32
          description: Number of results to skip for pagination (default 0)
        query:
          type: string
          description: >-
            Wildcard search query; supports * and ? wildcards. Defaults to *
            when blank
        sourceLang:
          type: string
          description: Source language locale
        sourceLangs:
          type: array
          items:
            type: string
        targetLangs:
          type: array
          description: Target language locales; defaults to all TM target languages
          items:
            type: string
      description: >-
        Request body for wildcard TM search; supports * and ? wildcards in the
        query string
    SearchResponseListTmDtoV1:
      type: object
      properties:
        searchResults:
          type: array
          description: Translation memory search results
          items:
            $ref: '#/components/schemas/SearchTMResponseDtoV1'
    SearchTMResponseDtoV1:
      type: object
      properties:
        grossScore:
          type: number
          format: double
          description: Raw match score before penalty adjustments
        score:
          type: number
          format: double
          description: Final match score after penalty adjustments
        segmentId:
          type: string
          description: Unique identifier of the matched TM segment
        source:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMSegmentDtoV1'
        subSegment:
          type: boolean
          description: >-
            When true, the match is a subsegment (source is a substring of the
            query)
        transMemory:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMTransMemoryDtoV1'
        translations:
          type: array
          description: Target translation segments for the TM match
          items:
            $ref: '#/components/schemas/SearchTMResponseDtoSearchTMSegmentDtoV1'
    SearchTMResponseDtoSearchTMSegmentDtoV1:
      type: object
      properties:
        client:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMClientDtoV1'
        createdAt:
          type: integer
          format: int64
          description: Timestamp of creation (milliseconds since epoch)
        createdBy:
          $ref: '#/components/schemas/UserReferenceV1'
        domain:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMDomainDtoV1'
        filename:
          type: string
          description: Name of the source file the segment originates from
        id:
          type: string
          description: Segment identifier
        key:
          type: string
          description: Context key used for context-based TM matching
        lang:
          type: string
          description: Language code of the segment
        modifiedAt:
          type: integer
          format: int64
          description: Timestamp of the last modification (milliseconds since epoch)
        modifiedBy:
          $ref: '#/components/schemas/UserReferenceV1'
        nextSegment:
          type: string
          description: Following segment used for context matching
        previousSegment:
          type: string
          description: Preceding segment used for context matching
        project:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMProjectDtoV1'
        rtl:
          type: boolean
          description: When true, the language is right-to-left
        subDomain:
          $ref: '#/components/schemas/SearchTMResponseDtoSearchTMSubDomainDtoV1'
        tagMetadata:
          type: array
          description: Tag metadata for the segment
          items:
            $ref: '#/components/schemas/TagMetadata'
        text:
          type: string
          description: Segment text content
    SearchTMResponseDtoSearchTMTransMemoryDtoV1:
      type: object
      properties:
        id:
          type: string
          description: Internal translation memory ID
        name:
          type: string
          description: Translation memory name
        reverse:
          type: boolean
          description: When true, this TM is used in reverse (target-to-source) mode
        uid:
          type: string
          description: Translation memory UID
    SearchTMResponseDtoSearchTMClientDtoV1:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: Internal client ID
        name:
          type: string
          description: Client name
    UserReferenceV1:
      type: object
      properties:
        email:
          type: string
          description: Email address of the user
        firstName:
          type: string
          description: First name of the user
        id:
          type: string
          description: Unique numeric identifier of the user
        lastName:
          type: string
          description: Last name of the user
        role:
          type: string
          description: Role of the user in the organization
          enum:
            - SYS_ADMIN
            - SYS_ADMIN_READ
            - ADMIN
            - PROJECT_MANAGER
            - LINGUIST
            - GUEST
            - SUBMITTER
            - PORTAL_MEMBER
            - BOT
        uid:
          type: string
          description: Unique string identifier of the user
        userName:
          type: string
          description: Username of the user
    SearchTMResponseDtoSearchTMDomainDtoV1:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: Internal domain ID
        name:
          type: string
          description: Domain name
    SearchTMResponseDtoSearchTMProjectDtoV1:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: Internal project ID
        name:
          type: string
          description: Project name
        uid:
          type: string
          description: Project UID
    SearchTMResponseDtoSearchTMSubDomainDtoV1:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: Internal subdomain ID
        name:
          type: string
          description: Subdomain name
    TagMetadata:
      type: object
      properties:
        content:
          type: string
        id:
          type: string
        transAttributes:
          type: string
        type:
          type: string
  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: {}

````