Package org.dspace.discovery

Examples of org.dspace.discovery.DiscoverQuery


        String uuid = cris.getUuid();

        String query = MessageFormat.format(getRelationConfiguration()
                .getQuery(), authority, uuid);

        DiscoverQuery solrQuery = new DiscoverQuery();
        solrQuery.setFacetMinCount(1);
        try
        {
            solrQuery.addFilterQueries(getTypeFilterQuery());
        }
        catch (InstantiationException e)
        {
            log.error(e.getMessage(), e);
        }
        catch (IllegalAccessException e)
        {
            log.error(e.getMessage(), e);
        }
        solrQuery.setQuery(query);
        solrQuery.addSearchField("search.resourceid");
        solrQuery.addSearchField("search.resourcetype");
        solrQuery.setStart(start);
        solrQuery.setMaxResults(rpp);
        if (orderfield == null)
        {
            orderfield = "score";
        }
        solrQuery.setSortField(orderfield, ascending ? SORT_ORDER.asc
                : SORT_ORDER.desc);

        for (ICrisBeanComponent facetComponent : getTypes().values())
        {
            String format = MessageFormat.format(
                    facetComponent.getFacetQuery(), authority, uuid);
            solrQuery.addFacetQuery(format);
            solrQuery.getNamedFacetQueries().put(format, facetComponent.getComponentIdentifier());
        }

        if(getCommonFilter()!=null) {           
            String format = MessageFormat.format(getCommonFilter(), getRelationConfiguration().getRelationName(),
                    cris.getUuid(), authority);
            solrQuery.addFilterQueries(format);
        }   
       
        return getSearchService().search(context, solrQuery);
    }
View Full Code Here


        String uuid = cris.getUuid();
        String query = MessageFormat.format(getRelationConfiguration()
                .getQuery(), authority, uuid);
        List<String> filters = getFilters(type);

        DiscoverQuery solrQuery = new DiscoverQuery();
        try
        {
            solrQuery.addFilterQueries("NOT(withdrawn:true)",
                    getTypeFilterQuery());
        }
        catch (InstantiationException e)
        {
            log.error(e.getMessage(), e);
        }
        catch (IllegalAccessException e)
        {
            log.error(e.getMessage(), e);
        }
        solrQuery.setQuery(query);
        solrQuery.addSearchField("search.resourceid");
        solrQuery.addSearchField("search.resourcetype");
        solrQuery.setStart(start);
        solrQuery.setMaxResults(rpp);
        if (orderfield == null)
        {
            orderfield = "score";
        }
        solrQuery.setSortField(orderfield, ascending ? SORT_ORDER.asc
                : SORT_ORDER.desc);

        if (filters != null)
        {
            for (String filter : filters)
            {
                solrQuery.addFilterQueries(MessageFormat.format(filter,
                        authority, uuid));
            }
        }

        return getSearchService().search(context, solrQuery);
View Full Code Here

            init();
            if (query != null && query.length() > 2)
            {
                String luceneQuery = ClientUtils.escapeQueryChars(query.toLowerCase()) + "*";
                luceneQuery = luceneQuery.replaceAll("\\\\ "," ");
                DiscoverQuery discoverQuery = new DiscoverQuery();
                discoverQuery.setDSpaceObjectFilter(getCRISTargetTypeID());
                String filter = configurationService.getProperty("cris."
                        + getPluginName() + ((field!=null && !field.isEmpty())?"." + field:"") + ".filter");
                if (filter != null)
                {
                    discoverQuery.addFilterQueries(filter);
                }

                discoverQuery
                        .setQuery("{!lucene q.op=AND df=crisauthoritylookup}("
                                + luceneQuery
                                + ") OR (\""
                                + luceneQuery.substring(0,
                                        luceneQuery.length() - 1) + "\")");
               
                discoverQuery.setMaxResults(50);
                DiscoverResult result = searchService.search(null,
                        discoverQuery, true);

                List<Choice> choiceList = new ArrayList<Choice>();

View Full Code Here

                    luceneQuery += (luceneQuery.length() > 0 ? " " : "")
                            + ClientUtils.escapeQueryChars(tmpPersonName
                                    .getFirstNames().trim()) + "*";
                }
                luceneQuery = luceneQuery.replaceAll("\\\\ ", " ");
                DiscoverQuery discoverQuery = new DiscoverQuery();
                discoverQuery.setDSpaceObjectFilter(CrisConstants.RP_TYPE_ID);
                String filter = configurationService.getProperty("cris."
                        + RP_AUTHORITY_NAME
                        + ((field != null && !field.isEmpty()) ? "." + field
                                : "") + ".filter");
                if (filter != null)
                {
                    discoverQuery.addFilterQueries(filter);
                }

                discoverQuery
                        .setQuery("{!lucene q.op=AND df=crisauthoritylookup}("
                                + luceneQuery
                                + ") OR (\""
                                + luceneQuery.substring(0,
                                        luceneQuery.length() - 1) + "\")");
                discoverQuery.setMaxResults(50);
                DiscoverResult result = searchService.search(null,
                        discoverQuery, true);

                List<Choice> choiceList = new ArrayList<Choice>();

