admin管理员组文章数量:1279050
I have cosmos document with name "Test Only"
There is search index created on the cosmos.
when I am searching with search text "olly~1 AND olly~1" getting above record.
Below is the code block
var client = new SearchClient(new Uri(searchServiceEndpoint), indexName, new DefaultAzureCredential());
string fuzzySearchText = "olly~1 AND olly~1";
var options = new SearchOptions
{
SearchMode = SearchMode.All, // Ensures all terms should be considered
QueryType = SearchQueryType.Full, // Allows fuzzy searching
IncludeTotalCount = true
};
var results = await client.SearchAsync<dynamic>(fuzzySearchText, options);
I need result that the record "Test Only" should no match with "olly~1 AND olly~1".
Any suggestion?.
I have cosmos document with name "Test Only"
There is search index created on the cosmos.
when I am searching with search text "olly~1 AND olly~1" getting above record.
Below is the code block
var client = new SearchClient(new Uri(searchServiceEndpoint), indexName, new DefaultAzureCredential());
string fuzzySearchText = "olly~1 AND olly~1";
var options = new SearchOptions
{
SearchMode = SearchMode.All, // Ensures all terms should be considered
QueryType = SearchQueryType.Full, // Allows fuzzy searching
IncludeTotalCount = true
};
var results = await client.SearchAsync<dynamic>(fuzzySearchText, options);
I need result that the record "Test Only" should no match with "olly~1 AND olly~1".
Any suggestion?.
Share Improve this question edited Feb 27 at 15:08 Sampath 3,6592 gold badges6 silver badges24 bronze badges Recognized by Microsoft Azure Collective asked Feb 24 at 11:17 user29776536user29776536 11 bronze badge 1- Instead of ~1, you can remove it or set it to ~0 – Sampath Commented Feb 26 at 9:34
1 Answer
Reset to default 0Fuzzy search (
~1)
allows for a one-character difference, meaning "olly~1"
can match "only"
due to their similarity.
To prevent "Test Only" from matching "olly~1"
and "olly1"
, you can try the following steps:
- Using
Full
enables the full Lucene query syntax, which sometimes leads to unexpected matches.
QueryType = SearchQueryType.Simple
Instead of ~1
, you can remove it or set it to ~0
(exact match). Modify:
string fuzzySearchText = "olly AND olly";
(or)
string fuzzySearchText = "olly~0 AND olly~0";
A value of ~0
signifies no expansion (only the exact term is considered a match). However, you can specify ~1
to allow for one character difference (one edit distance).
For example, "blue~"
or "blue~1"
would return matches like "blue"
, "blues"
, and "glue"
.
Refer to this MSDOC for information on Fuzzy Search in Azure AI Search. Also, check out this MSDOC to learn how to perform searches using Azure SDKs in Azure AI Search.
Below is the code
var client = new SearchClient(new Uri(searchServiceEndpoint), indexName, new DefaultAzureCredential());
string fuzzySearchText = "olly AND olly";
var options = new SearchOptions
{
SearchMode = SearchMode.Any,
QueryType = SearchQueryType.Simple,
IncludeTotalCount = true
};
var results = await client.SearchAsync<dynamic>(fuzzySearchText, options);
Output:
本文标签: Azure AI searchFuzzy search with same terms one char dfferenceStack Overflow
版权声明:本文标题:Azure AI search - Fuzzy search with same terms one char dfference - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741274453a2369646.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论