-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1828b94
commit 2c2a2d5
Showing
6 changed files
with
182 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
bingo/bingo-elastic/java/src/main/java/com/epam/indigo/sort/FieldComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.epam.indigo.sort; | ||
|
||
import com.epam.indigo.model.IndigoRecord; | ||
import org.elasticsearch.search.sort.FieldSortBuilder; | ||
import org.elasticsearch.search.sort.SortBuilder; | ||
import org.elasticsearch.search.sort.SortOrder; | ||
|
||
public class FieldComparator<T extends IndigoRecord> extends IndigoComparator<T> { | ||
|
||
protected String fieldName; | ||
|
||
public FieldComparator(final String fieldName, final SortOrder sortOrder) { | ||
super(sortOrder); | ||
this.fieldName = fieldName; | ||
} | ||
|
||
@Override | ||
public int compare(final T o1, final T o2) { | ||
// does not expect to be called | ||
return 0; | ||
} | ||
|
||
@Override | ||
public SortBuilder<FieldSortBuilder> toSortBuilder() { | ||
return new FieldSortBuilder(this.fieldName).order(this.sortOrder); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
bingo/bingo-elastic/java/src/main/java/com/epam/indigo/sort/IndigoComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.epam.indigo.sort; | ||
|
||
import com.epam.indigo.model.IndigoRecord; | ||
import org.elasticsearch.search.sort.SortBuilder; | ||
import org.elasticsearch.search.sort.SortOrder; | ||
|
||
import java.util.Comparator; | ||
|
||
|
||
public abstract class IndigoComparator<T extends IndigoRecord> implements Comparator<T> { | ||
protected SortOrder sortOrder; | ||
|
||
public IndigoComparator(SortOrder sortOrder) { | ||
this.sortOrder = sortOrder; | ||
} | ||
|
||
public abstract SortBuilder toSortBuilder(); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
bingo/bingo-elastic/java/src/main/java/com/epam/indigo/sort/ScoreComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.epam.indigo.sort; | ||
|
||
import com.epam.indigo.model.IndigoRecord; | ||
import org.elasticsearch.search.sort.ScoreSortBuilder; | ||
import org.elasticsearch.search.sort.SortBuilder; | ||
import org.elasticsearch.search.sort.SortOrder; | ||
|
||
public class ScoreComparator<T extends IndigoRecord> extends IndigoComparator<T> { | ||
|
||
public ScoreComparator() { | ||
super(SortOrder.DESC); | ||
} | ||
|
||
public ScoreComparator(SortOrder sortOrder) { | ||
super(sortOrder); | ||
} | ||
|
||
@Override | ||
public SortBuilder<ScoreSortBuilder> toSortBuilder() { | ||
return new ScoreSortBuilder().order(sortOrder); | ||
} | ||
|
||
@Override | ||
public int compare(final T o1, final T o2) { | ||
// does not expect to be called | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters