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

# attributeCriteriaComputedBy

> Control how Algolia calculates the Attribute ranking criterion.

\<ul><li>**Type:** `enum<string>`</li>
      \<li>**Default:** `best`</li>
      
      
      \<li>**Scope:** [`settings,search`](/doc/api-reference/api-parameters)</li></ul>The `attributeCriteriaComputedBy` parameter controls how Algolia calculates the Attribute ranking criterion,
mainly for multi-word queries with matches in more than one attribute.It supports three strategies: `best` (default), `minProximity`, and `sum`.## Options**minProximity**Picks the best matching attribute from the attributes that form the best proximity score.
On an ordered attribute, the match position breaks ties.The order of the [Attribute and Proximity ranking criteria](/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria) affects the `best` strategy.
By default, Proximity comes before Attribute, so Algolia uses `minProximity` instead of `best`.
To use `best`, move Attribute before Proximity in [`ranking`](/doc/api-reference/api-parameters/ranking).Both `minProximity` and `sum` work with either order.**best**Picks the best matching attribute from all attributes that match any query word.
On an ordered attribute, the match position breaks ties.**sum**Adds a score for every query word instead of picking one attribute.
The score depends on the matching attribute and, for [ordered attributes](/doc/guides/managing-results/must-do/searchable-attributes/how-to/configuring-searchable-attributes-the-right-way#word-position),
the position of the match.
Words that don't match add a large penalty.
Records with lower total scores rank higher.With `sum`, a record can't rank highly based only on one query word matching an attribute with higher priority in the `searchableAttributes` list.## UsageUse `sum` with short, relevant attributes, and set long-text attributes to unordered in [`searchableAttributes`](/doc/api-reference/api-parameters/searchableAttributes).
`sum` combines attribute rank and word position into one score.
When an ordered attribute is long, a match deep inside it can outrank a better match spread across two attributes.Suppose a store has the following `searchableAttributes` and users search for `black jeans`:```json JSON icon=braces theme={"system"}
["color,brand,category", "unordered(name)", "unordered(description)"]
```- Record A matches `black` in `color` and `jeans` in `category`.
- Record B matches `black` in `color` and `jeans` in `name`.With `sum`, record A ranks higher, because both words matched in the top attribute group.## Example```cs C# theme={"system"}
var response = await client.SetSettingsAsync(
  "INDEX_NAME",
  new IndexSettings { AttributeCriteriaComputedBy = Enum.Parse<AttributeCriteriaComputedBy>("Sum") }
);
``````dart Dart theme={"system"}
final response = await client.setSettings(
  indexName: "INDEX_NAME",
  indexSettings: IndexSettings(
    attributeCriteriaComputedBy: AttributeCriteriaComputedBy.fromJson("sum"),
  ),
);
``````go Go theme={"system"}
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
  "INDEX_NAME",
  search.NewEmptyIndexSettings().SetAttributeCriteriaComputedBy(search.AttributeCriteriaComputedBy("sum"))))
if err != nil {
  // handle the eventual error
  panic(err)
}
``````java Java theme={"system"}
UpdatedAtResponse response = client.setSettings(
  "INDEX_NAME",
  new IndexSettings().setAttributeCriteriaComputedBy(AttributeCriteriaComputedBy.SUM)
);
``````js JavaScript theme={"system"}
const response = await client.setSettings({
  indexName: 'theIndexName',
  indexSettings: { attributeCriteriaComputedBy: 'sum' },
});
``````kotlin Kotlin theme={"system"}
var response =
  client.setSettings(
    indexName = "INDEX_NAME",
    indexSettings =
      IndexSettings(
        attributeCriteriaComputedBy =
          AttributeCriteriaComputedBy.entries.first { it.value == "sum" }
      ),
  )
``````php PHP theme={"system"}
$response = $client->setSettings(
    'INDEX_NAME',
    ['attributeCriteriaComputedBy' => 'sum',
    ],
);
``````python Python theme={"system"}
response = client.set_settings(
    index_name="INDEX_NAME",
    index_settings={
        "attributeCriteriaComputedBy": "sum",
    },
)
``````ruby Ruby theme={"system"}
response = client.set_settings(
  "INDEX_NAME",
  Algolia::Search::IndexSettings.new(attribute_criteria_computed_by: "sum")
)
``````scala Scala theme={"system"}
val response = Await.result(
  client.setSettings(
    indexName = "INDEX_NAME",
    indexSettings = IndexSettings(
      attributeCriteriaComputedBy = Some(AttributeCriteriaComputedBy.withName("sum"))
    )
  ),
  Duration(100, "sec")
)
``````swift Swift theme={"system"}
let response = try await client.setSettings(
    indexName: "INDEX_NAME",
    indexSettings: IndexSettings(attributeCriteriaComputedBy: SearchAttributeCriteriaComputedBy.sum)
)
```## See also- [`attributeCriteriaComputedByMinProximity`](/doc/api-reference/api-parameters/attributeCriteriaComputedByMinProximity)
