Search settings API

edit

Search settings API

edit

Use the search settings API to set engine defaults for the following search API request parameters:

Each query sent to an engine will use these default parameters, unless they are overridden directly within the query.

The changes you make to result_fields through this API will affect those shown within the Result Settings UI.

Requires a Private API Key.

Show search settings

edit

Show the search settings for a given engine.

GET /api/as/v1/engines/{ENGINE_NAME}/search_settings

Example - A GET request to national-parks-demo:

curl -X GET 'https://[instance id].ent-search.[region].[provider].cloud.es.io:443/api/as/v1/engines/national-parks-demo/search_settings' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxx'

Example response:

{
  "search_fields": {
    "description": {
      "weight": 1
    },
    "nps_link": {
      "weight": 1
    },
    "states": {
      "weight": 1
    },
    "title": {
      "weight": 3
    },
    "world_heritage_site": {
      "weight": 1
    },
    "id": {
      "weight": 1
    }
  },
  "result_fields": {
    "id": {
      "raw": {}
    },
    "description": {
      "raw": {}
    },
    "nps_link": {
      "raw": {}
    },
    "states": {
      "raw": {}
    },
    "title": {
      "raw": {}
    },
    "visitors": {
      "raw": {}
    },
    "world_heritage_site": {
      "raw": {}
    },
    "location": {
      "raw": {}
    },
    "acres": {
      "raw": {}
    },
    "square_km": {
      "raw": {}
    },
    "date_established": {
      "raw": {}
    }
  },
  "boosts": {},
  "precision": 2
}

Update search settings

edit

Update the search settings for a given engine.

Removing fields from result_fields means that those fields are not returned in results.

PUT /api/as/v1/engines/{ENGINE_NAME}/search_settings

Example - A PUT request to national-parks-demo. This example selects which fields to search, calibrates field weights, boosts specific field values, and tunes precision. Responses for this example return only the "title", "description", and "states" fields, with snippets.

curl -X PUT 'https://[instance id].ent-search.[region].[provider].cloud.es.io:443/api/as/v1/engines/national-parks-demo/search_settings' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxx' \
-d '{
  "search_fields": {
    "description": {
      "weight": 9.2
    },
    "nps_link": {
      "weight": 1
    },
    "states": {
      "weight": 3
    },
    "title": {
      "weight": 1
    },
    "world_heritage_site": {
      "weight": 1
    },
    "id": {
      "weight": 1
    }
  },
  "result_fields": {
    "title": {
      "snippet": {
        "size": 20,
        "fallback": true
      }
    },
    "description": {
      "raw": {
        "size": 200
      },
      "snippet": {
        "size": 100
      }
    },
    "states": {
      "raw" : {},
      "snippet": {
        "size": 20,
        "fallback": true
      }
    }
  },
  "boosts": {
    "world_heritage_site": [
      {
        "type": "value",
        "factor": 9.5,
        "value": [
          "true"
        ]
      }
    ]
  },
  "precision": 3
}'

Example response:

{
  "search_fields": {
    "description": {
      "weight": 9.2
    },
    "nps_link": {
      "weight": 1
    },
    "states": {
      "weight": 3
    },
    "title": {
      "weight": 1
    },
    "world_heritage_site": {
      "weight": 1
    },
    "id": {
      "weight": 1
    }
  },
  "boosts": {
    "world_heritage_site": [
      {
        "type": "value",
        "factor": 9.5,
        "value": [
          "true"
        ]
      }
    ]
  },
  "precision": 3
}

Reset search settings

edit

Reset the search settings for a given engine back to the App Search default values.

Your search settings will be lost. You may want to back up your settings before resetting them.

POST /api/as/v1/engines/{ENGINE_NAME}/search_settings/reset

Example - A POST request to national-parks-demo.

curl -X POST 'https://[instance id].ent-search.[region].[provider].cloud.es.io:443/api/as/v1/engines/national-parks-demo/search_settings/reset' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxx'

Example response:

{
  "search_fields": {
    "description": {
      "weight": 1
    },
    "nps_link": {
      "weight": 1
    },
    "states": {
      "weight": 1
    },
    "title": {
      "weight": 1
    },
    "world_heritage_site": {
      "weight": 1
    },
    "id": {
      "weight": 1
    }
  },
  "boosts": {},
  "precision": 2
}