Atvik
Mar 17, 9 PM - Mar 21, 10 AM
Taktu þátt í fundarröðinni til að byggja upp skalanlegar gervigreindarlausnir byggðar á raunverulegum notkunartilvikum með öðrum forriturum og sérfræðingum.
Nýskrá núnaÞessi vafri er ekki lengur studdur.
Uppfærðu í Microsoft Edge til að nýta þér nýjustu eiginleika, öryggisuppfærslur og tæknilega aðstoð.
Azure Cosmos DB for NoSQL now offers a powerful Full Text Search feature in preview, designed to enhance the search capabilities of your applications.
Azure Cosmos DB for NoSQL now offers a powerful Full Text Search feature in preview, designed to enhance your data querying capabilities. This feature includes advanced text processing techniques such as stemming, stop word removal, and tokenization, enabling efficient and effective text searches through a specialized text index. Full text search also includes full text scoring with a function that evaluates the relevance of documents to a given search query. BM25, or Best Matching 25, considers factors like term frequency, inverse document frequency, and document length to score and rank documents. This helps ensure that the most relevant documents appear at the top of the search results, improving the accuracy and usefulness of text searches.
Full Text Search is ideal for a variety of scenarios, including:
Full text search, full text scoring, and hybrid search all require enabling the preview feature on your Azure Cosmos DB for NoSQL account before using. Follow the below steps to register:
To use full text search capabilities, you'll first need to define two policies:
For every text property you'd like to configure for full text search, you must declare both the path
of the property with text and the language
of the text. A simple full text policy can be:
{
"defaultLanguage": "en-US",
"fullTextPaths": [
{
"path": "/text",
"language": "en-US"
}
]
}
Defining multiple text paths is easily done by adding another element to the fullTextPolicy
array:
{
"defaultLanguage": "en-US",
"fullTextPaths": [
{
"path": "/text1",
"language": "en-US"
},
{
"path": "/text2",
"language": "en-US"
}
]
}
Athugasemd
English ("en-us" as the language) is the only supported language at this time.
Mikilvægt
Wild card characters (*, []) are not currently supported in the full text policy or full text index.
Any full text search operations should make use of a full text index. A full text index can easily be defined in any Azure Cosmos DB for NoSQL index policy per the example below.
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/\"_etag\"/?"
},
],
"fullTextIndexes": [
{
"path": "/text"
}
]
}
Just as with the full text policies, full text indexes can be defined on multiple paths.
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/\"_etag\"/?"
},
],
"fullTextIndexes": [
{
"path": "/text"
},
{
"path": "/text2"
}
]
}
Full text search and scoring operations are performed using the following system functions in the Azure Cosmos DB for NoSQL query language:
FullTextContains
: Returns true
if a given string is contained in the specified property of a document. This is useful in a WHERE
clause when you want to ensure specific key words are included in the documents returned by your query.FullTextContainsAll
: Returns true
if all of the given strings are contained in the specified property of a document. This is useful in a WHERE
clause when you want to ensure that multiple key words are included in the documents returned by your query.FullTextContainsAny
: Returns true
if any of the given strings are contained in the specified property of a document. This is useful in a WHERE
clause when you want to ensure that at least one of the key words is included in the documents returned by your query.FullTextScore
: Returns a score. This can only be used in an ORDER BY RANK
clause, where the returned documents are ordered by the rank of the full text score, with most relevant (highest scoring) documents at the top, and least relevant (lowest scoring) documents at the bottom.Here are a few examples of each function in use.
In this example, we want to obtain the first 10 results where the keyword "bicycle" is contained in the property c.text
.
SELECT TOP 10 *
FROM c
WHERE FullTextContains(c.text, "bicycle")
In this example, we want to obtain first 10 results where the keywords "red" and "bicycle" are contained in the property c.text
.
SELECT TOP 10 *
FROM c
WHERE FullTextContainsAll(c.text, "red", "bicycle")
In this example, we want to obtain the first 10 results where the keywords "red" and either "bicycle" or "skateboard" are contained in the property c.text
.
SELECT TOP 10 *
FROM c
WHERE FullTextContains(c.text, "red") AND FullTextContainsAny(c.text, "bicycle", "skateboard")
In this example, we want to obtain the first 10 results where "mountain" and "bicycle" are included, and sorted by order of relevance. That is, documents that have these terms more often should appear higher in the list.
SELECT TOP 10 *
FROM c
ORDER BY RANK FullTextScore(c.text, ["bicycle", "mountain"])
Mikilvægt
FullTextScore can only be used in the ORDER BY RANK
clause and not projected in the SELECT
statement or in a WHERE
clause.
Atvik
Mar 17, 9 PM - Mar 21, 10 AM
Taktu þátt í fundarröðinni til að byggja upp skalanlegar gervigreindarlausnir byggðar á raunverulegum notkunartilvikum með öðrum forriturum og sérfræðingum.
Nýskrá núnaÞjálfun
Námsslóð
Define and implement an indexing strategy for Azure Cosmos DB for NoSQL - Training
Define and implement an indexing strategy for Azure Cosmos DB for NoSQL
Vottorð
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.