protected QueryBuilder getFilterForHasPropertyContainer(HasPropertyContainer hasProperty) { PropertyDefinition[] propertyDefinitions = StreamSupport.stream(hasProperty.getKeys().spliterator(), false) .map(this::getPropertyDefinition) .filter(Objects::nonNull) .toArray(PropertyDefinition[]::new); if (propertyDefinitions.length == 0) { // If we didn't find any property definitions, this means none of them are defined on the graph throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } List<QueryBuilder> filters = new ArrayList<>(); for (PropertyDefinition propDef : propertyDefinitions) { String[] propertyNames = getPropertyNames(propDef.getPropertyName()); for (String propertyName : propertyNames) { filters.add(QueryBuilders.existsQuery(propertyName)); if (GeoShape.class.isAssignableFrom(propDef.getDataType())) { filters.add(QueryBuilders.existsQuery(propertyName + Elasticsearch5SearchIndex.GEO_PROPERTY_NAME_SUFFIX)); } else if (isExactMatchPropertyDefinition(propDef)) { filters.add(QueryBuilders.existsQuery(propertyName + Elasticsearch5SearchIndex.EXACT_MATCH_PROPERTY_NAME_SUFFIX)); } } } if (filters.isEmpty()) { // If we didn't add any filters, this means it doesn't exist on any elements so raise an error throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } return getSingleFilterOrOrTheFilters(filters, hasProperty); }
protected FilterBuilder getFilterForHasPropertyContainer(HasPropertyContainer hasProperty) { PropertyDefinition[] propertyDefinitions = StreamSupport.stream(hasProperty.getKeys().spliterator(), false) .map(this::getPropertyDefinition) .filter(Objects::nonNull) .toArray(PropertyDefinition[]::new); if (propertyDefinitions.length == 0) { // If we didn't find any property definitions, this means none of them are defined on the graph throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } List<FilterBuilder> filters = new ArrayList<>(); for (PropertyDefinition propDef : propertyDefinitions) { String[] propertyNames = getPropertyNames(propDef.getPropertyName()); for (String propertyName : propertyNames) { filters.add(FilterBuilders.existsFilter(propertyName)); if (propDef.getDataType().equals(GeoPoint.class)) { filters.add(FilterBuilders.existsFilter(propertyName + ElasticsearchSingleDocumentSearchIndex.GEO_PROPERTY_NAME_SUFFIX)); } else if (isExactMatchPropertyDefinition(propDef)) { filters.add(FilterBuilders.existsFilter(propertyName + ElasticsearchSingleDocumentSearchIndex.EXACT_MATCH_PROPERTY_NAME_SUFFIX)); } } } if (filters.isEmpty()) { // If we didn't add any filters, this means it doesn't exist on any elements so raise an error throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } return getSingleFilterOrOrTheFilters(filters, hasProperty); }
protected QueryBuilder getFilterForHasPropertyContainer(HasPropertyContainer hasProperty) { PropertyDefinition[] propertyDefinitions = StreamSupport.stream(hasProperty.getKeys().spliterator(), false) .map(this::getPropertyDefinition) .filter(Objects::nonNull) .toArray(PropertyDefinition[]::new); if (propertyDefinitions.length == 0) { // If we didn't find any property definitions, this means none of them are defined on the graph throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } List<QueryBuilder> filters = new ArrayList<>(); for (PropertyDefinition propDef : propertyDefinitions) { String[] propertyNames = getPropertyNames(propDef.getPropertyName()); for (String propertyName : propertyNames) { filters.add(QueryBuilders.existsQuery(propertyName)); if (GeoShape.class.isAssignableFrom(propDef.getDataType())) { filters.add(QueryBuilders.existsQuery(propertyName + Elasticsearch5SearchIndex.GEO_PROPERTY_NAME_SUFFIX)); } else if (isExactMatchPropertyDefinition(propDef)) { filters.add(QueryBuilders.existsQuery(propertyName + Elasticsearch5SearchIndex.EXACT_MATCH_PROPERTY_NAME_SUFFIX)); } } } if (filters.isEmpty()) { // If we didn't add any filters, this means it doesn't exist on any elements so raise an error throw new VertexiumNoMatchingPropertiesException(Joiner.on(", ").join(hasProperty.getKeys())); } return getSingleFilterOrOrTheFilters(filters, hasProperty); }