Search_as_you_type not working, help

I was trying the new feature Search_as_you_type but I don't know if if it my lack of knowledge but it is not working. I installed the verion 7.14. this is my kibana queries. this query yeld nothing no hits.

DELETE test
PUT test
{
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "content": {
        "type": "search_as_you_type"
      }
    }
  }
}
POST test/_doc
{
  "id" : "my dog is a great search engine"
}
GET test/_search
{
  "query": {
    "multi_match": {
      "query": "search engine",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

Hi @michel.st-louis Welcome to the community!

Oops... put your data in the wrong field should be in the content field not the id field :slight_smile:

POST test/_doc
{
  "id" : "my dog is a great search engine"
}

Should be

POST test/_doc
{
  "content" : "my dog is a great search engine"
}

So now...

GET test/_search
{
  "query": {
    "multi_match": {
      "query": "search engine",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

Result

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 2.287682,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "JNzyZXsBmmhzZ_AM3A6p",
        "_score" : 2.287682,
        "_source" : {
          "content" : "my dog is a great search engine"
        }
      }
    ]
  }
}
1 Like

Your right !! now I get results. I had my eyes on the tree not the forest! but I still don't understand why this field is called search_as_you_type it return all the content field, am I going to have to index every words ? If I type lets say "gre" the search should come out with "great" or "great search".

I think you need to experiment this search will return the document as well

GET test/_search
{
  "query": {
    "multi_match": {
      "query": "gre",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

Apologies, I am unclear exactly what you mean...

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