How to use search_as_you_type datatype to get substring(infix) completion

Hi,
The new search_as_you_type feature should provide both infix and prefix completion, but i am seeing only prefix completion.

{
"mappings":{
"properties":{
"mail":{"type":"search_as_you_type"}
}}}

and the query which i am using is,

{
	"track_total_hits":true,
	"_source":"mail",
  "query": {
  "multi_match": {
      "query": "sam",
      "type": "bool_prefix",
      "fields": [
        "mail",
        "mail._2gram",
        "mail._3gram",
	"mail._index_prefix"
      ]
    }
  }
}

But in the response i am only able to see results which starts with sam like:
sam.a@gmail.com
sam.b@gmail.com

and i am also looking for results like :
aa.dgsfsamgh@gmail.com

what changes should i make in query?

Thanks.....

What dues your mapping look like?

{
"mappings":{
	"dynamic":false,
"properties":{
"cn":{
	"type":"text",
	"fields":{
"keyword":{
"type":"keyword"
}
},
"analyzer":"autocomplete"
	},
"mail":{"type":"search_as_you_type"}
}
},
"settings":{
	"index.mapping.total_fields.limit":5000,
"index":{
"number_of_replicas":0
},
"analysis": {
      "analyzer": {
        "autocomplete": {
          "tokenizer": "my_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "my_tokenizer": {
          "type": "ngram",
          "min_gram": 3,
          "max_gram": 3,
          "token_chars": [
            "letter",
            "digit"
          ]
        }
      }
    }
}
}

basically i have more than 2K fields ,all have text data type only cn and mail have different ones. thats why i am mentioning only two.
the custom analyzer is working fine for both infix and prefix completion but i want to use search_as_you_type.

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