mirror of https://github.com/apache/lucene.git
SOLR-2157 Suggester should return alpha-sorted results when onlyMorePopular=false.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0b31a11206
commit
abbd3f0e4d
|
@ -525,6 +525,8 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-2139: Wrong cast from string to float (Igor Rodionov via koji)
|
* SOLR-2139: Wrong cast from string to float (Igor Rodionov via koji)
|
||||||
|
|
||||||
|
* SOLR-2157 Suggester should return alpha-sorted results when onlyMorePopular=false (ab)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ public abstract class Lookup {
|
||||||
/**
|
/**
|
||||||
* Result of a lookup.
|
* Result of a lookup.
|
||||||
*/
|
*/
|
||||||
public static final class LookupResult {
|
public static final class LookupResult implements Comparable<LookupResult> {
|
||||||
String key;
|
String key;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ public abstract class Lookup {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return key + "/" + value;
|
return key + "/" + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compare alphabetically. */
|
||||||
|
public int compareTo(LookupResult o) {
|
||||||
|
return this.key.compareTo(o.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> {
|
public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Token;
|
import org.apache.lucene.analysis.Token;
|
||||||
|
@ -166,6 +167,9 @@ public class Suggester extends SolrSpellChecker {
|
||||||
if (suggestions == null) {
|
if (suggestions == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!options.onlyMorePopular) {
|
||||||
|
Collections.sort(suggestions);
|
||||||
|
}
|
||||||
for (LookupResult lr : suggestions) {
|
for (LookupResult lr : suggestions) {
|
||||||
res.add(t, lr.key, ((Number)lr.value).intValue());
|
res.add(t, lr.key, ((Number)lr.value).intValue());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue