Skip to content

Commit

Permalink
refactor: add isDocument() method to the SearchStream interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden committed Jun 7, 2024
1 parent 63e2f0a commit c778d11
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ public <R> SearchStream<T> highlight(Function<? super T, ? extends R> field, Pai
throw new UnsupportedOperationException("highlight is not supported on a ReturnFieldSearchStream");
}

@Override
public boolean isDocument() {
return isDocument;
}

@Override
public SearchStream<T> findFirstOrElse(Supplier<? extends T> supplier) {
throw new UnsupportedOperationException("findFirstOrElse is not supported on a ReturnFieldSearchStream");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ public interface SearchStream<E> extends BaseStream<E, SearchStream<E>> {
<R> SearchStream<E> highlight(Function<? super E, ? extends R> field);

<R> SearchStream<E> highlight(Function<? super E, ? extends R> field, Pair<String, String> tags);

boolean isDocument();
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,9 @@ public SearchStream<E> findFirstOrElse(Supplier<? extends E> supplier) {
throw new UnsupportedOperationException("findFirstOrElse is not supported on a WrappedSearchStream");
}

@Override
public boolean isDocument() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.domain.*;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatcher;
import org.springframework.data.domain.ExampleMatcher.StringMatcher;
import org.springframework.data.geo.Point;
import org.springframework.data.repository.query.FluentQuery;
Expand Down Expand Up @@ -166,15 +167,15 @@ void testFindByFieldWithExplicitNumericIndexedAnnotation() {
@Test
void testFindByFieldWithExplicitGeoIndexedAnnotation() {
MyHash template = new MyHash();
template.setLocation(new Point(-122.066540, 37.377690));
template.setLocation(new Point(-122.124500, 47.640160));

Example<MyHash> example = Example.of(template);

Optional<MyHash> maybeDoc1 = repository.findOne(example);
assertThat(maybeDoc1).isPresent();
MyHash doc1 = maybeDoc1.get();
assertThat(doc1.getTitle()).isEqualTo("hello mundo");
assertThat(doc1.getANumber()).isEqualTo(2);
assertThat(doc1.getTitle()).isEqualTo("hello world");
assertThat(doc1.getANumber()).isEqualTo(1);
}

@Test
Expand Down

0 comments on commit c778d11

Please sign in to comment.