Hi,
I have the following mappings inorder to search and even for sorting that field.
"description": {
"type": "multi_field",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"description":
{
"type": "string",
"analyzer": "analyzer_startswith"
},
"sort_field":
{
"type": "string",
"analyzer": "keyword_analyzer"
}
}
}
}
And here are my analyzers:
"analysis": {
"analyzer": {
"keyword_analyzer": {
"filter": "lowercase",
"tokenizer": "keyword"
},
"analyzer_startswith": {
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
},
"wordAnalyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
],
"tokenizer": "whitespace"
},
"whitespace_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "whitespace"
}
},
"filter": {
"nGram_filter": {
"max_gram": "20",
"min_gram": "1",
"type": "nGram",
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
}
}
These above settings am using...
And here is my query:
GET pdlfull/pdlfull_type/_search
{
"query": {
"match_phrase_prefix": {
"description": "a"
}
},
"sort": [
{
"description.sort_field": {
"order": "asc"
}
}
]
}
When am using the mappings that I kept above am getting one sort of results.
When I removed that raw field and executing the query am getting another sort of results.
May I know what is the reason and which is the best solution
Thanks.