# Searchable attributes match

- Operation ID: `searchableAttributesMatch`
- HTTP method: `GET`
- Path: `/search/v2/indices/{indexId}/explain-match`
- [Human-readable API reference](https://hub.synerise.com/api-reference/ai-search#tag/Search/operation/searchableAttributesMatch)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /search/v2/indices/{indexId}/explain-match:
    get:
      summary: Searchable attributes match
      description: |
        Enter a query and an item ID to check if a token (a word or a synonym which replaced it) matches a value or part of a value from the item's searchable attributes.


        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **API key permission required:** `ITEMS_SEARCH_SEARCH_READ`

        **User role permission required:** `assets_search: read`
      operationId: searchableAttributesMatch
      tags:
        - Search
      security:
        - TrackerKey: []
        - JWT: []
      parameters:
        - name: indexId
          in: path
          required: true
          description: ID of the index to be used in the search operation
          schema:
            type: string
        - name: query
          in: query
          required: true
          description: Query text to use in the search
          schema:
            type: string
        - name: itemId
          in: query
          required: true
          description: Item ID
          schema:
            type: string
      responses:
        "200":
          description: Searchable attributes match result
          content:
            application/json:
              schema:
                type: object
                title: Searchable attributes match
                properties:
                  query:
                    type: object
                    description: Search query with tokens
                    properties:
                      value:
                        type: string
                        description: Search query
                      tokens:
                        type: array
                        description: A list of search query tokens and their positions
                        items:
                          type: object
                          title: Search query tokens
                          properties:
                            token:
                              type: string
                              description: Search query token
                            positions:
                              type: array
                              description: A list of query token positions
                              items:
                                type: object
                                properties:
                                  start:
                                    type: number
                                    description: Start position
                                  end:
                                    type: number
                                    description: Start position
                  attributes:
                    type: array
                    description: A list of searchable attributes with value and matched tokens
                    items:
                      type: object
                      properties:
                        attribute:
                          type: string
                          description: Attribute name
                        value:
                          description: Attribute value
                          type: string
                        tokens:
                          type: array
                          description: A list of matched tokens
                          items:
                            type: object
                            properties:
                              queryToken:
                                type: string
                                description: Matched token
                              type:
                                description: Token type
                                type: string
                                enum:
                                  - word
                                  - synonym
                              start:
                                type: number
                                description: Start position
                              end:
                                type: number
                                description: Start position
        "500":
          description: Service not available
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  status:
                    type: integer
                    description: Status code
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  path:
                    type: string
                    description: URL of the requested resource
                required:
                  - timestamp
                  - status
                  - message
      x-snr-doc-urls:
        - /api-reference/ai-search#tag/Search/operation/searchableAttributesMatch
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.synerise.com/search/v2/indices/%7BindexId%7D/explain-match?query=SOME_STRING_VALUE&itemId=SOME_STRING_VALUE' \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" }

            conn.request("GET", "/search/v2/indices/%7BindexId%7D/explain-match?query=SOME_STRING_VALUE&itemId=SOME_STRING_VALUE", headers=headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = null;

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("GET", "https://api.synerise.com/search/v2/indices/%7BindexId%7D/explain-match?query=SOME_STRING_VALUE&itemId=SOME_STRING_VALUE");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "GET",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/search/v2/indices/%7BindexId%7D/explain-match?query=SOME_STRING_VALUE&itemId=SOME_STRING_VALUE",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/search/v2/indices/%7BindexId%7D/explain-match');
            $request->setMethod(HTTP_METH_GET);

            $request->setQueryData([
              'query' => 'SOME_STRING_VALUE',
              'itemId' => 'SOME_STRING_VALUE'
            ]);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN'
            ]);

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.get("https://api.synerise.com/search/v2/indices/%7BindexId%7D/explain-match?query=SOME_STRING_VALUE&itemId=SOME_STRING_VALUE")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Search
components:
  securitySchemes:
    TrackerKey:
      type: apiKey
      name: token
      in: query
      description: Authorization by tracker key sent as a query parameter. This is the same key as used in the website tracking code.
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
