Search settings API

edit

Search settings API

edit

Checkout the Relevance Tuning Guide to learn Weights and Boosts, and the Result Settings Guide for Result Fields.

Group search settings to create a custom search query and result template.

Customize which fields are searched, which are returned, and their overall weight.

The Search Settings template you create is then applied to every search query.

Supports Search Fields (Weights), Result Fields, and Boosts.

Note that result_fields changes will impact those set within the Result Settings UI. Be careful not to over-write your configuration!

Requires a Private API Key.

Show Settings

edit

Show all Weights and Boosts applied to the search fields of an Engine.

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

Example - A GET request to national-parks-demo to reveal Weight and Boost values.

curl -X GET 'https://[instance id].ent-search.[region].[provider].cloud.es.io/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": {}
}

Update Settings

edit

Create default search settings.

Impacts each search query and the results that are returned.

Pass Search Field (Weights), Result Field, and Boost objects using their usual parameters.

Note: 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 to select which fields to search, calibrate the existing Weight, and apply Boost values. Returns only the "title", "description", and "states" fields, with some snippets.

curl -X PUT 'https://[instance id].ent-search.[region].[provider].cloud.es.io/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"
        ]
      }
    ]
  }
}'

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"
        ]
      }
    ]
  }
}

Reset Settings

edit

Reset your Engine to default values.

Warning: This means your settings are wiped! Back them up!

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

Example - A POST request to national-parks-demo to reset all Weight and Boost settings.

curl -X POST 'https://[instance id].ent-search.[region].[provider].cloud.es.io/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": {}
}