> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ALS Recommender Jobs

export const schema = {
  "type": "object",
  "title": "ALS Recommender (deprecated)",
  "description": "Computes user recommendations or item similarities using a collaborative filtering ALS recommender. Configure the training collection and optional output collections to generate batch-predicted recommendations stored in Solr. Deprecated as of Fusion 5.2.0. Use the BPR Recommender instead.",
  "required": ["id", "trainingCollection", "type"],
  "properties": {
    "id": {
      "type": "string",
      "title": "Spark Job ID",
      "description": "The ID for this Spark job. Used in the API to reference this job. Allowed characters: a-z, A-Z, dash (-) and underscore (_).",
      "maxLength": 63,
      "pattern": "[a-zA-Z][_\\-a-zA-Z0-9]*[a-zA-Z0-9]?"
    },
    "sparkConfig": {
      "type": "array",
      "title": "Spark Settings",
      "description": "Sets Spark configuration key-value pairs for this job. Use entries like `spark.executor.memory=4g` to tune resource allocation. These settings override cluster defaults and apply only to this job's execution.",
      "hints": ["advanced"],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "trainingCollection": {
      "type": "string",
      "title": "Recommender Training Collection",
      "description": "Specifies the Solr collection containing user/item preference data, such as a signals or signals aggregation collection. This collection provides the interaction data used to train the ALS model."
    },
    "outputCollection": {
      "type": "string",
      "title": "Items-for-users Recommendation Collection",
      "description": "Specifies the collection where batch-predicted user-to-item recommendations are written. If absent, no user recommendations are computed or stored."
    },
    "outputItemSimCollection": {
      "type": "string",
      "title": "Item-to-item Similarity Collection",
      "description": "Specifies the collection where batch-computed item-to-item similarities are written. If absent, no item similarities are computed or stored."
    },
    "numRecs": {
      "type": "integer",
      "title": "Number of User Recommendations to Compute",
      "description": "Controls how many item recommendations are batch-computed and stored per user. Set to a higher value to surface more choices, but note that storage and compute time increase proportionally.",
      "default": 10
    },
    "numSims": {
      "type": "integer",
      "title": "Number of Item Similarites to Compute",
      "description": "Controls how many item similarities are batch-computed and stored per item. Larger values improve recommendation coverage but increase compute time and storage requirements.",
      "default": 10
    },
    "implicitRatings": {
      "type": "boolean",
      "title": "Implicit Preferences",
      "description": "Controls whether training data is treated as implicit feedback (such as clicks) rather than explicit ratings. When `true`, the ALS algorithm uses a confidence-weighted approach suited to implicit signals like view counts.",
      "default": true
    },
    "deleteOldRecs": {
      "type": "boolean",
      "title": "Delete Old Recommendations",
      "description": "Controls whether existing recommendations are deleted before writing new ones. When `true`, stale recommendations are removed to keep the collection current. When `false`, new recommendations are appended alongside old ones.",
      "default": true
    },
    "excludeFromDeleteFilter": {
      "type": "string",
      "title": "Exclude from Delete Filter",
      "description": "Specifies a Solr filter query identifying recommendation documents to retain when `deleteOldRecs` is `true`. Use this to protect specific documents, such as manually curated recommendations, from deletion.",
      "hints": ["advanced"]
    },
    "outputUserRecsCollection": {
      "type": "string",
      "title": "Users-for-items Recommendation Collection",
      "description": "Specifies the collection where batch-predicted item-to-user recommendations are written. If absent, no user recommendations per item are computed. Configure this in the advanced section.",
      "hints": ["advanced"]
    },
    "numUserRecsPerItem": {
      "type": "integer",
      "title": "Number of Users to Recommend to each Item",
      "description": "Controls how many user recommendations are batch-computed and stored per item. Requires `outputUserRecsCollection` to be set. If that field is absent, this setting has no effect.",
      "default": 10,
      "hints": ["advanced"]
    },
    "modelId": {
      "type": "string",
      "title": "Recommender Model ID",
      "description": "Sets the unique identifier used to store and retrieve the ALS model in Solr. If absent, defaults to the Spark job ID. Set explicitly when multiple jobs share a model.",
      "hints": ["advanced"]
    },
    "saveModel": {
      "type": "boolean",
      "title": "Save Model in Solr",
      "description": "Controls whether the computed ALS model is persisted to Solr after training. When `true`, the model is saved to `modelCollection` and can be reloaded without retraining.",
      "default": false,
      "hints": ["advanced"]
    },
    "modelCollection": {
      "type": "string",
      "title": "Model Collection",
      "description": "Specifies the Solr collection used to load and store the trained ALS model when `saveModel` is `true`. Defaults to `[app name]_recommender_models` if not set.",
      "hints": ["advanced"],
      "minLength": 1
    },
    "alwaysTrain": {
      "type": "boolean",
      "title": "Force model re-training",
      "description": "Controls whether the model is retrained even when an existing model with the same `modelId` is found. When `true`, training always runs. When `false`, an existing model is reused, saving compute time.",
      "default": true,
      "hints": ["advanced"]
    },
    "maxTrainingIterations": {
      "type": "integer",
      "title": "Maximum Training Iterations",
      "description": "Sets the maximum number of iterations for ALS matrix decomposition learning. More iterations generally improve model accuracy but increase training time. Convergence typically occurs well before the maximum is reached.",
      "default": 10,
      "hints": ["advanced"]
    },
    "trainingDataFilterQuery": {
      "type": "string",
      "title": "Training Data Filter Query",
      "description": "Filters the training data loaded from Solr using a standard Solr query, such as `type:click`. Use this to downsample data or select records meeting a minimum preference threshold before training.",
      "default": "*:*",
      "hints": ["advanced"]
    },
    "popularItemMin": {
      "type": "integer",
      "title": "Training Data Filter By Popular Items",
      "description": "Filters items from training data that have fewer than this many unique user interactions. Raising this value focuses the model on popular items but reduces the training set size.",
      "default": 2,
      "hints": ["advanced"],
      "minimum": 1,
      "exclusiveMinimum": false
    },
    "trainingSampleFraction": {
      "type": "number",
      "title": "Training Data Sampling Fraction",
      "description": "Sets the fraction of preference data to use for training, applied after any item popularity filtering. Values less than `1.0` downsample the dataset to speed up training at the cost of coverage.",
      "default": 1,
      "hints": ["advanced"],
      "maximum": 1,
      "exclusiveMaximum": false
    },
    "userIdField": {
      "type": "string",
      "title": "Training Collection User Id Field",
      "description": "Specifies the field in the training collection that contains user identifiers. Maps the `user_id_s` field by default. Change this when your collection uses a different user ID field name.",
      "default": "user_id_s",
      "hints": ["advanced"]
    },
    "itemIdField": {
      "type": "string",
      "title": "Training Collection Item Id Field",
      "description": "Specifies the field in the training collection that contains item identifiers. Maps the `item_id_s` field by default. Change this when your collection uses a different item ID field name.",
      "default": "item_id_s",
      "hints": ["advanced"]
    },
    "weightField": {
      "type": "string",
      "title": "Training Collection Weight Field",
      "description": "Specifies the field in the training collection that contains interaction weights or counts. Maps the `weight_d` field by default. Adjust this to match the actual weight or score field in your signals collection.",
      "default": "weight_d",
      "hints": ["advanced"]
    },
    "initialBlocks": {
      "type": "integer",
      "title": "Training Block Size",
      "description": "Sets the number of sub-matrix blocks used to partition training data for ALS computation. The default of `-1` enables automatic sizing. Increase for very large datasets to control memory usage per executor.",
      "default": -1,
      "hints": ["hidden"]
    },
    "trainingDataFrameConfigOptions": {
      "type": "object",
      "title": "Training DataFrame Config Options",
      "description": "Sets additional Spark DataFrame loading options as key-value pairs for the training data source. Use this to pass connector-specific options such as `zkHost` or `collection` when reading from non-default sources.",
      "properties": {},
      "additionalProperties": {
        "type": "string"
      },
      "hints": ["advanced"]
    },
    "initialRank": {
      "type": "integer",
      "title": "Recommender Rank",
      "description": "Sets the number of latent factors used in the ALS matrix decomposition, or the starting value for grid search. Higher values capture more complex user-item relationships but require more memory and compute time.",
      "default": 100,
      "hints": ["advanced"]
    },
    "initialAlpha": {
      "type": "number",
      "title": "Implicit Preference Confidence",
      "description": "Sets the confidence weight applied to implicit preference signals in ALS training, or the starting value for grid search. Higher values amplify the signal from observed interactions relative to unobserved ones.",
      "default": 50,
      "hints": ["advanced"]
    },
    "initialLambda": {
      "type": "number",
      "title": "Initial Lambda",
      "description": "Sets the regularization parameter to prevent overfitting during ALS training, or the starting value for grid search. Slightly larger values are recommended for small datasets to reduce variance.",
      "default": 0.01,
      "hints": ["advanced"]
    },
    "gridSearchWidth": {
      "type": "integer",
      "title": "Grid Search Width",
      "description": "Controls how many steps the parameter grid search explores around the initial ALS parameter values using exponential step sizes. Set to `0` to skip grid search. A value of `1` is a reasonable starting point.",
      "default": 0,
      "hints": ["advanced"]
    },
    "randomSeed": {
      "type": "integer",
      "title": "Random Seed",
      "description": "Sets the random seed used during ALS training to produce deterministic results across runs. Fix this value to reproduce identical model outputs when debugging or comparing configurations.",
      "default": 13,
      "hints": ["advanced"]
    },
    "itemMetadataFields": {
      "type": "array",
      "title": "Item Metadata Fields",
      "description": "Specifies the list of item metadata field names to include in recommendation output documents. Add fields such as `title` or `category` to enrich recommendations with item attributes.",
      "hints": ["advanced"],
      "items": {
        "type": "string"
      }
    },
    "itemMetadataCollection": {
      "type": "string",
      "title": "Item Metadata Collection",
      "description": "Specifies the Fusion collection or catalog asset ID containing item metadata to join with recommendation output. Leave blank to use only fields already present in the training collection.",
      "hints": ["advanced"]
    },
    "itemMetadataJoinField": {
      "type": "string",
      "title": "Item Metadata Join Field",
      "description": "Specifies the field used to join item metadata from `itemMetadataCollection` to recommendation output documents. This field must exist in both the training and metadata collections for the join to succeed.",
      "hints": ["advanced"]
    },
    "writeOptions": {
      "type": "array",
      "title": "Write Options",
      "description": "Sets additional key-value options passed to the Spark writer when writing output to Solr or other sinks. Use entries like `commitWithin=10000` to control Solr commit behavior.",
      "hints": ["advanced"],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "dataFormat": {
      "type": "string",
      "title": "Data format",
      "description": "Specifies the Spark-compatible format of the training data source, such as `solr`, `hdfs`, `file`, or `parquet`. This controls which Spark connector is used to load the training DataFrame.",
      "default": "solr",
      "hints": ["advanced"]
    },
    "type": {
      "type": "string",
      "title": "Spark Job Type",
      "enum": ["als_recommender"],
      "default": "als_recommender",
      "hints": ["readonly"]
    }
  },
  "additionalProperties": true,
  "category": "Other",
  "categoryPriority": 1,
  "propertyGroups": [{
    "label": "Input/Output Parameters",
    "properties": ["trainingCollection", "outputCollection", "outputUserRecsCollection", "outputItemSimCollection", "writeOptions"]
  }, {
    "label": "Model Tuning Parameters",
    "properties": ["numSims", "implicitRatings", "deleteOldRecs"]
  }, {
    "label": "Training Data Settings",
    "properties": ["trainingDataFilterQuery", "popularItemMin", "trainingSampleFraction", "userIdField", "itemIdField", "weightField", "maxIters", "trainingDataFrameConfigOptions", "initialBlocks"]
  }, {
    "label": "Model Settings",
    "properties": ["modelId", "saveModel", "modelCollection", "alwaysTrain"]
  }, {
    "label": "Grid Search Settings",
    "properties": ["initialRank", "gridSearchWidth", "initialAlpha", "initialLambda", "randomSeed"]
  }, {
    "label": "Item Metadata Settings",
    "properties": ["itemMetadataCollection", "itemMetadataJoinField", "itemMetadataFields"]
  }]
};

export const SchemaParamFields = ({schema}) => {
  const sanitize = str => {
    if (typeof str !== "string") return str;
    return str.replace(/^"(.*)"$/s, "$1").replace(/\\/g, "").replace(/"/g, "'");
  };
  const renderMd = str => {
    const s = sanitize(str);
    const text = (/[.!?]\)*$/).test(s) ? s : `${s}.`;
    return text.split(/(\*\*[^*]+\*\*|_[^_]+_|`[^`]+`)/g).map((part, i) => {
      if (part.startsWith("**")) return <strong key={i}>{part.slice(2, -2)}</strong>;
      if (part.startsWith("_")) return <em key={i}>{part.slice(1, -1)}</em>;
      if (part.startsWith("`")) return <code key={i}>{part.slice(1, -1)}</code>;
      return part;
    });
  };
  const {description, properties = {}, required: requiredProps = []} = schema;
  const visibleProps = useMemo(() => Object.entries(properties).filter(([, prop]) => !prop.hints?.includes("hidden")), [properties]);
  const renderProp = ([name, prop]) => {
    const isRequired = requiredProps.includes(name);
    const hasDefault = prop.default !== undefined;
    const rawDefault = prop.default;
    const hints = prop.hints || [];
    const isComplexDefault = hasDefault && (typeof rawDefault === "object" || typeof rawDefault === "string" && (rawDefault.length > 20 || rawDefault.includes('"')));
    const postBadges = [];
    if (prop.title) {
      postBadges.push(<><span className="text-stone-400 dark:text-stone-500">API property: </span>{name}</>);
    }
    const constraints = [];
    if (prop.minimum !== undefined && prop.maximum !== undefined) {
      constraints.push(`Range: ${prop.minimum} – ${prop.maximum}`);
    } else if (prop.minimum !== undefined) {
      constraints.push(`Min: ${prop.minimum}`);
    } else if (prop.maximum !== undefined) {
      constraints.push(`Max: ${prop.maximum}`);
    }
    if (prop.minLength !== undefined && prop.maxLength !== undefined) {
      constraints.push(`Length: ${prop.minLength} – ${prop.maxLength}`);
    } else if (prop.minLength !== undefined) {
      constraints.push(`Min length: ${prop.minLength}`);
    } else if (prop.maxLength !== undefined) {
      constraints.push(`Max length: ${prop.maxLength}`);
    }
    const fieldProps = {
      key: name,
      body: prop.title || name,
      type: prop.type,
      ...postBadges.length > 0 && ({
        post: postBadges
      }),
      ...isRequired && ({
        required: true
      }),
      ...!isComplexDefault && hasDefault ? {
        default: sanitize(String(rawDefault))
      } : {}
    };
    const isObject = prop.type === "object" && prop.properties;
    const isArrayOfObjects = prop.type === "array" && prop.items?.type === "object" && prop.items.properties;
    return <ParamField {...fieldProps}>
        {prop.description && <p>{renderMd(prop.description)}</p>}

        {prop.enum && <p>
            Allowed values: 
            {prop.enum.map((v, i) => <>{i > 0 && ", "}<code key={i}>{String(v)}</code></>)}
          </p>}

        {constraints.length > 0 && <p className="text-stone-500 dark:text-stone-400 text-sm">
            {constraints.join(" · ")}
          </p>}

        {isComplexDefault && <div className="flex">
            <p>
              <strong>Default:</strong>
            </p>
            <pre className="!my-0">
              <code>
                {JSON.stringify(rawDefault, null, 2)}
              </code>
            </pre>
          </div>}

        {isArrayOfObjects && <Expandable title="item properties">
            <SchemaParamFields schema={{
      properties: prop.items.properties,
      required: prop.items.required
    }} />
          </Expandable>}

        {isObject && <Expandable title="properties">
            <SchemaParamFields schema={{
      properties: prop.properties,
      required: prop.required
    }} />
          </Expandable>}
      </ParamField>;
  };
  return <div>
      {description && <p>{renderMd(description)}</p>}

      {visibleProps.map(renderProp)}
    </div>;
};

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

export const InlineImage = ({src, alt = '', height = '2em'}) => {
  return <img src={src} alt={alt} style={{
    display: 'inline',
    verticalAlign: 'start',
    height: height,
    margin: '0'
  }} />;
};

[localhost link]: http://localhost:3000/docs/5/fusion/reference/config-ref/jobs/als-recommender/overview

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/reference/config-ref/jobs/als-recommender/overview

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/561

Use this job when you want to compute user recommendations or item similarities using a collaborative filtering recommender. You can also implement a user-to-item recommender in the advanced section of this job’s configuration UI. This job uses [SparkML’s Alternating Least Squares (ALS)](https://spark.apache.org/docs/latest/ml-collaborative-filtering.html).

<Tip>
  **Important**

  This job is deprecated. Use the [BPR Recommender](/docs/5/fusion/reference/config-ref/jobs/bpr-recommender) instead.
</Tip>

|                      |                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Default job name** | `COLLECTION_NAME_item_recs`                                                                                                                                                                                                                                                                                                                                                                              |
| **Input**            | [Aggregated signals](/docs/5/fusion/reference/config-ref/jobs/aggregations/built-in-sql-aggregation-jobs) (the `COLLECTION_NAME_signals_aggr` collections by default)                                                                                                                                                                                                                                    |
| **Output**           | ● [Items-for-item recommendations](/docs/5/fusion/getting-data-out/query-enhancement/recommendations/items-for-item) (the `COLLECTION_NAME_items_for_item_recommendations` collection by default)<br />● [Items-for-user recommendations](/docs/5/fusion/getting-data-out/query-enhancement/recommendations/items-for-user) (the `COLLECTION_NAME_items_for_user_recommendations` collection by default) |

|                          | query | count\_i | type | timestamp\_tdt | user\_id | doc\_id | session\_id | fusion\_query\_id |
| ------------------------ | ----- | -------- | ---- | -------------- | -------- | ------- | ----------- | ----------------- |
| Required signals fields: |       | ✅        | ✅    | ✅              | ✅        | ✅       |             |                   |

The
`COLLECTION_NAME_user_item_prefs_agg`
job provides input data for this job and must run before it. See [Built-in SQL Aggregation Jobs](/docs/5/fusion/reference/config-ref/jobs/aggregations/built-in-sql-aggregation-jobs) for details.

This job assumes that your signals collection contains the preferences of many users. It uses this collection of preferences to predict another user’s preference about an item that the user has not yet seen. A preference which can be viewed as a triple: user, item, and interaction-value.

When you [enable recommendations](/docs/5/fusion/getting-data-out/query-enhancement/recommendations/getting-started) for a collection, Fusion automatically creates an ALS Recommender job called `COLLECTION_NAME_item_recommendations`. This job generates both [items-for-user recommendations](/docs/5/fusion/getting-data-out/query-enhancement/recommendations/items-for-user) and [items-for-item recommendations](/docs/5/fusion/getting-data-out/query-enhancement/recommendations/items-for-item#collaborative-items-for-item-recommendations), then stores the results in the `COLLECTION_NAME_items_for_user_recommendations` and `COLLECTION_NAME_items_for_item_recommendations` collections.

<LwTemplate />

## Basic job configuration

For items-for-item and items-for-user recommendations, the basic fields for configuring the `COLLECTION_NAME_item_recommendations` job are described below. To refine this job further, see [Advanced job configuration](#advanced-job-configuration).

* `numRecs`/**Number of User Recommendations to Compute**
  This is the number of recommendations that you want to return *per item* (for items-for-item recommendations) or *per user* (for items-for-user recommendations) in your dataset.\
  Increasing this number up to 1000 will not cost too much computationally because the intensive work of computing the matrix decomposition (involving optimization) is already done by the time these recommendations are generated.\
  Think of this as generating a matrix where the rows are the users and the columns are the recommendations. If we choose 1000 items to recommend, the size of the matrix will be `(number of users) x (number of items to recommend)`. For instance, if there are 10,000 users and 1000 recommendations, then the size of the matrix will be `10,000x1000`.

### Input/output parameters

* `trainingCollection`/**Recommender Training Collection**
  Usually this should point to the `COLLECTION_NAME_recs_aggr` collection. If you are using another aggregated signals collection, verify that this field points to the correct collection name.
* `outputItemSimCollection`/**Item-to-item Similarity Collection**
  Usually this should point to the\
  This collection will store the `N` most similar items for every item in the collection, where `N` is determined by the `numSims`/**Number of Item Similarities to Compute** field described below. Fusion can query this collection after the job to determine the most similar items to recommend based on an item choice.

  <Note>
    You can only specify a secondary collection of the collection with which this job is associated. For example, if you have a `Movies` collection and a `Films` collection and this job is associated with the `Movies` collection, then you cannot specify the `Films_items_for_item_recommendations` collection here.
  </Note>

### Model tuning parameters

* `numSims`/**Number of Item Similarities to Compute**
  This is similar to `numRecs`/**Number of User Recommendations to Compute** in the sense that this number of similar items are found for each item in the collection. Think of it as a matrix of size: `(number of items) x (number of item similarities to compute)`.\
  This is not computationally expensive because it is just a similarity calculation (which involves no optimization). A reasonable value would be 30–250. It will also depend on the number of items displayed in your search application.
* `implicitRatings`/**Implicit Preferences**
  The concept of Implicit preferences is explained in [Implicit vs explicit signals](/docs/5/fusion/getting-data-out/query-enhancement/signals/overview).\
  In this tutorial it is assumed that we submit no information about the items and the users (think of user and item features) but simply rely on the user-item interaction as a means to recommend similar products. That is the power of using implicit signals: we don’t need to know information about the user or the item, just how much they interact with each other.\
  If explicit ratings values are used (such as ratings from the user) then this box can be unchecked.
* `deleteOldRecs`/**Delete Old Recommendations**
  If you have reasons not to draw on old recommendations, then check this box. If this box is unchecked, then old recommendations will not be deleted but new recommendations will be appended with a different job ID. Both sets of recommendations will be contained within the same collection.

## Advanced job configuration

You can achieve higher accuracy, and often reduce the training time too, by tuning the `COLLECTION_NAME_item_recommendations` job using the advanced configuration keys described here. In the job configuration panel, click **Advanced** to display these additional fields.

* `excludeFromDeleteFilter`/**Exclude from Delete Filter**
  If you have selected `deleteOldRecs`/**Delete Old Recommendations** but you do not want to completely delete all old recommendations, this field allows you to input a query that captures the data you want keep and removes the rest.
* `numUserRecsPerItem`/**Number of Users to Recommend to each Item**
  This setting indicates which users (from the known user group) are most likely to be interested in a particular item. The setting allows you to choose how many of the most interested users you would like to precompute and store.\
  If one thinks of an estimated user-item matrix (after optimization), an item is a single column from the matrix, so if we wanted the top 100 users per item, we would sort the interest values in that column in descending order and take the top 100 row indexes which would correspond to individual users.
* `maxTrainingIterations`/**Maximum Training Iterations**
  The Alternating Least Squares algorithm involves optimization to find the two matrices `(user x latent factor and latent factor x item)` that best approximate the original user-item matrix (formed from the signals aggregation).\
  The optimization occurs at the matrix entry level (every non-zero element) and it is iterative. Therefore, the more iterations that are allowed during optimization, the lower the cost function value, meaning more accurate hyperparameters which lead to better recommendations.\
  However, the bigger the data, the longer the job takes to run because the number of constraints to satisfy have increased. A value of 10 iterations usually leads to effective results. Above a value of 15, the job will begin to slow dramatically for above 25 million signals.

### Training data settings

* `trainingDataFilterQuery`/**Training Data Filter Query**
  This query setting is useful when the main signals collection does not have the [recommended fields](/docs/5/fusion/getting-data-out/query-enhancement/signals/overview). The two most important fields are `doc_id` and `user_id` because the job must have a user-item pairing. Note that depending on how the signals are collected the names `doc_id` and `user_id` can be different, but the concept remains the same.\
  There are times when not all the signals have these fields. In this case we can add a query to select a subset of data that does have a user-item pairing. It is done with the following query:

  ```
  +doc_id:[* TO *] +user_id:[* TO *]
  ```

  This query returns all signals documents that have a `user_id` and `doc_id` field. Each query is separated by a space. The plus (`+`) sign is a positive request for the field of interest, meaning return signals with `doc_id` instead of signals without `doc_id` (negated or opposite queries are returned by prefixing with a negative (`-`) sign).
* `popularItemMin`/**Training Data Filter By Popular Items**
  The underlying assumption of this parameter is that the more users that view an item, the more popular that item is. Therefore, this value signifies the minimum number of interactions that must occur with the item for it to be considered a training data point.\
  The higher the number, the smaller amount of data available for training because it is unlikely that many users interacted with all of the items. However, the quality of the data will be higher.\
  One way to speed up training is to increase this number along with the training data sampling fraction. A reasonable number is between 10 and 20 depending on the application and user base. For instance, a song may be played much more than a movie and both may have more interaction than purchasing an item.
* `trainingSampleFraction`/**Training Data Sampling Fraction**
  This value is the percentage of the signal data or training data that you want to use for training the recommender job. It is advised to set this value to 1 and reduce the training data size (while increasing quality) by increasing the **Training Data Filter By Popular Items** as well as increasing the weight threshold in the **Training Data Filter Query**.
* `userIdField`/**Training Collection User Id Field**
  The ALS algorithm needs users, items, and a score of their interaction. The user ID field is the field name within the signal data that represents a user ID.
* `itemIdField`/**Training Collection Item Id Field**
  The item ID field is the field name within the aggregated signal data that represents the item or documents of interest.
* `weightField`/**Training Collection Weight Field**
  The weight field contains the score representing the interest of the user in an item.
* `initialBlocks`/**Training Block Size**
  In [Spark](/docs/5/fusion/intro/machine-learning/overview), the training data is split amongst the executors in unchangeable blocks. This parameter sets the size of these blocks for training, but it requires advanced knowledge of Spark internals. We recommend leaving this setting at -1.

### Model settings

* `modelId`/**Recommender Model ID**
  The **Recommender Model ID** is assigned the field `modelId` in the `COLLECTION_NAME_items_for_item_recommendations` and `COLLECTION_NAME_items_for_user_recommendations` recommendations collections. This allows you to filter the recommendations by the recommender model ID. When the recommender job runs, a job ID is also assigned; therefore, you can see the results from different runs of the same job parameters. If you want to experiment with different parameters, it is advised to change the recommender model ID to reflect the parameters so that you can find the best parameters.
* `saveModel`/**Save Model in Solr**
  Saving the model in Solr adds the parameters to the `COLLECTION_NAME_recommender_models` collection as a document. Using this method allows you to track all the recommender configurations.
* `modelCollection`/**Model Collection**
  This is the collection to store the experiment configurations (`_recommender_models` by default).
* `alwaysTrain`/**Force model re-training**
  When the job runs, it checks to see whether the model ID for the job already exists in the model collection. If the model does exist, it uses the pre-existing model to get the recommendations. Otherwise, if the box is checked it will re-run the recommender job and redo the optimization from scratch. Unless you need to maintain this ID name, it is advisable to create a separate model ID for each new combination of parameters.

### Grid search settings

* `initialRank`/**Recommender Rank**
  The recommender rank is the number of latent factors into which to decompose the original user-item matrix. A reasonable range is 50-200. Above 200, the performance of the optimization can degrade dramatically depending on computing resources.
* `gridSearchWidth`/**Grid Search Width**
  Grid search is an automatic way to determine the best parameters for the recommender model. It tries different combinations of parameters of equally spaced units within a parameter domain and takes the model that has the lowest cost function value. This is a long process because a single run can take several hours depending on the computing resources, so trying multiple combinations can take some time. Depending on the size of your training data, it is better to do a manual grid search to reduce the number of runs needed to find a suitable recommender model.
* `initialAlpha`/**Implicit Preference Confidence**
  The implicit preference confidence is an approximation of how confident you are that the implicit data does indeed represent an accurate level of interest of a user in an item. Typical values are 1-100, with 100 being more confident in the training data representing the interest of the user. This parameter is used as a regularizer for optimization. The higher the confidence value, the more the optimization is penalized for a wrong approximation of the interest value.
* `initialLambda`/**Initial Lambda**
  Lambda is another optimization parameter that prevents overfitting. Remember we are decomposing the user-item matrix by estimating two matrices. The values in these matrices can be any number, large or small, and have a wide spread in the values themselves. To keep the scale of the value consistent or reduce the spread of the values, we use a regularizer. The higher the lambda, the smaller the values in the two estimated matrices. A smaller lambda gives the algorithm more freedom to estimate an answer which can result in overfitting. Typical values are between 0.01 and 0.3.
* `randomSeed`/**Random Seed**
  When the two matrices are first being estimated, their values are set randomly as an initialization. As the optimization proceeds the values are changed according to the error in the optimization. When training it is important to keep the initialization the same in order to determine the effect of different values of parameters in the model. Keep this value the same across all experiments.

### Item metadata settings

* `itemMetadataCollection`/**Item Metadata Collection**
  The main collection has very detailed information about each item, much of which is not necessary for training the recommender system. All that is important to train the recommender are the document IDs and the known users. If you have this metadata in a different collection than the main collection, enter that collection’s name here. Once the training is complete, the document ID of the relevant documents can be used to retrieve detailed information from the item catalog. The point is to train on small data per item and retrieve the detailed information for only relevant documents.
* `itemMetadataJoinField`/**Item Metadata Join Field**
  This is the field that is common to the aggregated signal data and the original data. It is used to join each document from the recommender collection to the original item in the main collection. Usually this is the `id` field.
* `itemMetadataFields`/**Item Metadata Fields**
  These are fields from the main collection that should be returned with each recommendation. You can add fields here by clicking the **Add** <InlineImage src="/assets/images/4.0/icons/add-icon.png" /> icon. To ensure that this works correctly, verify that `itemMetadataJoinField`/**Item Metadata Join Field** has the correct value.

<SchemaParamFields schema={schema} />