View Full Code Here

            init();
            List<Choice> choiceList = new ArrayList<Choice>();
            int totalResult = 0;
            if (text != null && text.length() > 2)
            {
                DiscoverQuery discoverQuery = new DiscoverQuery();
                discoverQuery.setDSpaceObjectFilter(CrisConstants.RP_TYPE_ID);
                String filter = configurationService.getProperty("cris."
                        + RP_AUTHORITY_NAME + ".filter");
                if (filter != null)
                {
                    discoverQuery.addFilterQueries(filter);
                }

                discoverQuery
                        .setQuery("{!lucene q.op=AND df=crisauthoritylookup}\""
                                + ClientUtils.escapeQueryChars(text.trim())
                                + "\"");
                discoverQuery.setMaxResults(50);
                DiscoverResult result = searchService.search(null,
                        discoverQuery, true);
                totalResult = (int) result.getTotalSearchResults();
                for (DSpaceObject dso : result.getDspaceObjects())
                {
View Full Code Here

        try
        {
            if (resultsDoc == null)
            {
              Context context = ContextUtil.obtainContext(objectModel);
                DiscoverQuery queryArgs = new DiscoverQuery();

              Request request = ObjectModelHelper.getRequest(objectModel);
               
              // Sets the query
                queryArgs.setQuery(query);
                queryArgs.setStart(start);
                queryArgs.setMaxResults(rpp);

                // we want Items only
              queryArgs.setDSpaceObjectFilter(Constants.ITEM);
               
                // sort info
                if(sort != null)
                {
                    String sortField = this.searchService.toSortFieldIndex(sort.getMetadata(), sort.getType());
                    if(SortOption.ASCENDING.equals( sortOrder ))
                        queryArgs.setSortField(sortField, DiscoverQuery.SORT_ORDER.asc);
                    else
                        queryArgs.setSortField(sortField, DiscoverQuery.SORT_ORDER.desc);
                }

                DiscoverResult queryResults = null;
                if(scope == null)
                    queryResults = SearchUtils.getSearchService().search(context, queryArgs);
View Full Code Here

  }

  private void process(Context context, HttpServletRequest request,
            HttpServletResponse response, DSpaceObject scope)
    {
        DiscoverQuery queryArgs = DiscoverUtility.getTagCloudDiscoverQuery(context,
                request, scope, true);
        queryArgs.setMaxResults(0);
        DiscoverResult qResults;
        try
        {
            qResults = SearchUtils.getSearchService().search(context, scope,
                    queryArgs);
View Full Code Here

     * @throws SearchServiceException
     */
    public static DiscoverQuery getDiscoverQuery(Context context,
            HttpServletRequest request, DSpaceObject scope, boolean enableFacet)
    {
        DiscoverQuery queryArgs = new DiscoverQuery();
        DiscoveryConfiguration discoveryConfiguration = SearchUtils
                .getDiscoveryConfiguration(scope);

        List<String> userFilters = setupBasicQuery(context,
                discoveryConfiguration, request, queryArgs);
View Full Code Here

     * @throws SearchServiceException
     */
    public static DiscoverQuery getTagCloudDiscoverQuery(Context context,
            HttpServletRequest request, DSpaceObject scope, boolean enableFacet)
    {
        DiscoverQuery queryArgs = new DiscoverQuery();
        DiscoveryConfiguration discoveryConfiguration = SearchUtils
                .getDiscoveryConfiguration(scope);

        List<String> userFilters = setupBasicQuery(context,
                discoveryConfiguration, request, queryArgs);
View Full Code Here

     * @return the query.
     */
    public static DiscoverQuery getDiscoverAutocomplete(Context context,
            HttpServletRequest request, DSpaceObject scope)
    {
        DiscoverQuery queryArgs = new DiscoverQuery();
        DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration();
       
        setupBasicQuery(context, discoveryConfiguration, request, queryArgs);
        String autoIndex = request.getParameter("auto_idx");
        String autoQuery = request.getParameter("auto_query");
        String sort = request.getParameter("auto_sort");
        String autoType = request.getParameter("auto_type");
        if ("contains".equals(autoType) || "notcontains".equals(autoType))
        {
            autoType = DiscoveryConfigurationParameters.TYPE_STANDARD;
        }
        else if ("authority".equals(autoType) || "notauthority".equals(autoType))
        {
            autoType = DiscoveryConfigurationParameters.TYPE_AUTHORITY;
        }
        else
        {
            autoType = DiscoveryConfigurationParameters.TYPE_AC;
        }
        DiscoveryConfigurationParameters.SORT sortBy = DiscoveryConfigurationParameters.SORT.VALUE;
        if (StringUtils.isNotBlank(sort))
        {
            if ("count".equalsIgnoreCase(sort))
            {
                sortBy = DiscoveryConfigurationParameters.SORT.COUNT;
            }
            else
            {
                sortBy = DiscoveryConfigurationParameters.SORT.VALUE;
            }
        }
        // no user choices... default for autocomplete should be alphabetic
        // sorting in all cases except empty query where count is preferable
        else if ("".equals(autoQuery))
        {
           sortBy = DiscoveryConfigurationParameters.SORT.COUNT;
        }
        if (autoIndex == null)
        {
            autoIndex = "all";
        }
        if (autoQuery == null)
        {
            autoQuery = "";
        }
       
        int limit = UIUtil.getIntParameter(request, "autocomplete.limit");
        if (limit == -1)
        {
            limit = 10;
        }
        DiscoverFacetField autocompleteField = new DiscoverFacetField(autoIndex,
                autoType,
                limit, sortBy, autoQuery.toLowerCase());
        queryArgs.addFacetField(autocompleteField);
        queryArgs.setMaxResults(0);
        queryArgs.setFacetMinCount(1);
        return queryArgs;
    }
View Full Code Here

TOP

Related Classes of org.dspace.discovery.DiscoverQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.