SimpleSortField extends SortField { public SimpleSortField(String field, Boolean reverse) { super(reverse); if (field == null || StringUtils.isBlank(field)) { throw new IndexException("Field name required"); } this.field = field; } SimpleSortField(String field, Boolean reverse); String getField(); @Override org.apache.lucene.search.SortField sortField(Schema schema); Set<String> postProcessingFields(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); final String field; }
@Test public void testSimpleSortField() { Schema schema = schema().mapper("field", stringMapper()).build(); SimpleSortField sortField = new SimpleSortField("field", false); org.apache.lucene.search.SortField luceneSortField = sortField.sortField(schema); assertNotNull("SortField is not created", luceneSortField); assertEquals("SortField name is wrong", "field", luceneSortField.getField()); assertFalse("SortField reverse is wrong", luceneSortField.getReverse()); }