Search with target count search response.

@param searchRequestBuilder the search request builder
@param aggregationBuilders  the aggregation builders
@return the search response
487191
public SearchResponse searchWithTargetCount(
            SearchRequestBuilder searchRequestBuilder,
            AggregationBuilder[] aggregationBuilders) {
        return searchWithTargetCount(getSearchRequestBuilder(
                getSearchRequestBuilderWithCount(searchRequestBuilder),
                aggregationBuilders));
    }
1156414
public GetRequestBuilder<T,ID> find(ID... ids)
    {
        return new GetRequestBuilder<T, ID>(version,type,entityName,ids);
    }
44577
protected function performSearch(Builder $builder, array $options = [])
    {
        if ($builder->callback) {
            return call_user_func(
                $builder->callback,
                ElasticClient::getFacadeRoot(),
                $builder->query,
                $options
            );
        }

        $results = [];

        $this
            ->buildSearchQueryPayloadCollection($builder, $options)
            ->each(function ($payload) use (&$results) {
                $results = ElasticClient::search($payload);

                $results['_payload'] = $payload;

                if ($this->getTotalCount($results) > 0) {
                    return false;
                }
            });

        return $results;
    }
246105
SCIMSearchResult<Group> searchGroups(Query query, AccessToken accessToken) {
        return searchResources(query, accessToken);
    }
86656
private List populateUsingElasticSearch(Client client, EntityMetadata m)
    {
        Map<String, Object> searchFilter = client.getIndexManager().search(kunderaMetadata, kunderaQuery,
                persistenceDelegeator, m, this.firstResult, this.maxResult);
        Object[] primaryKeys = ((Map<String, Object>) searchFilter.get(Constants.PRIMARY_KEYS)).values().toArray(
                new Object[] {});
        Map<String, Object> aggregations = (Map<String, Object>) searchFilter.get(Constants.AGGREGATIONS);

        Iterable<Expression> resultOrderIterable = (Iterable<Expression>) searchFilter
                .get(Constants.SELECT_EXPRESSION_ORDER);
        List<Object> results = new ArrayList<Object>();

        if (!kunderaQuery.isAggregated())
        {
            results.addAll(findUsingLucene(m, client, primaryKeys));
        }
        else
        {
            if (KunderaQueryUtils.hasGroupBy(kunderaQuery.getJpqlExpression()))
            {
                populateGroupByResponse(aggregations, resultOrderIterable, results, client, m);
            }
            else
            {
                Iterator<Expression> resultOrder = resultOrderIterable.iterator();
                while (resultOrder.hasNext())
                {
                    Expression expression = (Expression) resultOrder.next();

                    if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
                    {
                        if (aggregations.get(expression.toParsedText()) != null)
                        {
                            results.add(aggregations.get(expression.toParsedText()));
                        }
                    }
                    else
                    {
                        results.addAll(findUsingLucene(m, client, new Object[] { primaryKeys[0] }));
                    }
                }
            }
        }

        return results;
    }
52048
@Transactional(readOnly = true)
	public Collection<Response> find(SearchCriteria searchCriteria) {
		CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
		CriteriaQuery<Response> criteriaQuery = criteriaBuilder.createQuery(Response.class);
		Root<Response> root = criteriaQuery.from(Response.class);
		
		Collection<Predicate> conditions = new ArrayList<>();
		
		if (searchCriteria.getUser() != null) {
			Predicate userCondition = criteriaBuilder.equal(root.get("user").get("username"), searchCriteria.getUser().getUsername());
			conditions.add(userCondition);
		}
		
		if (searchCriteria.getDetectionSystemIds() != null) {
			Predicate detectionSystemCondition = root.get("detectionSystem").get("detectionSystemId").in(searchCriteria.getDetectionSystemIds());
			conditions.add(detectionSystemCondition);
		}

		if (conditions.size() > 0) {
			criteriaQuery.where(criteriaBuilder.and(conditions.toArray(new Predicate[0])));
		}
		
		criteriaQuery.orderBy(criteriaBuilder.asc(root.get("timestamp")));

		TypedQuery<Response> query = em.createQuery(criteriaQuery); 
		List<Response> result = query.getResultList();
		
		return result;
	}
