> ## 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.

# Lucidworks AI Vectorize Field

> Lucidworks AI

export const schema = {
  "type": "object",
  "title": "LWAI Vectorize Field",
  "description": "Invokes a Lucidworks AI model to encode a string field to a vector representation. Will be skipped if the field to encode doesn't exist or is null on the pipeline document.",
  "required": ["accountName", "modelType", "sourceFieldName", "destinationFieldName"],
  "properties": {
    "skip": {
      "type": "boolean",
      "title": "Skip This Stage",
      "description": "Set to true to skip this stage.",
      "default": false,
      "hints": ["advanced"]
    },
    "label": {
      "type": "string",
      "title": "Label",
      "description": "A unique label for this stage.",
      "hints": ["advanced"],
      "maxLength": 255
    },
    "condition": {
      "type": "string",
      "title": "Condition",
      "description": "Define a conditional script that must result in true or false. This can be used to determine if the stage should process or not.",
      "hints": ["code", "code/javascript", "advanced"]
    },
    "accountName": {
      "type": "string",
      "title": "Account Name",
      "description": "Lucidworks AI API Account Name as defined in Lucidworks AI Gateway Service.  This entry should match the account name set in the LWAI Gateway.",
      "hints": ["enumUrl:/api/query-stages/lwai-accounts"]
    },
    "modelType": {
      "type": "string",
      "title": "Model",
      "description": "Lucidworks AI API model to use for encoding.",
      "hints": ["enumUrl:/api/query-stages/lwai-model?account=${accountName}&useCase=embedding"]
    },
    "sourceFieldName": {
      "type": "string",
      "title": "Source Field",
      "description": "Name of the string field whose value should be submitted to the model for encoding. If the field doesn't exist or is null in the pipeline document, this stage will be skipped.  Supports Template Expressions, e.g. <doc.title_t> and <ctx.myVar>."
    },
    "destinationFieldName": {
      "type": "string",
      "title": "Destination Field",
      "description": "Name of the field into which the dense vector value from the model response will be saved."
    },
    "useCaseConfig": {
      "type": "array",
      "title": "Use Case Configuration",
      "default": [{
        "key": "dataType",
        "value": "passage"
      }],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "modelConfig": {
      "type": "array",
      "title": "Model Configuration",
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "failOnError": {
      "type": "boolean",
      "title": "Fail on Error",
      "description": "Flag to indicate if this stage should throw an exception if an error occurs while generating a prediction for a document.",
      "default": false
    }
  },
  "category": "AI",
  "categoryPriority": 10,
  "unsafe": false
};

export const SchemaParamFields = ({schema}) => {
  const sanitize = str => {
    if (typeof str !== "string") return str;
    return str.replace(/^"(.*)"$/s, "$1").replace(/\\/g, "").replace(/"/g, "'");
  };
  const formatDescription = str => {
    const s = sanitize(str);
    return (/[.!?]\)*$/).test(s) ? s : `${s}.`;
  };
  const {description, properties = {}, required: requiredProps = []} = schema;
  const visibleProps = useMemo(() => Object.entries(properties).filter(([, prop]) => !prop.hints?.includes("hidden")), [properties]);
  return <div>
      {description && <p>{formatDescription(description)}</p>}

      {visibleProps.map(([name, prop]) => {
    const isRequired = requiredProps.includes(name);
    const hasDefault = prop.default !== undefined;
    const rawDefault = prop.default;
    const isComplexDefault = hasDefault && (typeof rawDefault === "object" || typeof rawDefault === "string" && (rawDefault.length > 20 || rawDefault.includes('"')));
    const fieldProps = {
      key: name,
      body: prop.title || name,
      type: prop.type,
      ...prop.title && ({
        post: [<><span className="text-stone-400 dark:text-stone-500">API property: </span>{name}</>]
      }),
      ...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>{formatDescription(prop.description)}</p>}

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

            {isArrayOfObjects && <div className="flex">
              <p>
                <strong>Object attributes:</strong>
              </p>
              <pre className="!my-0">
                <code>
                  {'{\n'}
                  {Object.entries(prop.items.properties).map(([iname, iprop]) => <>
                      {`  ${iname}`}
                      {prop.items?.required?.includes(iname) && <span style={{
      color: 'red'
    }}> required</span>}
                      {`: {\n    display name: ${sanitize(iprop.title || '')}\n    type: ${iprop.type}\n  }\n`}
                    </>)}
                  {'}'}
                </code>
              </pre>
              </div>}

            {isObject && <Expandable title="properties">
                <SchemaParamFields schema={{
      properties: prop.properties,
      required: prop.required
    }} />
              </Expandable>}
          </ParamField>;
  })}
    </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>;
};

[localhost link]: http://localhost:3000/docs/lw-platform/lw-ai/lw-ai-stages/vectorize-field-via-lucidworks-ai-index-stage

[mintlify link]: https://doc.lucidworks.com/docs/lw-platform/lw-ai/lw-ai-stages/vectorize-field-via-lucidworks-ai-index-stage

[old doc.lw link]: https://doc.lucidworks.com/lw-platform/ai/4h364i

LWAI Vectorize Field is a Fusion index pipeline stage that invokes a Lucidworks AI model to encode a string field to a vector representation.

<iframe src="https://app.supademo.com/embed/cmi66hg6y3oj6b7b4pd6zorc5?embed_v=2&utm_source=embed" loading="lazy" title="Configure LWAI Vectorize Field Index stage" allow="clipboard-write" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen style={{  width: '100%', height: '500px' }} />

To process documents in batches in Fusion 5.9.15 and later, use the [LWAI Batch Vectorize index stage](/docs/lw-platform/lw-ai/lw-ai-stages/batch-vectorize-field-via-lucidworks-ai-index-stage).

To use this stage, non-admin Fusion users must be granted the `PUT,POST,GET:/LWAI-ACCOUNT-NAME/**` permission in Fusion, which is the Lucidworks AI API Account Name defined in [Lucidworks AI Gateway](/docs/lw-platform/lw-ai/lw-ai-gateway) when this stage is configured.

For additional details about configuration, see the [APIs](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/overview).

<Accordion title="Configure Neural Hybrid Search">
  {/* // tag::intro[] */}

  Neural Hybrid Search combines lexical-semantic search with semantic vector search.

  {/* // end::intro[] */}

  To use semantic vector search in Fusion, you need to configure Neural Hybrid Search.
  Then you can choose the balance between lexical and semantic vector search that works best for your use case.

  Before you begin, see [Neural Hybrid Search](/docs/5/fusion/hybrid-search/overview) for conceptual information that can help you understand how to configure this feature.

  <Check>This feature is currently only available to clients who have contracted with Lucidworks for features related to Neural Hybrid Search and Lucidworks AI.</Check>

  <Note>This feature is available starting in Fusion 5.9.5 and in all subsequent Fusion 5.9 releases.</Note>

  Lucidworks recommends setting up Neural Hybrid Search with Lucidworks AI, but you can instead use Ray or Seldon vector search. If using Lucidworks AI, you may use the default LWAI Neural Hybrid Search pipeline.

  <LwTemplate />

  ## Configure vector search

  This section explains how to configure vector search using Lucidworks AI, but you can also configure it using Ray or Seldon.

  Before you set up the Lucidworks AI index and query stages, make sure you have set up your Lucidworks AI Gateway integration.

  ### Configure the LWAI Vectorize Field index stage

  To vectorize the index pipeline fields:

  1. Sign in to Fusion and click **Indexing > Index Pipelines**.
  2. Click the pipeline you want to use.
  3. Click **Add a new pipeline stage**.
  4. In the AI section, click **LWAI Vectorize Field**.
  5. In the **Label** field, enter a unique identifier for this stage.
  6. In the **Condition** field, enter a script that results in true or false, which determines if the stage should process.
  7. In the **Account Name** field, select the Lucidworks AI API account name defined in the Lucidworks AI Gateway service.

     If you do not see your account name, check that your Lucidworks AI Gateway integration is correctly configured.
  8. In the **Model** field, select the Lucidworks AI model to use for encoding.

     If you do not see any models names and you are a non-admin Fusion user, check that you have these permissions: `PUT,POST,GET:/LWAI-ACCOUNT-NAME/**`

     Your Fusion account name must match the name of the account that you selected in the **Account Name** dropdown.

     For more information about models, see:

     * [Pre-trained embedding models](/docs/lw-platform/lw-ai/lw-ai-pre-trained-embedding-models)
     * [Custom embedding model training](/docs/lw-platform/lw-ai/lw-ai-custom-embedding-model-training/overview)
  9. In the **Source** field, enter the name of the string field where the value should be submitted to the model for encoding. If the field is blank or does not exist, this stage is not processed. Template expressions are supported.
  10. In the **Destination** field, enter the name of the field where the vector value from the model response is saved.

      {/* // tag::lwai-prediction-query-stage[] */}

      If a value is entered in this field, the following information is added to the document:

      * `{Destination Field}` is the vector field.
      * `{Destination Field}_b`  is the boolean value if the vector has been indexed.

      {/* // end::lwai-prediction-query-stage[] */}
  11. In the **Use Case Configuration** section, click the **+** sign to enter the parameter name and value to send to Lucidworks AI. The `useCaseConfig` parameter that is common to embedding use cases is `dataType`, but each use case may have other parameters. The value for the query stage is `query`.
  12. Optionally, you can use the **Model Configuration** section for any additional parameters you want to send to Lucidworks AI.
      Several `modelConfig` parameters are common to generative AI use cases.
      For more information, see [Prediction API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/overview).
  13. Select the **Fail on Error** checkbox to generate an exception if an error occurs while generating a prediction for a document.
  14. Click **Save**.
  15. Index data using the new pipeline. Verify the vector field is indexed by confirming the field is present in documents.

  For reference information, see [Lucidworks AI Vectorize Field](/docs/lw-platform/lw-ai/lw-ai-stages/vectorize-field-via-lucidworks-ai-index-stage).

  ### Configure the LWAI Vectorize Query stage

  To vectorize the query in the query pipeline:

  1. Sign in to Fusion and click **Querying > Query Pipelines**.
  2. Select the pipeline you want to use.
  3. Click **Add a new pipeline stage**.
  4. Click **LWAI Vectorize Query**.
  5. In the **Label** field, enter a unique identifier for this stage.
  6. In the **Condition** field, enter a script that results in true or false, which determines if the stage should process.
  7. Select **Asynchronous Execution Config** if you want to run this stage asynchronously. If this field is enabled, complete the following fields:
     1. Select **Enable Async Execution**. Fusion automatically assigns an **Async ID** value to this stage.  Change this to a more memorable string that describes the asynchronous stages you are merging, such as `signals` or `access_control`.
     2. Copy the **Async ID** value.

        <Note>      For detailed information, see [Asynchronous query pipeline processing](/docs/5/fusion/getting-data-out/query-basics/query-pipelines/overview).</Note>
  8. In the **Account Name** field, select the name of the Lucidworks AI account.
  9. In the **Model** field, select the Lucidworks AI model to use for encoding.

     If you do not see any model names and you are a non-admin Fusion user, verify with a Fusion administrator that your user account has these permissions: `PUT,POST,GET:/LWAI-ACCOUNT-NAME/**`

     Your Fusion account name must match the name of the account that you selected in the **Account Name** dropdown.

     For more information about models, see:

     * [Pre-trained embedding models](/docs/lw-platform/lw-ai/lw-ai-pre-trained-embedding-models)
     * [Custom embedding model training](/docs/lw-platform/lw-ai/lw-ai-custom-embedding-model-training/overview)
  10. In the **Query Input** field, enter the location from which the query is retrieved.
  11. In the **Output context variable** field, enter the name of the variable where the vector value from the response is saved.
  12. In the **Use Case Configuration** section, click the **+** sign to enter the parameter name and value to send to Lucidworks AI. The `useCaseConfig` parameter that is common to embedding use cases is `dataType`, but each use case may have other parameters. The value for the query stage is `query`.
  13. Optionally, you can use the **Model Configuration** section for any additional parameters you want to send to Lucidworks AI.
      Several `modelConfig` parameters are common to generative AI use cases.
      For more information, see [Prediction API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/overview).
  14. Select the **Fail on Error** checkbox to generate an exception if an error occurs during this stage.
  15. Click **Save**.

  <Note>
    The **Top K** setting is 100 by default, but a value as high as 1000 provides better recall if you have fewer than one million indexed documents.
    You can raise it even higher, but keep in mind that higher recall also causes higher latency.\
    When raising this value, we recommend also setting a higher **Min Return Vector Similarity** value, in the 0.7-0.85 range.
  </Note>

  This query stage must be placed *before* the **[Solr Query stage](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/solr-query-stage)**.

  <Warning>
    **Using additional pipeline stages**

    For optimal vector search functionality, use the following stages in the order specified: either the LWAI Vectorize Query or Ray/Seldon Vectorize Field, Query Fields (if present), Neural Hybrid Query, and Solr Query. Other stages can be used, but must be placed in the correct processing order in relation to these stages.
  </Warning>

  ## Modify Solr managed-schema (5.9.4 and earlier)

  This step is required if you’re migrating a collection from a version of Fusion that does not support Neural Hybrid Search. If creating a new collection in Fusion 5.9.5 and later, you can continue to [Configure Hybrid Query stage](#configure-neural-hybrid-queries).

  1. Go to **System** > **Solr Config** and then click **managed-schema** to edit it.
  2. Comment out `<copyField dest="\_text_" source="*"/>` and add `<copyField dest="text" source="*_t"/>` below it. This will concatenate and index all `*_t fields`.
  3. Add the following code block to the **managed-schema** file:

     ```xml theme={"dark"}
     <fieldType class="solr.DenseVectorField" hnswBeamWidth=“200"
         hnswMaxConnections="45” name="knn_DIM_vector" similarityFunction="cosine"
         vectorDimension="DIM"/>
     <dynamicField docValues="false" indexed="true" multiValued="false" name="*_512v"
           required="false" stored="true" type="knn_DIM_vector"/>
     ```

     <Note>   This example uses 512 vector dimension. If your model uses a different dimension, modify the code block to match your model. For example, `_1024v`. There is no limitation on supported vector dimensions.</Note>

  ## Configure neural hybrid queries

  In Fusion 5.9.10 and later, you use the Neural Hybrid Query stage to configure neural hybrid queries.
  In Fusion 5.9.9 and earlier, you use the Hybrid Query stage.

  ### Configure Neural Hybrid Query stage (5.9.10 and later)

  1. In the same query pipeline where you configured vector search, click **Add a new pipeline stage**, then select **Neural Hybrid Query**.

  {/* // tag::configure-neural-hybrid-queries[] */}

  2. In the **Label** field, enter a unique identifier for this stage or leave blank to use the default value.

  3. In the **Condition** field, enter a script that results in true or false, which determines if the stage should process, or leave blank.

  4. In the **Lexical Query Input** field, enter the location from which the lexical query is retrieved. For example, **\<request.params.q>**. Template expressions are supported.

  5. In the **Lexical Query Weight** field, enter the relative weight of the lexical query. For example, **0.3**. If this value is **0**, no re-ranking will be applied using the lexical query scores.

  6. In the **Lexical Query Squash Factor** field, enter a value that will be used to squash the lexical query score.

     The squash factor controls how much difference there is between the top-scoring documents and the rest.
     It helps ensure that documents with slightly lower scores still have a chance to show up near the top.
     For this value, Lucidworks recommends entering the inverse of the lexical maximum score across all queries for the given collection.

  7. In the **Vector Query Field**, enter the name of the Solr field for k-nearest neighbor (KNN) vector search.

  8. In the **Vector Input** field, enter the location from which the vector is retrieved. Template expressions are supported. For example, a value of `<ctx.vector>` evaluates the context variable resulting from a previous stage, such as the [LWAI Vectorize Query](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/lwai-vectorize-query) stage.

  9. In the **Vector Query Weight** field, enter the relative weight of the vector query. For example, **0.7**.

  10. In the **Min Return Vector Similarity** field, enter the minimum vector similarity value to qualify as a match from the Vector portion of the hybrid query.

  11. In the **Min Traversal Vector Similarity** field, enter the minimum vector similarity value to use when walking through the graph during the Vector portion of the hybrid query.

  12. When enabled, the **Compute Vector Similarity for Lexical-Only Matches** setting computes vector similarity scores for documents in lexical search results but not in the initial vector search results. Select the checkbox to enable this setting.

  13. If you want to use pre-filtering:
      1. Uncheck **Block pre-filtering**.

         In the Javascript context (`ctx`), the `preFilterKey` object becomes available.
      2. Add a [Javascript stage](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/javascript-query-stage) *after* the Neural Hybrid Query stage and use it to configure your pre-filter.

         The `preFilter` object adds both the top-level `fq` and `preFilter` to the parameters for the vector query.
         You do not need to manually add the top level `fq` in the javascript stage.
         See the example below:

         ```js theme={"dark"}
         var QueryRequestAndResponse = Java.type('com.lucidworks.apollo.pipeline.query.QueryRequestAndResponse');
         if(ctx.hasProperty("preFilterKey")) {
           var preFilter = ctx.getProperty("preFilterKey");
           var wrapper = QueryRequestAndResponse.create(request,response,0)
           preFilter.addFilter(wrapper, 'id:* OR foo_s:bar');
         }
         ```

  14. Click **Save**.

  {/* // end::configure-neural-hybrid-queries[] */}

  Make sure the **Hybrid Query** stage is ordered before the **Solr Query** stage.

  Be aware that the Neural Hybrid Query stage uses new query parsers, so if you are *not* setting up a new collection, the following must be added to `solrconfig.xml` within the `<config>` tag:

  ```xml theme={"dark"}
  <!-- FUSION NOTES: These query parsers are used with Solr-based vector search -->
  <queryParser name="xvecSim" class="org.apache.solr.lwbackported.XVecSimQParserPlugin"/>
  <queryParser name="neuralHybrid" class="org.apache.solr.lw.NeuralHybridQParserPlugin"/>
  ```

  ### Configure Hybrid Query stage (5.9.9 and earlier)

  If you’re setting up Neural Hybrid Search in Fusion 5.9.9 and earlier, use the Hybrid Query stage.
  If you’re using Fusion 5.9.10 or later, use the [Neural Hybrid Query stage](#configure-neural-hybrid-queries).

  1. In the same query pipeline where you configured vector search, click **Add a new pipeline stage**, then select **Hybrid Query**.

  {/* // tag::configure-hybrid-query-stage[] */}

  2. In the **Label** field, enter a unique identifier for this stage or leave blank to use the default value.
  3. In the **Condition** field, enter a script that results in true or false, which determines if the stage should process, or leave blank.
  4. In the **Lexical Query Input** field, enter the location from which the lexical query is retrieved. For example, **\<request.params.q>**. Template expressions are supported.
  5. In the **Lexical Query Weight** field, enter the relative weight of the lexical query. For example, **0.3**. If this value is **0**, no re-ranking will be applied using the lexical query scores.
  6. In the **Number of Lexical Results** field, enter the number of lexical search results to include in re-ranking. For example, **1000**. A value is **0** is ignored.
  7. In the **Vector Query Field**, enter the name of the Solr field for k-nearest neighbor (KNN) vector search.
  8. In the **Vector Input** field, enter the location from which the vector is retrieved. Template expressions are supported. For example, a value of `<ctx.vector>` evaluates the context variable resulting from a previous stage, such as the [LWAI Vectorize Query](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/lwai-vectorize-query) stage.
  9. In the **Vector Query Weight** field, enter the relative weight of the vector query. For example, **0.7**.
  10. Select the **Use KNN Query** checkbox to use the **knn** query parser and configure its options. This option cannot be selected if **Use VecSim Query** checkbox is selected. In addition, **Use KNN Query** is used if neither **Use KNN Query** or **Use VecSim Query** is selected.
      1. If the **Use KNN Query checkbox** is selected, enter a value in the **Number of Vector Results** field. For example, **1000**.
  11. Select the **Use VecSim Query** checkbox to use the **vecSim** query parser and configure its options. This option cannot be selected if **Use KNN Query** checkbox is selected.\
      If the **Use VecSim Query** checkbox is selected, enter values in the following fields:

      * **Min Return Vector Similarity**. Enter the minimum vector similarity value to qualify as a match from the Vector portion of the hybrid query.
      * **Min Traversal Vector Similarity**. Enter the minimum vector similarity value to use when walking through the graph during the Vector portion of the hybrid query. The value must be lower than, or equal to, the value in the Min Return Vector Similarity field.
  12. In the **Minimum Vector Similarity Filter**, enter the value for a minimum similarity threshold for filtering documents. This option applies to all documents, regardless of other score boosting such as rules or signals.
  13. Click **Save**.

  {/* // end::configure-hybrid-query-stage[] */}

  Make sure the **Hybrid Query** stage is ordered before the **Solr Query** stage.

  ## Perform hybrid searches

  After setting up the stages, you can perform hybrid searches via the [`knn` query parser](https://solr.apache.org/guide/solr/latest/query-guide/dense-vector-search.html#knn-query-parser) as you would with Solr.
  Specify the search vector and include it in the query.
  For example, change the `q` parameter to a `knn` query parser string.

  You can also preview the results in the [Query Workbench](/docs/5/fusion/getting-data-out/query-basics/query-workbench).
  Try a few different queries, and adjust the weights and parameters in the Hybrid Query stage to find the best balance between lexical and semantic vector search for your use case.
  You can also disable and re-enable the Neural Hybrid Query stage to compare results with and without it.

  <Note>`XDenseVectorField` is not supported in Fusion 5.9.5 and above. Instead, use `DenseVectorField`.</Note>

  ## Troubleshoot inconsistent results

  Neural Hybrid Search leverages Solr semantic vector search, which has known behaviors which can be inconsistent at query time.
  These behaviors include score fluctuations with re-querying, documents showing and disappearing on re-querying, and (when SVS is configured without Hybrid stages) completely unfindable documents.
  This section outlines possible reasons for inconsistent behavior and resolutions steps.

  ### NRT replicas and HNSW graph challenges

  Lucidworks recommends using PULL and TLOG replicas. These replica types copy the index of the leader replica, which results in the same HNSW graph on every replica. When querying, the HNSW approximation query will be consistent given a static index.

  In contrast, NRT replicas have their own index, so they will also have their own HNWS graph. HNSW is an Approximate Nearest Neighbor (ANN) algorithm, so it will not return exactly the same results for differently constructed graphs. This means that queries performed can and will return different results per HNWS graph (number of NRT replicas in a shard) which can lead to noticeable result shifts. When using NRT replicas, the shifts can be made less noticeable by increasing the `topK` parameter. Variation will still occur, but it should be lower in the documents. Another way to mitigate shifts is to use Neural Hybrid Search with a vector similarity cutoff.

  For more information, refer to [Solr Types of Replicas](https://solr.apache.org/guide/solr/latest/deployment-guide/solrcloud-shards-indexing.html#types-of-replicas).

  In the case of Neural Hybrid Search, lexical BM25 & TF-IDF score differences that can occur with NRT replicas because of index differences for deleted documents, can also affect combined [Hybrid score](/docs/5/fusion/hybrid-search/overview).
  If you choose to use NRT replicas then it is possible that any lexical and/or semantic vectors variations can and will be exacerbated.

  ### Orphaning (Disconnected Nodes)

  Solr’s implementation of dense vector search depends on the Lucene implementation of HNSW ANN.
  The Lucene implementation has a known issue where, in some collections, nodes in the HNSW graph become unreachable via graph traversal, essentially becoming disconnected or “orphaned.”

  #### Identify orphaning

  Run the following command to identify orphaning:

  ```bash theme={"dark"}
  curl -sS -u 'USERNAME:PASSWORD' 'https://FUSION_HOST:FUSION_PORT/api/solrAdmin/default/COLLECTION_NAME/select'\
    --form-string 'fl=id,vecSim:$vecSim' \
    --form-string 'rows=1' \
    --form-string 'q=(*:* -{!knn f=VECTOR_FIELD topK=999999 v=$vec})' \
    --form-string 'vecSim=vectorSimilarity(VECTOR_FIELD,$vec)' \
    --form-string 'vec=COMPATIBLE_VECTOR'
  ```

  <Note>If the collection doesn’t have a vector for every document, include a filter so only the documents that have vectors are included. Filter on the boolean vector, as in this example:  `--form-string 'fq=VECTOR_FIELD_b:true' \`</Note>

  Construct a KNN exclusion query where topK is higher than the number of vectors in your collection
  If the number of vectors in your collection exceeds 999,999 then increase the value to be at least equal to that value.

  If any are documents returned, there are orphans, and the `ids` you see are the orphans.
  Proceed to [Resolving orphans](#resolving-orphans).
  If no documents are returned, there are likely no orphans.
  You can try a few varying vectors to be certain.

  {/* [#resolve] */}

  #### Resolving orphans

  To resolve orphans, do the following:

  1. Increase the HNSW Solr schema parameters `hnswBeamWidth` and `hnswMaxConnections` per the [Suggested values](#suggested-values) below.
  2. Save the schema.
  3. Clear the index.
  4. Re-index your collection.

  {/* [#suggested] */}

  ##### Suggested values

  | Orphaning rate | `hnswBeamWidth` | `hnswMaxConnections` |
  | -------------- | --------------- | -------------------- |
  | 5% or less     | 300             | 64                   |
  | 5% - 25%       | 500             | 100                  |
  | 25% or more    | 3200            | 512                  |
</Accordion>

## Configurable vector quantization method

In Fusion 5.9.13 and later, you can configure the vector quantization method.
Quantization converts high-precision float vectors into compact 8-bit integer vectors, significantly lowering storage and compute costs.
By default, no quantization is performed; you enable it by selecting a method.

To select the quantization method, go to **Model Configuration** in the stage configuration and enter the `vectorQuantizationMethod` parameter with the value for the desired method:

<Frame>
  <img src="https://mintcdn.com/lucidworks/QpNF2ZqMixUmoHvm/assets/images/5.9/vector-quantization-method-config.png?fit=max&auto=format&n=QpNF2ZqMixUmoHvm&q=85&s=29cf6e862c230bc924b0bc196b13704a" alt="Vector quantization method configuration in an LWAI pipeline stage" width="1508" height="318" data-path="assets/images/5.9/vector-quantization-method-config.png" />
</Frame>

Available methods are:

* `min-max` creates tensors of embeddings and converts them to uint8 by normalizing them to the range \[0, 255].\
  This method loses precision when evaluated against non-quantized vectors.\
  Test it against your data to see if the loss is acceptable.
* `max-scale` finds the maximum absolute value along each embedding, normalizes the embeddings by scaling them to a range of -127 to 127, and returns the quantized embeddings as an 8-bit integer tensor.\
  This method has no loss at the ten-thousandths place during evaluation against non-quantized vectors.

## Matryoshka vector dimension reduction configuration

Vector dimension reduction is the process of making the default vector size of a model smaller. The purpose of this reduction is to lessen the burden of storing large vectors while still achieving the good quality of a larger model.

The technique is called [Matryoshka Representation Learning (MRL)](https://sbert.net/examples/training/matryoshka/README.html) and lets you reduce vector size while maintaining good quality.

To select the vector dimension reduction method, go to **Model Configuration** in the stage configuration and enter the `dimReductionSize` parameter with the value for the desired method:

<img src="https://mintcdn.com/lucidworks/QpNF2ZqMixUmoHvm/assets/images/5.9/dim-reduction-size-config.png?fit=max&auto=format&n=QpNF2ZqMixUmoHvm&q=85&s=269bc321a104ddf5eb0b06925f6063a6" alt="Matryoshka vector dimension reduction configuration in an LWAI pipeline stage" width="1518" height="314" data-path="assets/images/5.9/dim-reduction-size-config.png" />

The value allows any integer above 0, but less than or equal to the vector dimension of the model.

## Configuration

<Tip>
  When entering configuration values in the UI, use *unescaped* characters, such as `\t` for the tab character. When entering configuration values in the API, use *escaped* characters, such as `\\t` for the tab character.
</Tip>

<SchemaParamFields schema={schema} />
