Ngram not workign for multivalued field

Hi All,

Couple of questions:

  1. We are trying to create an index having an analyzed multi value field (filter used is n-gram).
    But we are not able to query the partial values. But when we have analyzed single valued field everything is working as expected, i.f able to retrieve partial query results as well.

Create index:
curl -X PUT "http://localhost:9200/xxxx-test" -d '{
"mappings" : {
"test" : {
"properties" : {
"lists" : {
"properties" : {
"url_domain" : {
"type" : "string",
"search_analyzer" : "str_search_analyzer",
"index_analyzer" : "str_index_analyzer"
}
}
}
}
}
},

"settings" : {
"analysis" : {
"analyzer" : {

  "str_search_analyzer" : {
      "tokenizer" : "keyword",
      "filter" : ["lowercase"]
    },
    "str_index_analyzer" : {
      "tokenizer" : "keyword",
      "filter" : ["lowercase", "substring"]
    }
  },

  "filter" : {
    "substring" : {
      "type" : "nGram",
      "min_gram" : 2,
      "max_gram"  : 5
    }
  }
}

}
}’;

Sample values inserted
curl -X POST "http://localhost:9200/xxx-test/test" -d '{
"url_domain" : "slkd"
}'
curl -X POST "http://localhost:9200/xxx-test/test" -d '{
"url_domain" : ["a1b2c","c1de"]
}’

Search query used and got some results as expected(this is entire string match)
curl "http://localhost:9200/xxx-test/_search" -d '{
"query": {
"match": {"url_domain": “a1b2c"}
}
}’

Search query used but didn’t give any results(this is a partial match)
curl "http://localhost:9200/xxx-test/_search" -d '{
"query": {
"match": {"url_domain": "1b2"}
}
}’
As the field is n gram analysed, we are expecting a result for this query. Let us know if our understanding is wrong?

  1. We have a query with collection of dynamic terms eg: title:test AND title:west AND desc:world AND desc:hello, now our objective is to avoid terms in the query having document frequency > 10 within the specific field. I.,e if title:west has df as 11 and desc:world has df 20, elastic search should be internally changing the query to title:west AND desc:hello, let us know if this can be done in effective way, as our search queries are very high!

  2. We are using ngram for prefix,suffix and fuzzy queries are there any effective ways to store the index for the same?