467743
@Override
    public Map<String, Object> search(Class<?> clazz, EntityMetadata m, String luceneQuery, int start, int count)
    {
        if (log.isInfoEnabled())
        {
            log.info("Executing lucene query " + luceneQuery);
        }

        ListenableActionFuture<SearchResponse> listenableActionFuture = client
                .prepareSearch(m.getSchema().toLowerCase()).setQuery(QueryBuilders.queryStringQuery(luceneQuery))
                .setSize(40000).execute();
        SearchResponse response = listenableActionFuture.actionGet();

        Map<String, Object> results = new HashMap<String, Object>();
        for (SearchHit hit : response.getHits())
        {
            Object id = PropertyAccessorHelper.fromSourceToTargetClass(
                    ((AbstractAttribute) m.getIdAttribute()).getBindableJavaType(), String.class, hit.getId());
            results.put(hit.getId(), id);
        }
        return results;
    }
769872
public SearchRequestBuilder getSearchRequestBuilderWithMatchAll(
            boolean isSetExplain, String[] indices, String[] types) {
        return getSearchRequestBuilderWithMatchAll(isSetExplain, indices, types,
                null, null);
    }
1220081
protected <T> int executeCountQuery(SearchCriteriaBean criteria, EntityManager entityManager, Class<T> type) {
        CriteriaBuilder builder = entityManager.getCriteriaBuilder();
        CriteriaQuery<Long> countQuery = builder.createQuery(Long.class);
        Root<T> from = countQuery.from(type);
        countQuery.select(builder.count(from));
        applySearchCriteriaToQuery(criteria, builder, countQuery, from, true);
        TypedQuery<Long> query = entityManager.createQuery(countQuery);
        return query.getSingleResult().intValue();
    }
451440
@Override
    public org.fcrepo.server.types.gen.FieldSearchResult findObjects(org.fcrepo.server.types.gen.ArrayOfString resultFields,
                                                                     java.math.BigInteger maxResults,
                                                                     org.fcrepo.server.types.gen.FieldSearchQuery query) {
        MessageContext ctx = context.getMessageContext();
        Context context = ReadOnlyContext.getSoapContext(ctx);
        assertInitialized();
        try {
            String[] resultFieldsArray =
                    resultFields.getItem().toArray(EMPTY_STRING_ARRAY);

            org.fcrepo.server.search.FieldSearchResult result =
                    m_access.findObjects(context,
                                         resultFieldsArray,
                                         maxResults.intValue(),
                                         TypeUtility
                                                 .convertGenFieldSearchQueryToFieldSearchQuery(query));
            return TypeUtility
                    .convertFieldSearchResultToGenFieldSearchResult(result);
        } catch (Throwable th) {
            LOG.error("Error finding objects", th);
            throw CXFUtility.getFault(th);
        }
    }
1355313
public SearchResponse searchAllWithTargetCount(String[] indices,
            String[] types, QueryBuilder filterQueryBuilder) {
        return searchAllWithTargetCount(indices, types, filterQueryBuilder,
                null);
    }
