Suggest: No results with anything I've tried (term, phrase, simple_phrase, collate)

Hi everyone, I'm new to Elasticsearch and I've been trying for some time to get a suggest search to return me anything at all and I really need help.

Requirement
Suggest article titles based on incomplete or misspelled input, where the input could appear anywhere in the title. The order of the words in the title may not be well-known.

Here is where I am right now:

Index

PUT /item
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "edge_ngram_filter": {
            "type": "edge_ngram",
            "min_gram": "1",
            "max_gram": "10"
          },
          "suggest_shingle_filter": {
            "type": "shingle",
            "min_shingle_size": 2,
            "max_shingle_size": 10
          }
        },
        "analyzer": {
          "suggest_token_analyzer": {
            "tokenizer": "standard",
            "type": "custom",
            "filter": [
              "lowercase",
              "asciifolding",
              "edge_ngram_filter",
              "stop"
            ]
          },
          "suggest_shingle_analyzer": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": [
              "lowercase",
              "suggest_shingle_filter"
            ]
          }
        }
      }
    },
    "max_ngram_diff": "10",
    "max_shingle_diff": 10
  },
  "mappings": {
    "properties": {
      "title_suggest": {
        "type": "text",
        "analyzer": "suggest_token_analyzer",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "suggest_shingle_analyzer"
          },
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  }
}

Populate Index

PUT /item/_doc/1
{
  "title_suggest": "Diabetes"
}

PUT /item/_doc/2
{
  "title_suggest": "Diabetes Mellitus"
}

PUT /item/_doc/3
{
  "title_suggest": "Diabetes Mellitus Type 1"
}

Attempted suggests (they all do nothing)

GET /item/_search
{
  "suggest": {
    "YOUR_SUGGESTION": {
      "text": "Diabetes",
      "term": {
        "field": "title_suggest"
      }
    }
  }
}

GET /item/_search
{
  "suggest": {
    "YOUR_SUGGESTION": {
      "text": "Diabetes",
      "term": {
        "field": "title_suggest.shingle"
      }
    }
  }
}

GET item/_search
{
  "suggest": {
    "text": "dia",
    "simple_phrase": {
      "phrase": {
        "field": "title_suggest",
        "confidence": 0.0,
        "direct_generator": [
          {
            "field": "title_suggest"
          }
        ],
        "collate": {
          "query": {
            "source": {
              "match": {
                "title": {
                  "query": "{{suggestion}}",
                  "fuzziness": "2",
                  "operator": "and"
                }
              }
            }
          },
          "prune": "true"
        }
      }
    }
  }
}

Desired results
I should be able to:

  1. Type in "D" and get all 3 items returned
  2. Type in "Diabetes" and get all 3 items returned
  3. Type in "Diabeetus" and get all 3 items returned
  4. Type in "Mel" and get "Diabetes Mellitus" and "Diabetes Mellitus Type 1" returned
    And so on...

Can someone please help me figure out what I'm doing wrong or point me in the right direction?

Thanks in advance!

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