# Phrase suggester collate doesn't work in search template

**URL:** <https://discuss.elastic.co/t/phrase-suggester-collate-doesnt-work-in-search-template/33871>\
**Category:** Elasticsearch\
**Created:** [November 5, 2015, 1:25pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-doesnt-work-in-search-template/33871 "2015-11-05T13:25:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![buinauskas\_evaldas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/buinauskas_evaldas/32/31439_2.png) [@buinauskas\_evaldas](https://discuss.elastic.co/u/buinauskas_evaldas)\
**Post date:** [November 5, 2015, 1:25pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-doesnt-work-in-search-template/33871/1 "2015-11-05T13:25:52Z")

</div>

I'm facing issues with `collate` in Phrase Suggester.

Please see this reproduction:

```
PUT /test/test/1
{
  "CompanyName": "coca-cola"
}

POST /test/_search
{
  "size": 0,
  "suggest": {
    "DidYouMean": {
      "text": "coce",
      "phrase": {
        "field": "_all",
        "size": 50,
        "direct_generator": [
          {
            "field": "_all",
            "suggest_mode": "popular",
            "min_word_length": 3
          }
        ],
        "collate": {
          "query": {
            "match": {
              "CompanyName": {
                "query": "{{suggestion}}",
                "operator": "and"
              }
            }
          },
          "prune": true
        }
      }
    }
  }
}

```

It brings me this result with `"collate_match": true`:

```
{
   "took": 4,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 0,
      "hits": []
   },
   "suggest": {
      "DidYouMean": [
         {
            "text": "coce",
            "offset": 0,
            "length": 4,
            "options": [
               {
                  "text": "coca",
                  "score": 0.6531368,
                  "collate_match": true
               },
               {
                  "text": "cola",
                  "score": 0.5476822,
                  "collate_match": true
               }
            ]
         }
      ]
   }
} 

```

But when I create a template using this query:

```
PUT /_search/template/suggest
{
  "template": {
    "size": 0,
    "suggest": {
      "DidYouMean": {
        "text": "{{SearchPhrase}}",
        "phrase": {
          "field": "_all",
          "size": 50,
          "direct_generator": [
            {
              "field": "_all",
              "suggest_mode": "popular",
              "min_word_length": 3
            }
          ],
          "collate": {
            "query": {
              "match": {
                "CompanyName": {
                  "query": "{{suggestion}}",
                  "operator": "and"
                }
              }
            },
            "prune": true
          }
        }
      }
    }
  }
}

```

And call it using this:

```
POST /test/_search/template
{
  "template": {
    "id": "suggest"
  },
  "params": {
    "SearchPhrase": "coca cole"
  }
}

```

I'm getting false results:

```
{
   "took": 6,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 0,
      "hits": []
   },
   "suggest": {
      "DidYouMean": [
         {
            "text": "coca cole",
            "offset": 0,
            "length": 9,
            "options": [
               {
                  "text": "coca cola",
                  "score": 0.4727091,
                  "collate_match": false
               },
               {
                  "text": "coca coca",
                  "score": 0.39638618,
                  "collate_match": false
               }
            ]
         }
      ]
   }
}

```

How do I resolve it?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:40pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-doesnt-work-in-search-template/33871/2 "2017-07-05T23:40:20Z")

</div>


