2

According to article https://azure.microsoft.com/pl-pl/blog/azure-search-synonyms-public-preview/ I should be to use multi-word/phrase synonym in synonymMaps

Multi-word synonyms

In many full text search engines, support for synonyms is limited to single words. Our team has engineered a solution that allows Azure Search to support multi-word synonyms. This allows for phrase queries (“”) to function properly while using synonyms. If someone has mapped ‘hot tub’ to ‘whirlpool bath’ and they then search for “large hot tub,” Azure Search will return matches which contain both “large hot tub” and “large whirlpool bath.”

However, in my case I got match on sub words.

My synonymMap looks like:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss\n"}

And I have documents in search index which contains medicine disciplines like Gastroenterology (acute and chronic).

What I receives after ?search="vomiting" is:

 {
            "@search.score": 1.0405536,
            "@search.highlights": {
                "disciplines/name": [
                    "<em>Acute</em> <em>and</em> <em>chronic</em> ear disease",
                    "<em>Acute</em> <em>and</em> <em>chronic</em> skin disease",
                    "<em>Gastroenterology</em> (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Haematology (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Respiratory medicine (<em>acute</em> <em>and</em> <em>chronic</em>)"
                ],

And I am expecting:

{
    "@search.score": 1.0405536,
    "@search.highlights": {
        "disciplines/services/translatedName": [
            "<em>Gastroenterology (acute and chronic)</em>",
        ],

Am I doing something wrong?

I tried to cut main word to one-word like Gastroenterology but some of them simply cannot be cut. Providing quotes like synonyms => "Gastroenterology (acute and chronic)" also does not work.

UPDATED

I was wondering why I thought there is problem. Well, I provided:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss\n"}

And actually using:

{"name":"map",

"format":"solr",

"synonyms":"Gastroenterology (acute and chronic),vomiting, diarrhoea, weight loss
     => Gastroenterology (acute and chronic)\n"}

In that case I vae 4 results:

"@odata.count": 4,
"value": [
        {
            "@search.score": 1.0137179,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Acute</em> <em>and</em> <em>chronic</em> ear disease",
                    "<em>Acute</em> <em>and</em> <em>chronic</em> skin disease",
                    "<em>Gastroenterology</em> (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Haematology (<em>acute</em> <em>and</em> <em>chronic</em>)",
                    "Respiratory medicine (<em>acute</em> <em>and</em> <em>chronic</em>)"
                ],
                "equipment/translatedName": [
                    "Emergency <em>and</em> crictial care",
                    "In house skin <em>and</em> ear cyology"
                ],
                "disciplines/translatedName": [
                    "Anaesthesia <em>and</em> analgesia",
                    "Emergency <em>and</em> critical care"
                ]
            },
          ...
        {
            "@search.score": 0.33542877,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Chronic</em> pain management"
                ],
                "disciplines/translatedName": [
                    "Anaesthesia <em>and</em> analgesia"
                ]
            },
        ...
        {
            "@search.score": 0.13757591,
            "@search.highlights": {
                "equipment/translatedName": [
                    "Emergency <em>and</em> crictial care"
                ],
                "disciplines/translatedName": [
                    "Emergency <em>and</em> critical care"
                ]
            },
         ...
        {
            "@search.score": 0.07112321,
            "@search.highlights": {
                "disciplines/services/translatedName": [
                    "<em>Chronic</em> pain management"
                ]
            },

Could you explain to me how it works in that case?

MOORWEENO
  • 21
  • 2

1 Answers1

1

Azure Search does support multi-word synonyms and the result in your case is as expected. There are a couple of things to be called out here.

First ?search="vomiting" will return docs that match 'vomiting' or specified synonyms anywhere within the document. The multi-word synonym Gastroenterology (acute and chronic) in the collection disciplines/name matches your query, resulting the document to be returned.

The second thing that is probably the source of confusion, is the highlighting. Azure search doesn't support phrase highlighting currently. If used with a phrase query, it highlights the individual terms in the phrase. Since the matching document also had individual terms elsewhere, all of those were highlighted. Check Azure search highlights for phrases with double quotes for more details.

So, the multi-word synonym expansion and search is functioning as expected. You can test this by indexing a test document that just contains Gastroenterology (acute and chronic) and then another that just contains acute and chronic. The query should result only return the 1st document.

If you have a strict requirement on highlighting phrases, you'll have to do some client side processing after retrieving the search results