Skip to main content

Relevance data - Azure Cognitive Search

Scoring profile

A scoring profile is a configuration that you can use to boost or lower the relevance scores of search results based on specific criteria.

scoringProfile in a search query in Node.js
const { SearchIndexClient, AzureKeyCredential } = require('@azure/search-documents');

const endpoint = 'https://[SERVICE NAME].search.windows.net';
const apiKey = '[API KEY]';
const indexName = '[INDEX NAME]';

const client = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey));

const searchResult = await client.search('search text', {
scoringProfile: 'boostKeywords',
});

for await (const result of searchResult.results) {
}

console.log(`Total count of documents found: ${searchResult.count}`);
console.log(`Documents found:`);
console.log(searchResult.results);

Text Weights

The textWeights attribute allows you to assign different weights to the search terms in a query to influence the relevance scores of the search results. For example, you might want to assign a higher weight to the search term in the document title than to the search term in the document body.

textWeights - scoringProfile
const scoringProfile = {
name: 'myScoringProfile',
textWeights: {
weights: {
title: 2,
body: 1,
},
},
};