我在PHP中排序有问题,这里是我的映射:
{
"jdbc": {
"mappings": {
"jdbc": {
"properties": {
"admitted_date": {
"type": "date",
"format": "dateOptionalTime"
},
"et_tax": {
"type": "string"
},
"jt_tax": {
"type": "string"
},
"loc_cityname": {
"type": "string"
},
"location_countryname": {
"type": "string"
},
"location_primary": {
"type": "string"
},
"pd_firstName": {
"type": "string"
}
}
}
}
}
}
当我使用排序的结果,它将排序的结果与字母数字,它将加载结果与数字作为第一个。我需要订购的结果只开始字母字母。现在它的顺序是这样的:
http://localhost:9200/jdbc/_search?pretty=true&sort=pd_lawFirmName:asc
- BM&
- Gomez-Acebo,Pombo
Addleshaw Goddard
如何排序这样的结果?
Addleshaw Goddard
- BM&
- Gomez-Acebo,Pombo
这是我用来索引
的查询{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/dbname",
"user" : "user",
"password" : "pass",
"sql" : "SQL QUERY",
"poll" : "24h",
"strategy" : "simple",
"scale" : 0,
"autocommit" : true,
"bulk_size" : 5000,
"max_bulk_requests" : 30,
"bulk_flush_interval" : "5s",
"fetchsize" : 100,
"max_rows" : 149669,
"max_retries" : 3,
"max_retries_wait" : "10s",
"locale" : "in",
"digesting" : true,
"mappings": {
"sorting": {
"properties": {
"pd_lawFirmName": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}
这是因为Elasticsearch将使用默认分析器(standard
)对文本进行标记。例如,McDermott Will Amery
的索引如下:
"amery",
"mcdermott",
"will"
如果你想这样排序,我建议改变你的pd_lawFirmName
的映射像这样:
"pd_lawFirmName": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
并按raw
子字段排序:
http://localhost:9200/jdbc/_search?pretty=true&sort=pd_lawFirmName.raw:asc