我在查询像这样的索引时发现了多个样本:
results = indexClient.Documents.Search<Hotel>("budget", parameters);
但是,在使用方面时,我什么也找不到。您如何使用SearchServiceClient和方面?
在搜索服务浏览器中,它将类似于:
&facet=Group
结果:
{
"@odata.context": "https://xxx-dev.search.windows.net/indexes('influencers')/$metadata#docs",
"@search.facets": {
"Group@odata.type": "#Collection(Microsoft.Azure.Search.V2017_11_11.QueryResultFacet)",
"Group": [
{
"count": 426,
"value": "Gaming"
},
{
"count": 388,
"value": "Action Sports"
},
{
"count": 379,
"value": "Music"
},
{
"count": 378,
"value": "Sport"
}
]
},
"value": [
{
"@search.score": 1,
"id": "fc4b1200-fb91-4fe0-a251-beb351ee2988",
"FirstName": "Chase",
"LastName": "Powell",
"Mobile": "500-0545772",
"Country": "Sweden",
"Group": "Music",
"SubGroups": [
"Jazz",
"Electronic Dance",
"Rock Music",
"Pop",
"Techno",
"Indie Rock",
"Dubstep"
]
},
{
"@search.score": 1,
"id": "131f3d54-9b36-4b60-bb38-4d412bcc1682",
"FirstName": "Ian",
"LastName": "Bryant",
"Mobile": "236-3224487",
"Country": "Denmark",
"Group": "Gaming",
"SubGroups": [
"World of Warcraft ",
"Counter-Strike",
"League of Legends"
]
}
答案 0 :(得分:1)
但是,在使用方面时,我什么也找不到。您如何使用SearchServiceClient和方面?
我们可以调查Azure搜索demo source code以获得答案。 以下是Azure搜索演示中的代码段。
SearchParameters sp = new SearchParameters()
{
...
Select = new List<String>() {"id", "agency", "posting_type",...},
....
// Add facets
Facets = new List<String>() { "business_title", "posting_type", "level", "salary_range_from,interval:50000" },
};
// Add filtering
string filter = null;
if (businessTitleFacet != "")
filter = "business_title eq '" + businessTitleFacet + "'";
if (postingTypeFacet != "")
{
if (filter != null)
filter += " and ";
filter += "posting_type eq '" + postingTypeFacet + "'";
}
....
sp.Filter = filter;
_indexClient.Documents.Search(searchText, sp);