Hi All,
I try to implement a query from my content with Elasticsearch 2.4
What I need, is displaying all results which ends with e.g. 154, 024... etc.
I've tried:
GET rd_product_lpv1/_search
{
"query": {
"match_phrase_prefix": {
"STD_EXTRN_CODE.STD_EXTRN_CODE_ENDS": {
"query": "154",
"max_expansions": 5
}
}
}
}
The query mentioned above display results, where within the value begins with "154"
Example:
"STD_EXTRN_CODE": "15400007118021",
I want to display results where the value ends with 154
sample code:-
"STD_EXTRN_CODE": "02100007118154",
"STD_EXTRN_CODE": "02101231232024",
Here the settings & mappings I use:
PUT /rd_product_lpv1
{
"settings": {
"analysis": {
"analyzer": {
"analyzer_endswith":{
"tokenizer": "keyword",
"type": "standard",
"filter" : [
"lowercase"
]
}
}
}
},
"mappings": {
"properties": {
"STD_EXTRN_CODE": {
"type": "string",
"fields": {
"STD_EXTRN_CODE_RAW": {
"type": "string",
"index": "not_analyzed",
"norms":{
"enabled": false
},
"fielddata":{
"format": "disabled"
}
},
"STD_EXTRN_CODE_CONTAINS": {
"type": "string",
"analyzer": "str_index_analyzer",
"fielddata":{
"format": "disabled"
}
},
"STD_EXTRN_CODE_ENDS": {
"type": "string",
"analyzer": "analyzer_endswith",
"fielddata":{
"format": "disabled"
}
}
}
}
}
}
}
Here the sample data,
POST rd_product_lpv1/product_lpv/1
{
"STD_EXTRN_CODE": "15400007118021"
}
POST rd_product_lpv1/product_lpv/1
{
"STD_EXTRN_CODE": "02100007118154"
}
Please let me know your thoughts
Thanks,
Ganeshbabu R