path_hierarchy_v2 not working along with facet field in Azure cognitive search

Aayush Sah (IND) 1 Reputation point
2021-05-13T18:58:35.94+00:00

I am unable to use path_hierarchy_v2 tokenizer in the facet field. But while analyzing the text with analyze api it tokenizes the text in path hierarchy.
{
"text": "a/b/c",
"analyzer": "my_path_analyzer"
}

I am unable to use path_hierarchy_v2 tokenizer in the facet field. But while analyzing the text with analyze api it tokenizes the text in path hierarchy.

 {
  "text": "a/b/c",
  "analyzer": "my_path_analyzer"
 }

this gives:

a, a/b, a/b/c

but while using with facet it does not work.

and the result it returns is:

 {
  "count": 2,
  "value": "a/b/c"
 }

But i want to get something like this

 {
  "count": 2,
  "value": "a"
 },
{
  "count": 1,
  "value": "a/b"
 },
{
  "count": 1,
  "value": "a/b/c"
 }

This is my field mapping:

{
      "name": "hierarchy_field",
      "type": "Edm.String",
      "facetable": true,
      "filterable": true,
      "key": false,
      "retrievable": true,
      "searchable": true,
      "sortable": true,
      "analyzer": "my_path_analyzer",
      "indexAnalyzer": "",
      "searchAnalyzer": "",
      "synonymMaps": []
}
Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
834 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 24,396 Reputation points Microsoft Employee
    2021-05-20T18:18:51.213+00:00

    @Aayush Sah (IND) , I'd shared this on your SO thread and also was expecting your reply to my private comment here.

    You may try to break that down during pre-processing and assign each 'tier' of the hierarchy to a different field, as below:

    Top_Level_Field=”a/b/c”  
     
    Next_Level_Field=”b/c”  
      
    Bottom_Level_Field=”c”  
    

    Typically, each facet tier can have different values but you need to have a pre-determined hierarchy depth.
    Kindly let us know if you have any further questions on this.

    0 comments No comments