You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2010/10/18 15:50:08 UTC
svn commit: r1023802 - in /lucene/dev: branches/branch_3x/solr/
branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/
trunk/solr/ trunk/solr/src/java/org/apache/solr/spelling/suggest/
Author: ab
Date: Mon Oct 18 13:50:07 2010
New Revision: 1023802
URL: http://svn.apache.org/viewvc?rev=1023802&view=rev
Log:
SOLR-2157 Suggester should return alpha-sorted results when onlyMorePopular=false.
Modified:
lucene/dev/branches/branch_3x/solr/CHANGES.txt
lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java
lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java
lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Mon Oct 18 13:50:07 2010
@@ -236,6 +236,7 @@ New Features
after parsing the functions, instead of silently ignoring it.
This allows expressions like q=dist(2,vector(1,2),$pt)&pt=3,4 (yonik)
+* SOLR-2157 Suggester should return alpha-sorted results when onlyMorePopular=false (ab)
Optimizations
Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java Mon Oct 18 13:50:07 2010
@@ -33,7 +33,7 @@ public abstract class Lookup {
/**
* Result of a lookup.
*/
- public static final class LookupResult {
+ public static final class LookupResult implements Comparable<LookupResult> {
String key;
float value;
@@ -45,6 +45,11 @@ public abstract class Lookup {
public String toString() {
return key + "/" + value;
}
+
+ /** Compare alphabetically. */
+ public int compareTo(LookupResult o) {
+ return this.key.compareTo(o.key);
+ }
}
public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> {
Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java Mon Oct 18 13:50:07 2010
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.apache.lucene.analysis.Token;
@@ -173,6 +174,9 @@ public class Suggester extends SolrSpell
if (suggestions == null) {
continue;
}
+ if (!options.onlyMorePopular) {
+ Collections.sort(suggestions);
+ }
for (LookupResult lr : suggestions) {
res.add(t, lr.key, ((Number)lr.value).intValue());
}
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Oct 18 13:50:07 2010
@@ -525,6 +525,8 @@ Bug Fixes
* 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
----------------------
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java Mon Oct 18 13:50:07 2010
@@ -16,7 +16,7 @@ public abstract class Lookup {
/**
* Result of a lookup.
*/
- public static final class LookupResult {
+ public static final class LookupResult implements Comparable<LookupResult> {
String key;
float value;
@@ -28,6 +28,11 @@ public abstract class Lookup {
public String toString() {
return key + "/" + value;
}
+
+ /** Compare alphabetically. */
+ public int compareTo(LookupResult o) {
+ return this.key.compareTo(o.key);
+ }
}
public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> {
Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java?rev=1023802&r1=1023801&r2=1023802&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java Mon Oct 18 13:50:07 2010
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.util.Collections;
import java.util.List;
import org.apache.lucene.analysis.Token;
@@ -166,6 +167,9 @@ public class Suggester extends SolrSpell
if (suggestions == null) {
continue;
}
+ if (!options.onlyMorePopular) {
+ Collections.sort(suggestions);
+ }
for (LookupResult lr : suggestions) {
res.add(t, lr.key, ((Number)lr.value).intValue());
}