searchableAttributes

Type: list of strings
Engine default: [] (all string attributes)
Formerly: attributesToIndex
Parameter syntax
'searchableAttributes' => [
  'attribute1',
  'attribute2, attribute3', // both attributes have the same priority
  'ordered(attribute4)',
  'unordered(attribute5)'
]
Parameter syntax
searchableAttributes: [
  'attribute1',
  'attribute2, attribute3', # both attributes have the same priority
  'ordered(attribute4)',
  'unordered(attribute5)'
]
Parameter syntax
searchableAttributes: [
  'attribute1',
  'attribute2, attribute3', // both attributes have the same priority
  'ordered(attribute4)',
  'unordered(attribute5)'
]
Parameter syntax
'searchableAttributes': [
  'attribute1',
  'attribute2, attribute3', # both attributes have the same priority
  'ordered(attribute4)',
  'unordered(attribute5)'
]
Parameter syntax
"searchableAttributes": [
  "attribute1",
  "attribute2, attribute3", // both attributes have the same priority
  "ordered(attribute4)",
  "unordered(attribute5)"
]
Parameter syntax
new JSONObject().put(
  "searchableAttributes",
  new JSONArray()
    .put("attribute1")
    .put("attribute2, attribute3") // both attributes have the same priority
    .put("ordered(attribute4)")
    .put("unordered(attribute5)")
)
Parameter syntax
dynamic settings = new JObject();
settings.searchableAttributes = new JArray(new string[] {
new JArray(new string[] {
  "attribute1",
  "attribute2, attribute3", // both attributes have the same priority
  "ordered(attribute4)",
  "unordered(attribute5)"
});
Parameter syntax
new IndexSettings().setSearchableAttributes(Arrays.asList(
  "attribute1",
  "attribute2, attribute3", // both attributes have the same priority
  "ordered(attribute4)",
  "unordered(attribute5)"
))
Parameter syntax
"searchableAttributes": []string{
  "attribute1",
  "attribute2, attribute3", // both attributes have the same priority
  "ordered(attribute4)",
  "unordered(attribute5)"
}
Parameter syntax
searchableAttributes = Some(Seq(
  SearchableAttributes.attribute("attribute1")
  SearchableAttributes.attributes("attribute2", "attribute3") // both attributes have the same priority
  SearchableAttributes.attribute("attribute4") // ordered
  SearchableAttributes.unordered("attribute5")
))

Can be used in these methods:
setSettings set_settings setSettings set_settings setSettings setSettingsAsync SetSettings setSettings SetSettings changeSettings

About this parameter

The complete list of attributes that will be used for searching.

This setting is critical to establishing good relevance, for 2 main reasons:

  • Limits the scope of a search to the attributes listed in this setting. Defining specific attributes as searchable is critical for relevance because it gives you direct control over what information (i.e., attributes) the search engine will look at. Not every attribute in your index is useful for search; for example, some attributes contain URLs, others are used for display purposes only. Such attributes are not relevant to search. With this setting, you guide the engine to search only those attributes relevant to search.
  • Creates an order of priority for every listed attribute that the engine uses to improve relevance. The order in which the attributes appear determine their search priority. The engine will start searching your index using the first attributes in the list. If it finds a sufficient number of records, it stops and returns the results. If it doesn’t find enough records, it will continue searching using the next set of attributes, and so on.

Usage notes:
  • Default/Empty list: If you don’t use this setting, or use it with an empty list, the engine will search for all attributes.

  • Same Priority: You can create the same priority by putting more than one attribute in the same string.

  • Ordering/Unordering. In addition to creating attribute-level priority, you can also determine how the engine is going to search within an attribute. The engine can be directed to favor matches at the beginning of an attribute, or it can ignore positioning and consider any match within an attribute of equal importance. See below ordered/unordered options.

  • Nested attributes: When you specify an attribute that has children attributes, all of them will be indexed. If you don’t want the full nest to be searched, you can reference a child attribute, for example: categories.lvl0.child_attribute.sub_child_attribute


Modifiers:

  • ordered: Matches at the beginning of an attribute are more important than in the middle, and matches in the middle are more important than towards the end.

    If you don’t use either ordered or unordered, ordered is the default.

  • unordered: There is no preference: Any match anywhere in the attribute has the same weight.

Examples

Set searchableAttributes

The following example shows how to:

  • make some attributes searchable
  • put several attributes at the same level
  • set an attribute as unordered
  • search only a child attribute
<?php
$index->setSettings([
  'searchableAttributes' => [
    "title,alternative_title",
    "author",
    "unordered(text)"
  ]
]);
index.set_settings({
  searchableAttributes: [
    'title,alternative_title',
    'author',
    'unordered(text)',
    'emails.personal'
  ]
})
index.setSettings({
  searchableAttributes: [
    'title,alternative_title',
    'author',
    'unordered(text)'
  ]
});
index.set_settings({
  'searchableAttributes': [
    'title,alternative_title',
    'author',
    'unordered(text)',
    'emails.personal'
  ]
})
index.setSettings([
  "searchableAttributes": [
    "title,alternative_title",
    "author",
    "unordered(text)",
    "emails.personal"
  ]
])
index.setSettings(
  new JSONObject().put(
    "searchableAttributes",
    new JSONArray()
      .put("title,alternative_title")
      .put("author")
      .put("unordered(text)")
      .put("emails.personal")
  )
);
dynamic settings = new JObject();
settings.searchableAttributes = new JArray(new string[] {
  "title,alternative_title",
  "author",
  "unordered(text)",
  "emails.personal"
});

index.SetSettings(settings);
index.setSettings(
  new IndexSettings().setSearchableAttributes(Arrays.asList(
    "title,alternative_title",
    "author",
    "unordered(text)",
    "emails.personal"
  ))
);
res, err := index.SetSettings(algoliasearch.Map{
  "searchableAttributes": []string{
    "title,alternative_title",
    "author",
    "unordered(text)",
    "emails.personal"
  },
})
client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    searchableAttributes = Some(Seq(
      SearchableAttributes.attributes("title", "alternative_title")
      SearchableAttributes.attribute("author")
      SearchableAttributes.unordered("text")
      SearchableAttributes.attribute("emails.personal")
    ))
  )
}
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala