@Test void mapQueryRuleAttributeSearchReferencedAttribute() { when(queryRule.getField()).thenReturn("attr"); when(queryRule.getValue()).thenReturn("val"); when(entityType.getIndexingDepth()).thenReturn(1); when(entityType.getAttributeByName("attr")).thenReturn(attribute); when(attribute.hasRefEntity()).thenReturn(true); when(attribute.getRefEntity()).thenReturn(refEntityType); when(refIdAttribute.getDataType()).thenReturn(STRING); when(refEntityType.getIdAttribute()).thenReturn(refIdAttribute); when(documentIdGenerator.generateId(refIdAttribute)).thenReturn("refAttr"); when(documentIdGenerator.generateId(attribute)).thenReturn("attr"); QueryBuilder queryBuilder = searchQueryGenerator.mapQueryRule(queryRule, entityType); QueryBuilder expectedQueryBuilder = QueryBuilders.nestedQuery( "attr", simpleQueryStringQuery("val").field("attr.refAttr").defaultOperator(AND), ScoreMode.Avg); assertQueryBuilderEquals(expectedQueryBuilder, queryBuilder); }
QueryBuilder mapQueryRule(QueryRule queryRule, EntityType entityType) { if (queryRule.getValue() == null) { throw new MolgenisQueryException(QUERY_VALUE_CANNOT_BE_NULL_MSG); } if (queryRule.getField() == null) { return createQueryClauseSearchAll(queryRule); } else { return createQueryClauseSearchAttribute(queryRule, entityType); } }
QueryClauseSearchQueryGenerator extends BaseQueryClauseGenerator { QueryBuilder mapQueryRule(QueryRule queryRule, EntityType entityType) { if (queryRule.getValue() == null) { throw new MolgenisQueryException(QUERY_VALUE_CANNOT_BE_NULL_MSG); } if (queryRule.getField() == null) { return createQueryClauseSearchAll(queryRule); } else { return createQueryClauseSearchAttribute(queryRule, entityType); } } }
QueryClauseSearchQueryGenerator extends BaseQueryClauseGenerator { QueryBuilder mapQueryRule(QueryRule queryRule, EntityType entityType) { if (queryRule.getValue() == null) { throw new MolgenisQueryException(QUERY_VALUE_CANNOT_BE_NULL_MSG); } if (queryRule.getField() == null) { return createQueryClauseSearchAll(queryRule); } else { return createQueryClauseSearchAttribute(queryRule, entityType); } } QueryClauseSearchQueryGenerator(DocumentIdGenerator documentIdGenerator); }
QueryClauseSearchQueryGenerator extends BaseQueryClauseGenerator { QueryBuilder mapQueryRule(QueryRule queryRule, EntityType entityType) { if (queryRule.getValue() == null) { throw new MolgenisQueryException(QUERY_VALUE_CANNOT_BE_NULL_MSG); } if (queryRule.getField() == null) { return createQueryClauseSearchAll(queryRule); } else { return createQueryClauseSearchAttribute(queryRule, entityType); } } QueryClauseSearchQueryGenerator(DocumentIdGenerator documentIdGenerator);  }
QueryClauseSearchQueryGenerator extends BaseQueryClauseGenerator { QueryBuilder mapQueryRule(QueryRule queryRule, EntityType entityType) { if (queryRule.getValue() == null) { throw new MolgenisQueryException(QUERY_VALUE_CANNOT_BE_NULL_MSG); } if (queryRule.getField() == null) { return createQueryClauseSearchAll(queryRule); } else { return createQueryClauseSearchAttribute(queryRule, entityType); } } QueryClauseSearchQueryGenerator(DocumentIdGenerator documentIdGenerator);   }