# Setting up resolvers for Outbound Feeds

Source: https://dev.arcxp.com/arc-io/developer-docs/setting-up-resolvers-for-outbound-feeds/

A Resolver is a regular expression pattern that matches a Template to a piece of content before rendering and serving a webpage to the reader. This document guides you through setting up a resolver to use with Outbound Feeds. Take the following steps:

1. On your Arc XP dashboard, select the **outboundfeeds** or **outboundfeeds-sandbox** environment.
2. Click the **outbound feeds** tile.
3. On the top navigation menu, click the **Developer Tools** tab.  
The Developer Tools submenu displays.
4. On the Developer Tools submenu, click the **Resolvers** tab  
The Resolvers Configuration page displays.
5. Click the **New Resolver** button.  
The Create Resolver pane opens.
6. Complete the following fields:

  - **Resolver Name:** Give the resolver a name.
  - **Resolver Priority:** An integer value from 1 to 99 that represents how important this configuration is. The lower the value, the higher the priority of the resolver. 10 is a good value to use in case you need to add higher priority resolvers in the future. For example, if you have two RSS resolvers, both with the same regex, but one with a required parameter such as `summary=false`, you can assign a higher priority (lower value) to the one with the required parameter so it gets evaluated first.
  - **Resolver Note:** You can add a note to describe what this resolver does or how it differs from other resolvers.
  - **Pattern:** The regex of the URL(s) for the feed. Consider the following:

    - Outbound Feeds is a separate website that is hosted at `https://www.your_website.com/arc/outboundfeeds`. All requests start with `/arc/outboundfeeds` at the beginning of the URI.
    - Take care when creating or modifying resolvers. A mistake in one regex in one resolver can impact your entire Outbound Feeds site. For example, if you create a regex like “feed”, it matches anything that contains the letters “feed”, like /`arc/outboundfeeds/rss/` and `/arc/outboundfeeds/feed/`. Make each regex as specific as possible.
    - If you want to match only your RSS feed: `/arc/outboundfeeds/rss`, use `^/arc/outboundfeeds/rss$` to match only that URI. The caret `^` symbol specifies the string must start there, to prevent matching in the middle of a string. The dollar `$` symbol specifies the string must end there, again preventing matching in the middle of a string.
    - If you want to match `/arc/outboundfeeds/rss` and `/arc/outboundfeeds/rss/`, use `^/arc/outboundfeeds/rss/?$` to specify it may end with an optional forward slash `/`. Requests from your origin (CDN) have a forward slash added to them, so adding the forward slash or an optional forward slash and question mark `/?` is best practice.  
      > **Note:**  
      >  
      > When testing locally or using the internal links, such as `https://outboundfeeds.{ORG}.arcpublishing.com/`, you can build regexes without the `/arc/outboundfeeds/` and a forward slash `/`. But for URLs from origin (CDN) all start with `/arc/outboundfeeds/` and have a forward slash `/` (unless they end in a file extension like `.xml`).
    - If you want to add a pattern to the URL, for example, to pass a section in the request, use parentheses: `^/arc/outboundfeeds/rss/category/(.*)/?$`. If a request is made for `/arc/outboundfeeds/rss/category/sports` the word `sports` matches the pattern in parentheses. You can then use the pattern option to pass that value to the content source.
    - You can join multiple regex patterns with the pipe symbol `|`. If you want to allow filtering by section, author, keywords, and tags, you can join multiple regex terms together, for example:  
      ```
      ^/arc/outboundfeeds/rss/?$|^/arc/outboundfeeds/rss/category/(.*)/?$|^/arc/outboundfeeds/rss/author/(.*)/?$|^/arc/outboundfeeds/rss/keyword/(.*)/?$|^/arc/outboundfeeds/rss/tags/(.*)/?$|^/arc/outboundfeeds/rss/tags_slug/(.*)/?$
      ```
      > **Important:**  
      >  
      > Be careful not to start or end a regex with a pipe `|`. This causes the regex pattern to match every request and it is difficult to debug.
  - **URL Parameters:** Add additional parameters to the resolver URL. Consider the following:

    - You can add the `size` parameter with a value of `.*` and make it optional
    - You can add the `from` parameter with a value of `.*` and make it optional
    - Here is the list of valid URL parameters for Outbound Feeds:  
      ```
      _id
      body
      branch
      format
      from
      fulltext
      key
      limit
      outputType
      pagebuilder
      published
      revision_id
      size
      slug
      sort
      summary
      url
      ```
      > **Important:**  
      >  
      > Using a parameter that is not in the list causes unexpected results and is ignored by the CDN when performing cache lookup, which causes invalid cache hits.  
      >  
      > If you want to use a parameter that is not in the list, use a regex pattern instead. If you cannot use a regex pattern, contact [Arc XP Customer Support](https://support.arcpublishing.com/) to evaluate your request and submit it to the ideas board.  
      > **Note:**  
      >  
      > The `query` and `dsl` parameters are no longer supported. All redirects with either of these parameters do not work as intended.
  - **Content source:**

    - The standard Content-API source for most feeds is `feeds-content-api`. Additional content sources are available out-of-the-box. For more information, see [Content sources with outbound feeds](https://dev.arcxp.com/arc-io/developer-docs/content-sources-with-outbound-feeds/).
    - The default query is for stories published in the last two days.
    - To override the default query use `Include-Terms`, `Exclude-Terms`, and `Exclude-Sections`. You can use the `feeds-content-api` content source to search for other types of content, like video or gallery, by changing the query by using the `Include-Terms` and `Exclude-Terms` fields.
  - **Parameter from the request:**

    - If you added any parameters, you should add them here. Leaving the parameter fields empty causes the content source to use its default values, which are listed here:

      - **Section** : Maps to `taxonomy.sections._id`. A comma separated list of sections to search for. Each section should start with a slash like `/news,/politics`. If the included sections aren’t being included as expected, try adding `taxonomy.sections` to the `Source-Include` parameter. **Section** \- pattern 1
      - **Author:** Maps to `Credits.By._id`. **Author** \- pattern 2
      - **Keywords:** Maps to `taxonomy.seo_keywords`. It can be a comma separated list of values. **Keywords** \- pattern 3
      - **Tags-Text:** Maps to `taxonomy.tags.text`. It can be a comma separated list of values. **Tags-Text** \- pattern 4
      - **Tags-Slug:** Maps to `taxonomy.tags.slug`. **Tags-Slug** \- pattern 5
      - **Include-Terms:** If you don’t want to use the default query, you can enter a query here. It must be a valid JSON array formatted with ElasticSearch DSL syntax. For more details on custom queries, see [How to Create a Custom Query with Outbound Feeds](https://dev.arcxp.com/arc-io/developer-docs/how-to-create-a-custom-query-with-outbound-feeds/). For example, if the feed uses display date, you can use `display_date` in the query (and sort by `display_date`):  
            ```
            [{"term":{"type":"story"}},{"range":{"display_date":{"gte":"now-2d","lte":"now"}}}]
            ```
            > **Note:**  
            >  
            > If you are working in `outboundfeeds-sandbox` and you do not see any data, it could be because Sandbox does not have recent content. If that is the case, you can remove the range term in your Sandbox resolvers.
      - **Exclude-Terms:** If you need to exclude terms in your query, enter them as an array formatted the same as the `Include-Terms`. For more details on custom queries, see [How to Create a Custom Query with Outbound Feeds](https://dev.arcxp.com/arc-io/developer-docs/how-to-create-a-custom-query-with-outbound-feeds/). For example, to exclude all content with language “es”, use:  
            ```
            [{"term":{"language": "es"}}]
            ```
      - **Exclude-Sections:** A comma separated list of sections to exclude. For example `/premium,/paid-content`. If the excluded sections are not excluded as expected, try adding `taxonomy.sections` to the `Source-Include` parameter.
      - **Feed-Size:** Integer 1 to 100\. Defaults to 100\. If you added a size URL parameter, select the parameter option, select size, and enter a default value.
      - **Feed-Offset:** Integer. Defaults to 0\. If you add a `from` URL parameter, select the parameter option, select `from`, and enter a default value. Offsets cannot be greater than or equal to 10,000.
      - **Sort:** Comma separated list of fields to sort on. If the feed displays a date, use that date for the sort and the range field in `Include-Terms`. Defaults to `publish_date:desc`.
      - **Source-Include:** Comma-separated list of Arc XP Native Specification (ANS) fields to include in the response from Content API. The content sources use the `_sourceIncludes` parameter to reduce the response size. They start with the following [ANS fields](https://dev.arcxp.com/arc-io/developer-docs/content-sources-with-outbound-feeds/#included-data/). You can include additional fields to the `_sourceIncludes` parameter.
      - **Source-Exclude:** Comma-separated list of ANS fields to exclude from the response. The content sources use the `_sourceIncludes` parameter to reduce the response size. They start with the following [ANS fields](https://dev.arcxp.com/arc-io/developer-docs/content-sources-with-outbound-feeds/#included-data/). You can exclude fields from that list by adding them to the `_sourceIncludes` parameter.
      - **Sitemap-at-root** : Populate this field with `true` only if you need to convert Section values from dashes to slashes. If you are redirecting `Sitemap-section-front-index` from root, the generated links look like `/sitemap-category-sports-football`. The Section pattern is `sports-football.` Setting this field to `true` converts the pattern to `/sports/football`. If you have sections that contain slashes, you must set up separate resolvers to handle those sections.
      - **Include-Distributor-Name:** If you want content from certain distributors, enter the name or names as a comma-separated list. You can only populate one distributor field.
      - **Exclude-Distributor-Name:** If you want to exclude content from certain distributors, enter the name or names as a comma-separated list. You can only populate one distributor field.
      - **Include-Distributor-Category:** If you want content from certain distributor categories, enter the name or names as a comma-separated list. You can only populate one distributor field.
      - **Exclude-Distributor-Category:** If you want to exclude content from certain distributor categories, enter the name or names as a comma-separated list. You can only populate one distributor field.
      - **Default Template:** Select a template you created in the outboundfeeds environment.
      - **Default output type:** Select the output type appropriate for the template, such as xml, json, or text.
      - **Content Mapped:** Template - leave blank.
7. Click **Save**.

## View feed output

You have three options to view the feed output:

- You can see the published feed using the following URL format. This assumes the resolver is for /sitemap:

  - sandbox: `https://outboundfeeds-sandbox.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap?_website={websitename}`
  - prod: `https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap?_website={websitename}`
- You can use the fusion (pf) URL if you are logged in through OKTA.
- You can use the public URLs:

  - sandbox: `https://{ORG}-{WEBSITE}-sandbox.web.arc-cdn.net/arc/outboundfeeds/sitemap/`
  - prod: `https://{ORG}-{WEBSITE}-prod.web.arc-cdn.net/arc/outboundfeeds/sitemap/` (if your site isn’t live yet)
  - prod: `https://www.example.com/arc/outboundfeeds/sitemap/` (if your site is live)

## Filter by section

To see a filtered sitemap by section based on `taxonomy.sections._id`, use:

```
https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap/category/sports?_website={websitename}
```

## Filter by author

To see a filtered sitemap by author based on `credits.by._id`, use:

```
https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap/author/alexremington?_website={websitename}
```

## Filter by keyword

To see a filtered sitemap by keyword based on `taxonomy.seo_keywords`, use:

```
https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap/seo_keywords/sports,football?_website={websitename}
```

## Filter by tags

To see a filtered sitemap by tags based on `taxonomy.tags.text`, use:

```
https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap/tags/nfl,brady?_website={websitename}
```

## Filters by tags-slug

To see a filtered sitemap by tags-slug based on `taxonomy.tags.slug`, use:

```
https://outboundfeeds.{ORG}.arcpublishing.com/pf/arc/outboundfeeds/sitemap/tags-slug/2020-world-series?_website={websitename}
```
