Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrQuery


        {

            // HttpSolrServer solrServer = new HttpSolrServer(
            // solrConfig.getUrl()+solrCore);
            solrServer.setMaxRetries(0);
            SolrQuery solrQuery = new SolrQuery();
            // http://localhost:8983/solr/statistics/select/?q=type%3A2&rows=20&facet=true&facet.date=time&facet.date.start=2008-07-00T00:00:00.000Z&facet.date.end=2009-06-31T00:00:00.000Z&facet.date.gap=%2B1MONTHS&facet.field=id
            _prepareBasicQuery(solrQuery, StatComponentsService.getYearsQuery());
            // _prepareTopQuery(type, id, fieldName, solrQuery);

            if(StatComponentsService.isExcludeBot()) {
                solrQuery.addFilterQuery("-isBot:true");   
            }

            Integer relationType = getRelationObjectType();
            if(relationType==null) {
                relationType = CrisConstants.getEntityType(getRelationObjectClass().newInstance());
            }
            solrQuery.addFilterQuery("type:"+ relationType);     
            for(String filter : getBean().getFilters()) {
                solrQuery.addFilterQuery(filter);
            }           
            String query = MessageFormat.format(QUERY_COMMON, getFromField(), getBean().getQuery());
            String sID = getObjectId(id);
            query = MessageFormat.format(query, sID);
            solrQuery.setQuery(query);
            if (getBean() instanceof BeanFacetComponent)
            {
                BeanFacetComponent beanFacet = (BeanFacetComponent) getBean();
                solrQuery.setFacet(true);
                solrQuery.addFacetQuery(beanFacet.getFacetQuery());
                solrQuery.addFacetField(beanFacet.getFacetField());
            }
            solrResponse = solrServer.query(solrQuery);           
            if(!getBean().getSubQueries().isEmpty()) {               
                statisticDatasBeans.addValue(TOP, CrisConstants.getEntityTypeText(relationType), CATEGORY,
                    generateCategoryView(solrServer, TOP, relationType.toString(), CATEGORY, StatComponentsService.getTopCityLength(), query, getBean().getSubQueries(), sID));
View Full Code Here


                .getRelationConfiguration().getQuery(), cris.getCrisID(), cris
                .getUuid());

        boolean sysAdmin = AuthorizeManager.isAdmin(context);

        SolrQuery solrQuery = new SolrQuery();
        if (StringUtils.isNotEmpty(userQuery))
        {
            solrQuery.addFilterQuery("{!tag=user}"
                    + ClientUtils.escapeQueryChars(userQuery) + "*");
            solrQuery.addFacetQuery("{!ex=user}*:*");
        }

        if (!configuration.isActionEnabled(RelationPreference.HIDED, sysAdmin))
        {
            solrQuery.addFilterQuery(getHiddenFilter(cris, configurationName));
        }
        if (!configuration.isActionEnabled(RelationPreference.SELECTED,
                sysAdmin))
        {
            solrQuery
                    .addFilterQuery(getSelectedFilter(cris, configurationName));
        }
        if (configuration
                .isActionEnabled(RelationPreference.UNLINKED, sysAdmin))
        {
            query = getUnlinkedFilter(cris, configurationName, query);
        }

        solrQuery.setQuery(query);

        if (StringUtils.isNotEmpty(status))
        {

            solrQuery
                    .addFilterQuery(RelationPreference.PREFIX_RELATIONPREFERENCES
                            + configurationName
                            + "."
                            + status.toLowerCase()
                            + ":\"" + cris.getUuid() + "\"");

        }

        if (sorts != null)
        {
            for (Sort s : sorts)
            {
                if (s.col < 0)
                {
                    solrQuery.addSortField("cris-uuid", s.asc ? ORDER.asc
                            : ORDER.desc);
                    solrQuery.addSortField("search.resourceid",
                            s.asc ? ORDER.asc : ORDER.desc);
                }
                else
                {
                    solrQuery.addSortField(columns.get(s.col).getSortField(),
                            s.asc ? ORDER.asc : ORDER.desc);
                }
            }
        }

        solrQuery.setRows(rpp);
        solrQuery.setStart(offset);
        solrQuery
                .setFields("search.resourceid", "cris-uuid",
                        RelationPreference.PREFIX_RELATIONPREFERENCES
                                + configurationName + "."
                                + RelationPreference.UNLINKED,
                        RelationPreference.PREFIX_RELATIONPREFERENCES
View Full Code Here

    }

    private QueryResponse shootQuery(String query, boolean facet,
            String facetField) throws SearchServiceException
    {
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);
        solrQuery.setStart(0);
        solrQuery.setRows(0);

        if (facet)
        {
            solrQuery.setFacet(true);
            solrQuery.setFacetMinCount(1);
            solrQuery.addFacetField(facetField);
        }
        QueryResponse rsp = service.search(solrQuery);       
        return rsp;
    }
