# Problem with phrase suggestor

**URL:** <https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293>\
**Category:** Elasticsearch\
**Created:** [November 28, 2017, 12:16am UTC](https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293 "2017-11-28T00:16:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshay\_Deep\_Lamba](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Akshay\_Deep\_Lamba](https://discuss.elastic.co/u/Akshay_Deep_Lamba)\
**Post date:** [November 28, 2017, 12:16am UTC](https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293/1 "2017-11-28T00:16:21Z")

</div>

Hello  
I created an index using the below code

```
PUT test
{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "analysis": {
        "analyzer": {
          "trigram": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["standard", "shingle"]
          },
          "reverse": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["standard", "reverse"]
          }
        },
        "filter": {
          "shingle": {
            "type": "shingle",
            "min_shingle_size": 2,
            "max_shingle_size": 3
          }
        }
      }
    }
  },
  "mappings": {
    "test": {
      "properties": {
        "title": {
          "type": "text",
          "fields": {
            "trigram": {
              "type": "text",
              "analyzer": "trigram"
            },
            "reverse": {
              "type": "text",
              "analyzer": "reverse"
            }
          }
        }
      }
    }
  }
}

```

then i placed some data into that by the below code.

> POST test/test?refresh=true  
> {"title": "noble warriors"}

> POST test/test?refresh=true  
> {"title": "nobel prize"}

> POST test/test?refresh=true  
> {"title": "nobele prize"}

and then tried the phrase suggestor by the below code :-

```
POST test/_search
{
  "suggest": {
    "text" : "nobl prize",
    "simple_phrase" : {
      "phrase" : {
        "field" : "title.trigram",
        "size" : 1,
        "direct_generator" : [ {
          "field" : "title.trigram",
          "suggest_mode" : "always"
        }, {
          "field" : "title.reverse",
          "suggest_mode" : "always",
          "pre_filter" : "reverse",
          "post_filter" : "reverse"
        } ]
      }
    }
  }
} 

```

received the below result :-

```
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": 0,
    "hits": []
  },
  "suggest": {
    "simple_phrase": [
      {
        "text": "nobl prize",
        "offset": 0,
        "length": 10,
        "options": [
          {
            "text": "nobel prize",
            "score": 0.52381706
          }
        ]
      }
    ]
  }
}

```

The problem with search is as below :-

1. The Expected output should be 2 option as below  
**{"title": "nobel prize"}**  
**{"title": "nobele prize"}**  
as they both are present in the index ..

2. when i try search **nobal preze** or **nobl preze** then i receive the result after correction of only one word..that **preze into prize** also when i search for **nobal prize** or **nobl prize** then i received **nobl or nobal into nobel**

pls guide..

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [December 1, 2017, 11:47am UTC](https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293/2 "2017-12-01T11:47:45Z")

</div>

If you set `size` to 1 then only one suggestion is returned. I tried with a `size` of 2 and both suggestions are returned as expected.  
Regarding your second question, the phrase suggester has a parameter to control the number of terms that can be corrected in the response: `max_errors`. It defaults to 1 so only one term is replaced, using 2 allows the entire query terms to be replaced in your example.  
Though the docs says:

```auto
Low values like 1 or 2 are recommended otherwise the time spend in suggest calls might exceed the time spend in query execution.

```

so check the performance hit when you set this value 😉

---

<div class="post-metadata">

**Author:** ![Akshay\_Deep\_Lamba](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Akshay\_Deep\_Lamba](https://discuss.elastic.co/u/Akshay_Deep_Lamba)\
**Post date:** [December 1, 2017, 11:49pm UTC](https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293/3 "2017-12-01T23:49:26Z")

</div>

**@jimczi.**.This Works 😄 ...i Had One Small Question to ask like ...Say I Type **Nobl Preze Winar** with max\_error = 3 ..then Do You think that it will Get It Self Changed to **Nobel Prize Winner**... the Result I am getting is **Nobel Prize Winar**...How Can We Use Some NLP along with this...

Pls Guide...

---

<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:** [December 29, 2017, 11:49pm UTC](https://discuss.elastic.co/t/problem-with-phrase-suggestor/109293/4 "2017-12-29T23:49:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
