ElasticSearch版本:5.6
我在ElasticSearch中导入了MySQL数据,并根据需要向ElasticSearch添加了映射。下面是该列的一个映射
application_status
.
映射:
{
"settings": {
"analysis": {
"analyzer": {
"case_insensitive": {
"type": "custom",
"tokenizer": "keyword",
"filter": ["lowercase"]
}
}
}
},
"mappings": {
"lead": {
"properties": {
"application_status": {
"type": "string",
"analyzer": "case_insensitive",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}}
在上面的映射中,我能够进行简单的排序(
asc
或
desc
)使用以下查询:
{
"size": 50,
"from": 0,
"sort": [{
"application_status.keyword": {
"order": "asc"
}
}]}
MySql等价于
select * from <table_name> order by application_status asc limit 50;
需要以下问题的帮助:
我有MySQL查询,它根据
应用程序状态
:
select * from vLoan_application_grid order by CASE WHEN application_status = "IP_QUAL_REASSI" THEN application_status END desc, CASE WHEN application_status = "IP_COMPLE" THEN application_status END desc, CASE WHEN application_status LIKE "IP_FRESH%" THEN application_status END desc, CASE WHEN application_status LIKE "IP_%" THEN application_status END desc
请帮助我在ElasticSearch中编写相同的查询。我找不到
order by value
等效于
strings
在ElasticSearch中。在网上搜索,我明白,我应该使用
sorting scripts
我有下面的查询,它只做简单的排序。
{
"size": 500,
"from": 0,
"query" : {
"match_all": {}
},
"sort": {
"_script": {
"type": "string",
"script": {
"source": "doc['application_status.keyword'].value",
"params": {
"factor": ["IP_QUAL_REASS", "IP_COMPLE"]
}
},
"order": "desc"
}
}}
在上述查询中,我没有使用
params
部分,因为我不知道如何使用它
type: string
我想我要求的太多了。请提供帮助或任何相关文档链接,我们将不胜感激。希望问题很清楚。如有必要,我会提供更多细节。