path_hierarchy_v2 not working along with facet field in Azure cognitive search

Viewed 40

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": []
}
1 Answers

Apologies for the delay. 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.

Related