Skip to content

Commit

Permalink
The cites collector is behaving weirdly
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Oct 3, 2016
1 parent 6dc759f commit 7ea5cb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ protected QueryNode postProcessNode(QueryNode node)
if (node instanceof WildcardQueryNode) {
field = ((WildcardQueryNode) node).getFieldAsString();
value = ((WildcardQueryNode) node).getTextAsString();
if (value.indexOf('*') == 0 || value.indexOf('?') == 0)
return node; //let the analyzer decide the fate

for (String suffix: new String[]{"_wildcard", ""}) {
if (hasAnalyzer(field + suffix)) {
tokens = analyze(field + suffix, "foo*bar");
tokens = analyze(field + suffix, value);

if (tokens.length > 1 || value.indexOf('*') == 0 || value.indexOf('?') == 0)
if (tokens.length > 1)
return node; // break, let the analyzer decide the fate

if (!tokens[0].equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;

import monty.solr.util.MontySolrAbstractTestCase;
import monty.solr.util.MontySolrSetup;
Expand Down Expand Up @@ -136,12 +139,12 @@ public void testCitesCollector() throws Exception {
HashMap<Integer, int[]> references = createRandomDocs(0, new Float(maxHits * 0.4f).intValue());


assertU(commit()); // closes the writer, create a new segment
assertU(commit("waitSearcher", "true")); // closes the writer, create a new segment

references.putAll(createRandomDocs(new Float(maxHits * 0.3f).intValue(), new Float(maxHits * 0.7f).intValue()));


assertU(commit()); // closes the writer, create a new segment
assertU(commit("waitSearcher", "true")); // closes the writer, create a new segment
references.putAll(createRandomDocs(new Float(maxHits * 0.71f).intValue(), new Float(maxHits * 1.0f).intValue()));

assertU(commit("waitSearcher", "true")); // closes the writer, create a new segment
Expand Down Expand Up @@ -339,12 +342,21 @@ private boolean hitsEquals(int[] thisDocCites, HashMap<Integer, int[]> cites, Sc
return false;
}
}
Set<Integer> exp = new HashSet<Integer>();
ArrayList<Integer> expected = new ArrayList<Integer>();
for (int r: thisDocCites) {
if (cites.containsKey(r)) {
expected.add(r);
exp.add(r);
}
}
for (Integer x: exp) {
expected.add(x);
}
Collections.sort(expected);
Collections.sort(result);


assertEquals(expected, result);
if (!(result.containsAll(expected) && expected.containsAll(result))) {
System.err.println("expected: " + expected.toString() + " actual: " + result.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public QueryNode process(QueryNode queryTree) throws QueryNodeException {
newMap = oldMap;

int i = 1;
System.out.println( this.getClass().toGenericString());
System.out.println(" 0. starting");
System.out.println("--------------------------------------------");
System.out.println(oldVal);
Expand Down

0 comments on commit 7ea5cb8

Please sign in to comment.