@Override public FullTextQueryImpl setProjection(String... fields) { hSearchQuery.projection( fields ); return this; }
@Override public CacheQuery<Object[]> projection(String... fields) { this.projectionConverter = new ProjectionConverter(fields, cache, keyTransformationHandler); hSearchQuery.projection(projectionConverter.getHSearchProjection()); return (CacheQuery<Object[]>) this; }
@Override public CacheQuery<Object[]> projection(String... fields) { projectionConverter = new ProjectionConverter(fields, keyTransformationHandler); queryDefinition.getHsQuery().projection(projectionConverter.getHSearchProjection()); return (CacheQuery<Object[]>) this; }
public AssertBuildingHSQueryContext projecting(String ... projections) { before = before.andThen( q -> q.projection( projections ) ); return this; }
private List<Object[]> doQuery(Query mltQuery) { List<EntityInfo> results = helper.hsQuery( mltQuery, Coffee.class ) .projection( ProjectionConstants.ID, ProjectionConstants.SCORE ) .queryEntityInfos(); return results.stream().map( EntityInfo::getProjection ).collect( Collectors.toList() ); }
@Test public void clear_projection() throws Exception { HSQuery hsQuery = queryAll(); hsQuery.projection( ProjectionConstants.ID ); helper.assertThat( hsQuery ).matchesExactlySingleProjections( 0, 1, 2 ); hsQuery.projection( ProjectionConstants.ID, "field" ); helper.assertThat( hsQuery ).matchesExactlyProjections( new Object[][]{ { 0, "zero" }, { 1, "one" }, { 2, "two" }, } ); }
@Test @TestForIssue(jiraKey = "HSEARCH-1987") public void testNumericMappingOfEmbeddedFields() { List<EntityInfo> list = helper.hsQuery( ScoreBoard.class ) .projection( ProjectionConstants.DOCUMENT ) .queryEntityInfos(); assertEquals( 1, list.size() ); Document document = (Document) list.iterator().next().getProjection()[0]; IndexableField scoreNumeric = document.getField( "score_id" ); assertThat( scoreNumeric.numericValue() ).isEqualTo( 1 ); IndexableField beta = document.getField( "score_beta" ); assertThat( beta.numericValue() ).isEqualTo( 100 ); }
@Test @TestForIssue(jiraKey = "HSEARCH-1987") public void testOneOfSeveralFieldsIsNumeric() { List<EntityInfo> list = helper.hsQuery( TouristAttraction.class ) .projection( ProjectionConstants.DOCUMENT ) .queryEntityInfos(); assertEquals( 1, list.size() ); Document document = (Document) list.iterator().next().getProjection()[0]; IndexableField scoreNumeric = document.getField( "scoreNumeric" ); assertThat( scoreNumeric.numericValue() ).isEqualTo( 23 ); IndexableField scoreString = document.getField( "scoreString" ); assertThat( scoreString.numericValue() ).isNull(); assertThat( scoreString.stringValue() ).isEqualTo( "23" ); }
List<EntityInfo> entityInfos = query .maxResults( 1 ) .projection( HSQuery.DOCUMENT_ID ) .queryEntityInfos(); if ( entityInfos.size() == 0 ) {
List<EntityInfo> entityInfos = query .maxResults( 1 ) .projection( HSQuery.DOCUMENT_ID ) .queryEntityInfos(); if ( entityInfos.size() == 0 ) {
public void initialize(AdvancedCache<?, ?> cache) { if (hsQuery == null) { QueryEngine queryEngine = getQueryEngine(cache); HsQueryRequest hsQueryRequest; if (indexedType != null && sortableFields != null) { IndexedTypeMap<CustomTypeMetadata> metadata = createMetadata(); hsQueryRequest = queryEngine.createHsQuery(queryString, metadata, namedParameters); } else { hsQueryRequest = queryEngine.createHsQuery(queryString, null, namedParameters); } hsQuery = hsQueryRequest.getHsQuery(); sort = hsQueryRequest.getSort(); hsQuery.firstResult(firstResult); hsQuery.maxResults(maxResults); hsQuery.projection(hsQueryRequest.getProjections()); } }
private HSQuery getQuery(Query luceneQuery) { ExtendedSearchIntegrator sf = sfHolder.getSearchFactory(); HSQuery hsQuery = sf.createHSQuery( luceneQuery, IndexedObject.class ); return hsQuery .projection( "id" ) .sort( new Sort( new SortField( "idSort", SortField.Type.INT ) ) ); }
.projection( ElasticsearchProjectionConstants.ID ) .queryEntityInfos(); assertThat( result ).as( "Both documents (with field '" + field + "' index as null and with the same field" .projection( ElasticsearchProjectionConstants.ID, field, ElasticsearchProjectionConstants.SOURCE ) .queryEntityInfos(); for ( EntityInfo entityInfo : result ) { .projection( ElasticsearchProjectionConstants.ID ) .queryEntityInfos(); assertThat( result ).as( "Both documents (with field '" + field + "' index as null and with the same field equal"
public HsQueryRequest createHsQuery(String queryString, IndexedTypeMap<CustomTypeMetadata> metadata, Map<String, Object> nameParameters) { IckleParsingResult<TypeMetadata> parsingResult = parse(queryString); if (parsingResult.hasGroupingOrAggregations()) { throw log.groupAggregationsNotSupported(); } LuceneQueryParsingResult luceneParsingResult = transformParsingResult(parsingResult, nameParameters); org.apache.lucene.search.Query luceneQuery = makeTypeQuery(luceneParsingResult.getQuery(), luceneParsingResult.getTargetEntityName()); SearchIntegrator searchFactory = getSearchFactory(); HSQuery hsQuery = metadata == null ? searchFactory.createHSQuery(luceneQuery) : searchFactory.createHSQuery(luceneQuery, metadata); Sort sort = luceneParsingResult.getSort(); if (sort != null) { hsQuery.sort(sort); } String[] projections = luceneParsingResult.getProjections(); if (projections != null) { hsQuery.projection(projections); } return new HsQueryRequest(hsQuery, sort, projections); }
private void expectedProjections(NumericRangeQuery<Long> numericRangeQuery, String... expectedProjections) { SearchIntegrator searchFactory = factoryHolder.getSearchFactory(); QueryBuilder queryBuilder = helper.queryBuilder( Staff.class ); HSQuery hsQuery = searchFactory.createHSQuery( numericRangeQuery, Staff.class ) .projection( "name" ) .sort( queryBuilder.sort().byField( "idSort" ).createSort() ); helper.assertThat( hsQuery ) .matchesExactlySingleProjections( expectedProjections ) .hasResultSize( expectedProjections.length ); }
.projection("surname") .queryEntityInfos();