Indexes - Azure Cognitive search
Index schema
In Azure Cognitive Search, an index schema is a blueprint that defines the fields that will be included in your search index. Each field in the index schema has a set of attributes that determine how the field can be searched and filtered. Below is the list of attributes available for defining an index schema:
name: The name of the field.
type: The data type of the field. Available data types include Edm.String, Edm.Boolean, Edm.Int32, Edm.Int64, Edm.Double, Edm.DateTimeOffset, Edm.GeographyPoint, and Collection(Edm.*).
key: Indicates whether the field is the key for the index. A key field is a unique identifier for each document in the index.
searchable: Indicates whether the field can be searched. If set to true, the field will be included in full-text searches.
filterable: Indicates whether the field can be used in filters. If set to true, the field can be used in filter expressions.
sortable: Indicates whether the field can be sorted. If set to true, the field can be used in sorting expressions.
facetable: Indicates whether the field can be used in faceted navigation. If set to true, the field can be used to group search results by a specific value.
retrievable: Indicates whether the field can be retrieved in search results. If set to false, the field will not be included in search results.
analyzer: The name of the analyzer to use for the field. An analyzer is used to tokenize and normalize text data to improve search accuracy.
synonymMaps: An array of synonym map names to associate with the field. Synonym maps are used to expand search queries to include synonyms and related terms.
const schema = {
name: 'products',
fields: [
{ name: 'id', type: 'Edm.String', key: true, searchable: false },
{
name: 'name',
type: 'Edm.String',
searchable: true,
filterable: true,
sortable: true,
facetable: true,
analyzer: 'standard.lucene',
synonymMaps: ['product-synonyms'],
},
{ name: 'description', type: 'Edm.String', searchable: true, analyzer: 'standard.lucene' },
{ name: 'price', type: 'Edm.Double', filterable: true, sortable: true, facetable: true },
{ name: 'category', type: 'Edm.String', filterable: true, facetable: true },
{ name: 'created', type: 'Edm.DateTimeOffset', sortable: true },
{ name: 'location', type: 'Edm.GeographyPoint', searchable: false },
{
name: 'tags',
type: 'Collection(Edm.String)',
searchable: true,
filterable: true,
facetable: true,
analyzer: 'keyword',
},
],
};