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

# attributeCriteriaComputedByMinProximity

> Select the best-matching attribute based on proximity score

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="boolean" default="false" scope="settings" />

The `attributeCriteriaComputedByMinProximity` parameter changes how the best-matching attribute is selected when the **Attribute** comes before **Proximity** in the [ranking formula](/doc/api-reference/api-parameters/ranking).

By default, when **Attribute** comes before **Proximity** in the ranking formula,
matches are ranked by the attribute order in [`searchableAttributes`](/doc/api-reference/api-parameters/searchableAttributes).
When this parameter is `true`, the engine uses **minimum proximity** instead to decide which attribute matches best.

## Usage

* Only applies when `Attribute` ranks higher than `Proximity` in your ranking formula.
* Improves relevance when proximity matters more than attribute order in tie-breaking.

Suppose your searchable attributes are `["title", "author", "description"]` and a record matches both `title` and `description`.\
If proximity is lower in `description` but `title` appears earlier in the list:

* With `attributeCriteriaComputedByMinProximity: false` (default), `title` is the best-matching attribute.
* With `attributeCriteriaComputedByMinProximity: true`, `description` is the better match because of its lower proximity score.

## Example

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SetSettingsAsync(
        "INDEX_NAME",
        new IndexSettings { AttributeCriteriaComputedByMinProximity = true }
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          attributeCriteriaComputedByMinProximity: true,
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SetSettings(client.NewApiSetSettingsRequest(
        "INDEX_NAME",
        search.NewEmptyIndexSettings().SetAttributeCriteriaComputedByMinProximity(true)))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings(
        "INDEX_NAME",
        new IndexSettings().setAttributeCriteriaComputedByMinProximity(true)
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: { attributeCriteriaComputedByMinProximity: true },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(attributeCriteriaComputedByMinProximity = true),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->setSettings(
          'INDEX_NAME',
          ['attributeCriteriaComputedByMinProximity' => true,
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "attributeCriteriaComputedByMinProximity": True,
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings(
        "INDEX_NAME",
        Algolia::Search::IndexSettings.new(attribute_criteria_computed_by_min_proximity: true)
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(
            attributeCriteriaComputedByMinProximity = Some(true)
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response = try await client.setSettings(
          indexName: "INDEX_NAME",
          indexSettings: IndexSettings(attributeCriteriaComputedByMinProximity: true)
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      IndexSettings settings = new IndexSettings();
      settings.AttributeCriteriaComputedByMinProximity = true;

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      res, err := index.SetSettings(search.Settings{
      	AttributeCriteriaComputedByMinProximity: opt.AttributeCriteriaComputedByMinProximity(true),
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
        new IndexSettings()
          .setAttributeCriteriaComputedByMinProximity(true)
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          attributeCriteriaComputedByMinProximity: true,
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
        attributeCriteriaComputedByMinProximity = true
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'attributeCriteriaComputedByMinProximity' => true
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings({"attributeCriteriaComputedByMinProximity": True})
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          attributeCriteriaComputedByMinProximity: true
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          attributeCriteriaComputedByMinProximity = Some(true)
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.attributeCriteriaComputedByMinProximity, to: true)

      index.setSettings(settings) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
