use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoJsonIntegrationTests method shouldFindIntersectingObjectsWithCriteriaQuery.
// DATAES-931
@Test
@DisplayName("should find intersecting objects with Criteria query")
void shouldFindIntersectingObjectsWithCriteriaQuery() {
CriteriaQuery query = new CriteriaQuery(new Criteria("area").intersects(geoShape15To25));
SearchHits<Area> searchHits = operations.search(query, Area.class);
assertThat(searchHits.getTotalHits()).isEqualTo(1L);
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("area10To20");
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoJsonIntegrationTests method shouldFindDisjointObjectsWithCriteriaQuery.
// DATAES-931
@Test
@DisplayName("should find disjoint objects with Criteria query")
void shouldFindDisjointObjectsWithCriteriaQuery() {
CriteriaQuery query = new CriteriaQuery(new Criteria("area").isDisjoint(geoShape15To25));
SearchHits<Area> searchHits = operations.search(query, Area.class);
assertThat(searchHits.getTotalHits()).isEqualTo(1L);
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("area30To40");
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class SynonymRepositoryTests method shouldDo.
@Test
public void shouldDo() {
SynonymEntity entry1 = new SynonymEntity();
entry1.setText("Elizabeth is the english queen");
SynonymEntity entry2 = new SynonymEntity();
entry2.setText("Other text");
repository.save(entry1);
repository.save(entry2);
Query query = new CriteriaQuery(new Criteria("text").is("british"));
SearchHits<SynonymEntity> synonymEntities = operations.search(query, SynonymEntity.class);
assertThat(synonymEntities).hasSize(1);
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class RuntimeFieldsIntegrationTests method shouldUseRuntimeFieldFromQueryInSearch.
// #1971
@Test
@DisplayName("should use runtime-field from query in search")
void shouldUseRuntimeFieldFromQueryInSearch() {
insert("1", "item 1", 13.5);
insert("2", "item 2", 15);
Query query = new CriteriaQuery(new Criteria("priceWithTax").greaterThanEqual(16.5));
RuntimeField runtimeField = new RuntimeField("priceWithTax", "double", "emit(doc['price'].value * 1.19)");
query.addRuntimeField(runtimeField);
SearchHits<SomethingToBuy> searchHits = operations.search(query, SomethingToBuy.class);
assertThat(searchHits.getTotalHits()).isEqualTo(1);
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("2");
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method shouldNotTryToCallPropertyConverterOnUpdatingCriteriaExists.
// #2080
@Test
@DisplayName("should not try to call property converter on updating criteria exists")
void shouldNotTryToCallPropertyConverterOnUpdatingCriteriaExists() {
// don't care if the query makes no sense, we just add all criteria without values
Query query = new CriteriaQuery(Criteria.where("fieldWithClassBasedConverter").exists().empty().notEmpty());
mappingElasticsearchConverter.updateQuery(query, EntityWithCustomValueConverters.class);
}
Aggregations