|
|
@@ -38,8 +38,8 @@ public class StringFieldComparatorSource extends FieldComparatorSource {
|
|
|
int index1 = str1.indexOf(keyword);
|
|
|
int index2 = str2.indexOf(keyword);
|
|
|
// 一方包含关键词,另一方不包含时,该方排序靠前
|
|
|
- if (index1 > 0) {
|
|
|
- if (index2 > 0) {
|
|
|
+ if (index1 >= 0) {
|
|
|
+ if (index2 >= 0) {
|
|
|
// 均包含关键词时,比较关键词在字符串中的位置,位置越靠前,最终排序越靠前
|
|
|
if (index1 < index2) {
|
|
|
return AHEAD;
|
|
|
@@ -53,7 +53,7 @@ public class StringFieldComparatorSource extends FieldComparatorSource {
|
|
|
return AHEAD;
|
|
|
}
|
|
|
} else {
|
|
|
- if (index2 > 0) {
|
|
|
+ if (index2 >= 0) {
|
|
|
return BEHIND;
|
|
|
} else {
|
|
|
// 均不包含关键词时,比较字符串长度,长度较短,则排序靠前
|