Can we use Phonetic token and Synonyms together?

2019-07-11 06:12发布

问题:

I am trying to enable phonetic analyzer, and synonyms together. It doesn't seem to work. Is it wrong to use them together?

In the below implementation I would expect the search query be converted using synonyms and then phonetic analyzer be used to retrieve the results. But my synonyms are totally ignored in here.

If i remove the phonetic analyser as part of the index creation, then the synonyms are working fine.

Also, the synonyms work fine if i use the in built analyzers like en.microsoft; instead of custom analyzers. Is this a bug?

My Synonym map

{   
   "name":"mysynonymmap",   
   "format":"solr", 
   "synonyms": "    
    SW, Software, Softvare, software, softvare, sft\n   
    HW, Hardware, Hardvare, hardware, hardvare, hdw => hardware\n"  
}

Below is how the index is getting created

     "name": "newphonetichotelswithsynonyms",  
     "fields": [
       {"name": "hotelId", "type": "Edm.String", "key":true, "searchable": false},
       {"name": "baseRate", "type": "Edm.Double"},
       {"name": "description", "type": "Edm.String", "filterable": false, "sortable": false, "facetable": false, "analyzer":"my_standard",  
        "synonymMaps":[ 
            "mysynonymmap"  
        ]},
       {"name": "hotelName", "type": "Edm.String", "analyzer":"my_standard",    
        "synonymMaps":[ 
            "mysynonymmap"  
        ]},
       {"name": "category", "type": "Edm.String", "analyzer":"my_standard", 
        "synonymMaps":[ 
            "mysynonymmap"  
        ]},
       {"name": "tags", "type": "Collection(Edm.String)", "analyzer":"my_standard", 
        "synonymMaps":[ 
            "mysynonymmap"  
        ]},
       {"name": "parkingIncluded", "type": "Edm.Boolean"},
       {"name": "smokingAllowed", "type": "Edm.Boolean"},
       {"name": "lastRenovationDate", "type": "Edm.DateTimeOffset"},
       {"name": "rating", "type": "Edm.Int32"},
       {"name": "location", "type": "Edm.GeographyPoint"}
      ],
  "analyzers":[
    {
      "name":"my_standard",
      "@odata.type":"#Microsoft.Azure.Search.CustomAnalyzer",
      "tokenizer":"standard_v2",
      "tokenFilters":[ "lowercase", "asciifolding", "phonetic" ]
    }
  ]
     }````