elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.51k stars 24.6k forks source link

Completion suggester: Not returning all options #27217

Closed jaspsing closed 6 years ago

jaspsing commented 6 years ago

Elasticsearch version (bin/elasticsearch --version): 5.4.2

Plugins installed: []

JVM version (java -version): 1.8.0_141

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:

  1. The mapping of field looks like
              "topics": {
                "type": "text",
                "fields": {
                  "topics_suggest": {
                    "type": "completion",
                    "analyzer": "english",
                    "preserve_separators": true,
                    "preserve_position_increments": true,
                    "max_input_length": 50
                  }
                }
              }
  2. A sample document has this data:
            "topics": [
              "Cloud Computing",
              "Cloud Services"
              ]
  3. The query looks like ...
    GET test_new_index/_search
    {
    "_source": "false",
    "suggest": {
    "topics_suggest": {
      "completion": {
        "field": "topics.topics_suggest",
        "fuzzy": true
      },
      "prefix": "cloud"
    }
    }
    }
  4. The output is
    "suggest": {
    "topics_suggest": [
      {
        "text": "cloud",
        "offset": 0,
        "length": 5,
        "options": [
          {
            "text": "Cloud Computing",
            "_index": "test_autosuggest_english_analyzer",
            "_type": "document",
            "_id": "40000202",
            "_score": 4,
            "_source": {}
          }
        ]
      }
    ]
    }

    It should return both Cloud Computing and Cloud Services.

colings86 commented 6 years ago

@jimczi could you take a look at this?

jimczi commented 6 years ago

The completion suggester is document based. It returns documents that match the suggestion query. In your example the document matches both Cloud Computing and Cloud Services but it is returned only once. As such, results of the suggester are hits that respect the options set in the query. In your example you disabled _source so the suggester hits are returned with an empty _source.

I hope you don't mind if I close this issue, we reserve github for verified bugs and feature request. I or someone else from the community will be happy to help you configure your suggest field in the forum: https://discuss.elastic.co/t