Merge lp:~mmcm/akiban-server/full-text-search-sort into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2642
Merged at revision: 2643
Proposed branch: lp:~mmcm/akiban-server/full-text-search-sort
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 74 lines (+15/-9)
3 files modified
src/main/java/com/akiban/server/service/text/FullTextCursor.java (+7/-1)
src/test/resources/com/akiban/rest/text/name.expected (+4/-4)
src/test/resources/com/akiban/rest/text/wildcard.expected (+4/-4)
To merge this branch: bzr merge lp:~mmcm/akiban-server/full-text-search-sort
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+160960@code.launchpad.net

Description of the change

Address the recent test failures due to unpredictable ordering returned by full text queries.

Give an explicit Sort order: first by relevance, then by hkey.

Puts expected results back to the order they had before begin changed for asynchronous update, where there were only given an order that was somewhat more likely, but still depended on the number of times the updater ran.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

Makes sense.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/server/service/text/FullTextCursor.java'
2--- src/main/java/com/akiban/server/service/text/FullTextCursor.java 2013-04-05 20:33:47 +0000
3+++ src/main/java/com/akiban/server/service/text/FullTextCursor.java 2013-04-25 17:14:26 +0000
4@@ -35,6 +35,8 @@
5 import org.apache.lucene.search.Query;
6 import org.apache.lucene.search.ScoreDoc;
7 import org.apache.lucene.search.SearcherManager;
8+import org.apache.lucene.search.Sort;
9+import org.apache.lucene.search.SortField;
10 import org.apache.lucene.search.TopDocs;
11 import org.apache.lucene.util.BytesRef;
12
13@@ -55,6 +57,10 @@
14 private TopDocs results;
15 private int position;
16
17+ public static final Sort SORT = new Sort(SortField.FIELD_SCORE,
18+ new SortField(IndexedField.KEY_FIELD,
19+ SortField.Type.STRING));
20+
21 private static final Logger logger = LoggerFactory.getLogger(FullTextCursor.class);
22
23 public FullTextCursor(QueryContext context, HKeyRowType rowType,
24@@ -78,7 +84,7 @@
25 }
26 else {
27 try {
28- results = searcher.search(query, limit);
29+ results = searcher.search(query, limit, SORT);
30 }
31 catch (IOException ex) {
32 throw new AkibanInternalException("Error searching index", ex);
33
34=== modified file 'src/test/resources/com/akiban/rest/text/name.expected'
35--- src/test/resources/com/akiban/rest/text/name.expected 2013-04-17 16:23:40 +0000
36+++ src/test/resources/com/akiban/rest/text/name.expected 2013-04-25 17:14:26 +0000
37@@ -1,10 +1,10 @@
38 [
39 {
40+ "name": "John Smith",
41+ "cid": 1
42+ },
43+ {
44 "name": "Jane Smith",
45 "cid": 3
46- },
47- {
48- "name": "John Smith",
49- "cid": 1
50 }
51 ]
52
53=== modified file 'src/test/resources/com/akiban/rest/text/wildcard.expected'
54--- src/test/resources/com/akiban/rest/text/wildcard.expected 2013-04-17 16:23:40 +0000
55+++ src/test/resources/com/akiban/rest/text/wildcard.expected 2013-04-25 17:14:26 +0000
56@@ -1,14 +1,14 @@
57 [
58 {
59+ "name": "John Smith",
60+ "cid": 1
61+ },
62+ {
63 "name": "Jane Smith",
64 "cid": 3
65 },
66 {
67 "name": "Jonathan Smyth",
68 "cid": 4
69- },
70- {
71- "name": "John Smith",
72- "cid": 1
73 }
74 ]

Subscribers

People subscribed via source and target branches