1305132
@Override
    public EntityIdentifier[] searchForGroups(
            final String query,
            final SearchMethod method,
            @SuppressWarnings("unchecked") final Class leaftype) {

        // only search for groups
        if (leaftype != IPerson.class) {
            return new EntityIdentifier[] {};
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Searching Grouper for groups matching query: " + query);
        }

        // result groups.
        List<EntityIdentifier> groups = new ArrayList<EntityIdentifier>();

        try {

            // TODO: searches need to be performed against the group display
            // name rather than the group key

            GcFindGroups groupSearch = new GcFindGroups();
            WsQueryFilter filter = new WsQueryFilter();
            // is this an exact search or fuzzy
            if ((method == SearchMethod.DISCRETE_CI) || (method == SearchMethod.DISCRETE)) {
                filter.setQueryFilterType("FIND_BY_GROUP_NAME_EXACT");
            } else {
                filter.setQueryFilterType("FIND_BY_GROUP_NAME_APPROXIMATE");
            }
            filter.setGroupName(query);
            groupSearch.assignQueryFilter(filter);
            WsFindGroupsResults results = groupSearch.execute();

            if (results != null && results.getGroupResults() != null) {
                for (WsGroup g : results.getGroupResults()) {
                    if (validKey(g.getName())) {
                        if (LOGGER.isTraceEnabled()) {
                            LOGGER.trace("Retrieved group: " + g.getName());
                        }
                        groups.add(new EntityIdentifier(g.getName(), IEntityGroup.class));
                    }
                }
            }

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Returning " + groups.size() + " results for query " + query);
            }

            return groups.toArray(new EntityIdentifier[groups.size()]);

        } catch (Exception e) {
            LOGGER.warn(
                    "Exception while attempting to retrieve "
                            + "search results for query "
                            + query
                            + " and entity type "
                            + leaftype.getCanonicalName()
                            + " : "
                            + e.getMessage());
            return new EntityIdentifier[] {};
        }
    }
338247
func NewSearchRequestBuilder(version int, interval tsdb.Interval) *SearchRequestBuilder {
	builder := &SearchRequestBuilder{
		version:     version,
		interval:    interval,
		sort:        make(map[string]interface{}),
		customProps: make(map[string]interface{}),
		aggBuilders: make([]AggBuilder, 0),
	}
	return builder
}
1150431
@Override
    public Collection<IPermissionTarget> searchTargets(String term) {

        // Initialize a new collection of matching targets.  We use a HashSet
        // implementation here to prevent duplicate target entries.
        Collection<IPermissionTarget> matching = new HashSet<IPermissionTarget>();

        /*
         * Attempt to find matching entities for each allowed entity type.
         * Any matching entities will be added to our collection.
         */
        for (TargetType targetType : allowedTargetTypes) {
            Set<JsonEntityBean> entities = groupListHelper.search(targetType.toString(), term);
            for (JsonEntityBean entity : entities) {
                IPermissionTarget target =
                        new PermissionTargetImpl(entity.getId(), entity.getName(), targetType);
                matching.add(target);
            }
        }

        if (IPermission.ALL_CATEGORIES_TARGET.contains(term)) {
            matching.add(ALL_CATEGORIES_TARGET);
        } else if (IPermission.ALL_PORTLETS_TARGET.contains(term)) {
            matching.add(ALL_PORTLETS_TARGET);
        } else if (IPermission.ALL_GROUPS_TARGET.contains(term)) {
            matching.add(ALL_GROUPS_TARGET);
        }

        // return the list of matching targets
        return matching;
    }
840088
public SearchResponse searchAllWithTargetCount(String[] indices,
            String[] types, QueryBuilder filterQueryBuilder,
            AggregationBuilder[] aggregationBuilders) {
        return searchWithTargetCount(
                getSearchRequestBuilderWithMatchAll(false, indices, types,
                        filterQueryBuilder), aggregationBuilders);
    }
177910
public SearchRequestBuilder getSearchRequestBuilder(boolean isSetExplain,
            String[] indices, String[] types) {
        return getSearchRequestBuilder(isSetExplain, indices, types, null);
    }
33530
public <T> StreamSupplier<T> queryRawStream(List<String> dimensions, List<String> storedMeasures, AggregationPredicate where,
			Class<T> resultClass) throws QueryException {
		return queryRawStream(dimensions, storedMeasures, where, resultClass, classLoader);
	}