Hi ,
I have an array for field commodity line [3,35,1,11,12].I am trying to query the field for autocomplete results and i need output as 3 and 35 when i match with 3.My indexing works fine for all scenarios excpeting an array.
Is there an issue with my indexing or do i have to change my query.
Query used:
GET contracts/doc/_search
{
"query":{
"bool":{
"filter":{
"match_phrase":{
"commodity_line.autocomplete":"3"
}
}
}
},
"aggs":{
"commodity":{
"terms":{
"field": "commodity_line.keyword"
, "size":1000
}
}
}
}
Mapping:
PUT contracts
{
"settings":{
"analysis":{
"filter":{
"gramFilter": {
"type": "edge_ngram",
"min_gram" : 1,
"max_gram" : 20,
"token_chars": [
"letter",
"symbol",
"digit"
]
}
},
"analyzer":{
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"trim",
"gramFilter",
"asciifolding"
]
}
}
}
}
,
"mappings":{
"doc":{
"properties":{
"commodity_line" :{
"type":"text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"autocomplete":{
"type":"text",
"analyzer":"autocomplete",
"search_analyzer":"standard"
}
}
}
}
}