View Full Code Here

            {
                String q = "";
                try
                {
                    String name = key;
                    SolrQuery solrQuery = new SolrQuery();
                    q = query + " AND ("
                            + MessageFormat.format(subQueries.get(key), null,
                                    id) + ")";
                    solrQuery.setQuery(q);
                    if (StringUtils.isEmpty(name))
                        name = "Unknown";

                    int count = new Long(server.query(solrQuery).getResults().getNumFound()).intValue();
                    limitedData.add(new StatisticDatasBeanRow(name, count));
View Full Code Here

    public MultiValueMap getRelationsInformation(String type,
            String from, String to) throws SearchServiceException
    {
        MultiValueMap result = new MultiValueMap();
        SolrQuery solrQuery = new SolrQuery();

        Matcher matcher = patternRP.matcher(from);
        String field1 = "";
        String field2 = "";

        if (matcher.find())
        {
            field1 = "focus_auth";
        }
        else
        {
            field1 = "focus_val";
        }

        matcher = patternRP.matcher(to);

        if (matcher.find())
        {
            field2 = "focus_auth";
        }
        else
        {
            field2 = "focus_val";
        }

        solrQuery.setQuery(field1 + ":\"" + from
                + "\" AND " + field2 + ":\"" + to + "\"");

        solrQuery.addFilterQuery("type:" + type);       
        solrQuery.setRows(Integer.MAX_VALUE);
        QueryResponse rsp = service.search(solrQuery);

        for (SolrDocument doc : rsp.getResults())
        {
            String resultField = "";
View Full Code Here

        {
            found = true;
        }

        // load all publications
        SolrQuery solrQuery = new SolrQuery();

        List<DTOMetric> results = new ArrayList<DTOMetric>();

        String connection = ConfigurationManager
                .getProperty(NetworkPlugin.CFG_MODULE, "network.connection");

        String[] connections = connection.split(",");
        List<String> fieldsToRetrieve = new ArrayList<String>();
        fieldsToRetrieve.add("search.resourceid");
        fieldsToRetrieve.add("rp_fullname");
        for (String conn : connections)
        {
            fieldsToRetrieve
                    .add(ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_1_RETRIEVE
                            + conn);
            fieldsToRetrieve
                    .add(ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_2_RETRIEVE
                            + conn);
            fieldsToRetrieve
                    .add(ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_3_RETRIEVE
                            + conn);
            fieldsToRetrieve
                    .add(ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_4_RETRIEVE
                            + conn);
        }
        String[] fields = fieldsToRetrieve.toArray(new String[] {});
        QueryResponse rsp;
        try
        {
            solrQuery = new SolrQuery();
            solrQuery.setQuery("search.resourcetype:"
                    + CrisConstants.RP_TYPE_ID + " AND rp_dept:\"" + dept
                    + "\"");
            solrQuery.setFields(fields);
            solrQuery.setRows(Integer.MAX_VALUE);
            rsp = getService().getSearcher().search(solrQuery);

            SolrDocumentList rows = rsp.getResults();

            external: for (String conn : connections)
View Full Code Here

                              // (now search for
                              // RP
                              // is public)
    }

    SolrQuery query = new SolrQuery();
    query.setQuery("disabled:false");

    query.setFacet(true);
    query.setFacetLimit(-1);
    query.setFacetMinCount(1);
    query.setFacetMissing(true);
    query.setFacetSort(FacetParams.FACET_SORT_INDEX);
    // check table name
    query.addFacetField("faculty_filter");
    query.setRows(0);

    QueryResponse qResponse = ((CrisSearchService) searchService)
        .search(query);
   
    FacetField facetField = qResponse.getFacetField("faculty_filter");
View Full Code Here

  }
 
 
  public Map<String,Integer> getRelations(String from, String to) throws SearchServiceException {
    Map<String,Integer> result = new HashMap<String, Integer>();
    SolrQuery solrQuery = new SolrQuery();
   
   
        Matcher matcher = patternRP.matcher(from);
        String field1 = "";
        String field2 = "";
       
        if (matcher.find())
        {                           
          field1 = "focus_auth";
        }
        else
        {
          field1 = "focus_val";
        }
       
        matcher = patternRP.matcher(to);
       

        if (matcher.find())
        {                           
          field2 = "focus_auth";
        }
        else
        {
          field2 = "focus_val";
        }
       
       
    solrQuery.setQuery(
       
        field1 + ":\"" + from + "\" AND "+ field2 + ":\""+ to +"\""       
               
    );
   
    solrQuery.setFacet(true);
    solrQuery.addFacetField("type");
    solrQuery.setFacetLimit(Integer.MAX_VALUE);
    solrQuery.setFacetMinCount(1);
    solrQuery.setRows(0);

    QueryResponse rsp = service.search(solrQuery);

    FacetField facets = rsp.getFacetField("type");
    for(Count facet : facets.getValues()) {
View Full Code Here

    {

        String query = "type:" + connection + " AND focus_auth:" + authority
                + " AND entity:" + ConstantNetwork.ENTITY_RP;

        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);
        solrQuery.setStart(0);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().search(solrQuery);
        SolrDocumentList docs = rsp.getResults();
        if (docs != null)
        {
            if (docs.getNumFound() > 0)
View Full Code Here

  public Element marshall(String query, String paginationStart,
      String paginationLimit, String[] splitProjection, String type,
      Element root, User userWS, String nameRoot)
      throws SearchServiceException, IOException {

    SolrQuery solrQuery = buildQuery(query,
        paginationStart.trim(), paginationLimit.trim(),
        userWS, type, splitProjection);
    QueryResponse response = searchServices.search(solrQuery);
    List<T> results = getWSObject(response);
      root = getMarshaller()
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.SolrQuery

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.