use of com.enonic.xp.query.filter.IdFilter in project xp by enonic.
the class CopyExecutor method createQuery.
private ElasticsearchQuery createQuery() {
final IdFilter idFilter = IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(copyRequest.getNodeIds()).build();
final QueryBuilder idFilterBuilder = new FilterBuilderFactory(new SearchQueryFieldNameResolver()).create(Filters.from(idFilter));
QueryBuilder query = QueryBuilders.matchAllQuery();
return ElasticsearchQuery.create().query(QueryBuilders.filteredQuery(query, idFilterBuilder)).addIndexName(copyRequest.getStorageSource().getStorageName().getName()).addIndexType(copyRequest.getStorageSource().getStorageType().getName()).size(copyRequest.getNodeIds().getSize()).batchSize(BATCH_SIZE).from(0).setReturnFields(ReturnFields.from(NodeIndexPath.SOURCE)).build();
}
use of com.enonic.xp.query.filter.IdFilter in project xp by enonic.
the class JsonToFilterMapperTest method ids_filter.
@Test
public void ids_filter() throws Exception {
Map<String, Object> value = new HashMap<>();
List<String> values = List.of("fisk", "ost", "løk");
final HashMap<String, Object> valueFilter = new HashMap<>();
valueFilter.put("values", values);
value.put("ids", valueFilter);
final Filters filters = com.enonic.xp.lib.common.JsonToFilterMapper.create(value);
assertTrue(filters.get(0) instanceof IdFilter);
assertEquals(3, ((IdFilter) filters.get(0)).getValues().size());
}
Aggregations