@Test public void testCreateQueryChainRange() throws Exception { final List<Query> query = new AttributeSearchQueryBuilder().createQueryChain(null, "size", "30-_-50"); assertNotNull(query); assertEquals(1, query.size()); assertEquals("(size_range:[30 TO 49])^3.5", query.get(0).toString()); }
@Override public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) { if (StringUtils.isBlank(parameter)) { return null; } final String escapedParameter = escapeValue(parameter); if (value instanceof Collection) { final Collection singleValues = (Collection) value; if (singleValues.size() > 1) { final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder(); boolean hasClause = false; for (final Object item : singleValues) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(item)); if (clause != null) { aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD); hasClause = true; } } if (hasClause) { return Collections.singletonList(aggregatedQuery.build()); } } else if (singleValues.size() == 1) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next())); if (clause != null) { return Collections.singletonList(clause); } } return null; } final Query clause = createAttributeQuery(escapedParameter, escapeValue(value)); if (clause != null) { return Collections.singletonList(clause); } return null; }
AttributeSearchQueryBuilder extends AbstractSearchQueryBuilderImpl implements ProductSearchQueryBuilder<Query> { @Override public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) { if (StringUtils.isBlank(parameter)) { return null; } final String escapedParameter = escapeValue(parameter); if (value instanceof Collection) { final Collection singleValues = (Collection) value; if (singleValues.size() > 1) { final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder(); boolean hasClause = false; for (final Object item : singleValues) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(item)); if (clause != null) { aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD); hasClause = true; } } if (hasClause) { return Collections.singletonList(aggregatedQuery.build()); } } else if (singleValues.size() == 1) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next())); if (clause != null) { return Collections.singletonList(clause); } } return null; } final Query clause = createAttributeQuery(escapedParameter, escapeValue(value)); if (clause != null) { return Collections.singletonList(clause); } return null; } }
AttributeSearchQueryBuilder extends AbstractSearchQueryBuilderImpl implements ProductSearchQueryBuilder<Query> { @Override public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) { if (StringUtils.isBlank(parameter)) { return null; } final String escapedParameter = escapeValue(parameter); if (value instanceof Collection) { final Collection singleValues = (Collection) value; if (singleValues.size() > 1) { final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder(); boolean hasClause = false; for (final Object item : singleValues) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(item)); if (clause != null) { aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD); hasClause = true; } } if (hasClause) { return Collections.singletonList(aggregatedQuery.build()); } } else if (singleValues.size() == 1) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next())); if (clause != null) { return Collections.singletonList(clause); } } return null; } final Query clause = createAttributeQuery(escapedParameter, escapeValue(value)); if (clause != null) { return Collections.singletonList(clause); } return null; }  }
AttributeSearchQueryBuilder extends AbstractSearchQueryBuilderImpl implements ProductSearchQueryBuilder<Query> { @Override public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) { if (StringUtils.isBlank(parameter)) { return null; } final String escapedParameter = escapeValue(parameter); if (value instanceof Collection) { final Collection singleValues = (Collection) value; if (singleValues.size() > 1) { final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder(); boolean hasClause = false; for (final Object item : singleValues) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(item)); if (clause != null) { aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD); hasClause = true; } } if (hasClause) { return Collections.singletonList(aggregatedQuery.build()); } } else if (singleValues.size() == 1) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next())); if (clause != null) { return Collections.singletonList(clause); } } return null; } final Query clause = createAttributeQuery(escapedParameter, escapeValue(value)); if (clause != null) { return Collections.singletonList(clause); } return null; }  @Override List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value); }
AttributeSearchQueryBuilder extends AbstractSearchQueryBuilderImpl implements ProductSearchQueryBuilder<Query> { @Override public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) { if (StringUtils.isBlank(parameter)) { return null; } final String escapedParameter = escapeValue(parameter); if (value instanceof Collection) { final Collection singleValues = (Collection) value; if (singleValues.size() > 1) { final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder(); boolean hasClause = false; for (final Object item : singleValues) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(item)); if (clause != null) { aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD); hasClause = true; } } if (hasClause) { return Collections.singletonList(aggregatedQuery.build()); } } else if (singleValues.size() == 1) { final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next())); if (clause != null) { return Collections.singletonList(clause); } } return null; } final Query clause = createAttributeQuery(escapedParameter, escapeValue(value)); if (clause != null) { return Collections.singletonList(clause); } return null; }  @Override List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value);  }