SearchIndexClient with facets
I have found multiple samples on querying an index like:
results = indexClient.Documents.Search<Hotel>("budget", parameters);
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
In the search service explorer it would be something like:
&facet=Group
With result:
{
"@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"
]
}
azure-search
add a comment |
I have found multiple samples on querying an index like:
results = indexClient.Documents.Search<Hotel>("budget", parameters);
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
In the search service explorer it would be something like:
&facet=Group
With result:
{
"@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"
]
}
azure-search
add a comment |
I have found multiple samples on querying an index like:
results = indexClient.Documents.Search<Hotel>("budget", parameters);
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
In the search service explorer it would be something like:
&facet=Group
With result:
{
"@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"
]
}
azure-search
I have found multiple samples on querying an index like:
results = indexClient.Documents.Search<Hotel>("budget", parameters);
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
In the search service explorer it would be something like:
&facet=Group
With result:
{
"@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"
]
}
azure-search
azure-search
edited Nov 22 at 10:41
asked Nov 22 at 10:35
Thomas Segato
520314
520314
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
We could look into the Azure search demo source code to get the answer.
The following is the snippet code from the Azure search demo.
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);
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428994%2fsearchindexclient-with-facets%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
We could look into the Azure search demo source code to get the answer.
The following is the snippet code from the Azure search demo.
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);
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
add a comment |
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
We could look into the Azure search demo source code to get the answer.
The following is the snippet code from the Azure search demo.
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);
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
add a comment |
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
We could look into the Azure search demo source code to get the answer.
The following is the snippet code from the Azure search demo.
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);
However I cant find anything when working with facets. How do you work with the SearchServiceClient and facets?
We could look into the Azure search demo source code to get the answer.
The following is the snippet code from the Azure search demo.
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);
answered Nov 23 at 2:09
Tom Sun
16.1k2921
16.1k2921
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
add a comment |
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
WOW that was easy. Thanks alot!
– Thomas Segato
Nov 24 at 10:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428994%2fsearchindexclient-with-facets%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown