当前位置: 首页>>代码示例>>Java>>正文


Java ORDER类代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.SolrQuery.ORDER的典型用法代码示例。如果您正苦于以下问题:Java ORDER类的具体用法?Java ORDER怎么用?Java ORDER使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ORDER类属于org.apache.solr.client.solrj.SolrQuery包,在下文中一共展示了ORDER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
public static void main(String[] args) throws MalformedURLException, SolrServerException {
		String zkHost = "localhost:2181";
		String defaultCollection = "collection1";
		CloudSolrServer solr = new CloudSolrServer(zkHost);
		solr.setDefaultCollection(defaultCollection);
        
/*		ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("q", "cat:electronics");
    	params.set("defType", "edismax");
    	params.set("start", "0");*/
		
		SolrQuery params = new SolrQuery();
		params.setQuery("*:*");
		params.setSort("score ",ORDER.desc);
		params.setStart(Integer.getInteger("0"));
		params.setRows(Integer.getInteger("100"));
		
    

		QueryResponse response = solr.query(params);
		SolrDocumentList results = response.getResults();
		for (int i = 0; i < results.size(); ++i) {
			System.out.println(results.get(i));
		}
	}
 
开发者ID:dimensoft,项目名称:improved-journey,代码行数:26,代码来源:SolrCloudSolrJSearcher.java

示例2: main

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
public static void main(String[] args) throws MalformedURLException, SolrServerException {
		HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");
//		  ModifiableSolrParams params = new ModifiableSolrParams(); 
//        params.setQuery("name:Samsung ");
//        params.setStart(0);
//        params.setRows(100);
		SolrQuery params = new SolrQuery();
		params.setQuery("*:*");
		params.setSort("score ",ORDER.desc);
		params.setStart(Integer.getInteger("0"));
		params.setRows(Integer.getInteger("100"));

		QueryResponse response = solr.query(params);
		SolrDocumentList results = response.getResults();
		for (int i = 0; i < results.size(); ++i) {
			System.out.println(results.get(i));
		}
	}
 
开发者ID:dimensoft,项目名称:improved-journey,代码行数:19,代码来源:SolrJSearcher.java

示例3: search

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
/**
 * searches and returns a list of {@link SolrDocument}
 * 
 * @param from startdate
 * @param until enddate
 * @param set which collection
 * @param metadataPrefix
 * @param firstRow
 * @param numRows
 * @param urnOnly
 * @param querySuffix
 * @return list of hits as {@link SolrDocument}
 * @throws IOException
 * @throws SolrServerException
 */
public SolrDocumentList search(String from, String until, String set, String metadataPrefix, int firstRow, int numRows, boolean urnOnly,
        String querySuffix) throws IOException, SolrServerException {
    StringBuilder sbQuery = new StringBuilder(buildQueryString(from, until, set, metadataPrefix, urnOnly, querySuffix));
    if (urnOnly) {
        sbQuery.append(" AND (").append(SolrConstants.URN).append(":* OR ").append(SolrConstants.IMAGEURN_OAI).append(":*)");
    }
    sbQuery.append(getAllSuffixes());
    logger.debug("OAI query: {}", sbQuery.toString());
    SolrQuery solrQuery = new SolrQuery(sbQuery.toString());
    solrQuery.setStart(firstRow);
    solrQuery.setRows(numRows);
    solrQuery.addSort(SolrConstants.DATECREATED, ORDER.asc);
    QueryResponse resp = server.query(solrQuery);
    logger.debug("Total hits: {}, fetched records {} - {}", resp.getResults().getNumFound(), firstRow, firstRow + resp.getResults().size() - 1);

    return resp.getResults();
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:33,代码来源:SolrSearchIndex.java

示例4: getTotalHitNumber

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
/**
 * 
 * @param params
 * @param urnOnly
 * @param querySuffix
 * @return size of search
 * @throws IOException
 * @throws SolrServerException
 */
public long getTotalHitNumber(Map<String, String> params, boolean urnOnly, String querySuffix) throws IOException, SolrServerException {
    StringBuilder sbQuery = new StringBuilder(buildQueryString(params.get("from"), params.get("until"), params.get("set"), params.get(
            "metadataPrefix"), urnOnly, querySuffix));
    if (urnOnly) {
        sbQuery.append(" AND (").append(SolrConstants.URN).append(":* OR ").append(SolrConstants.IMAGEURN_OAI).append(":*)");
    }
    sbQuery.append(getAllSuffixes());
    logger.debug("OAI query: {}", sbQuery.toString());
    SolrQuery solrQuery = new SolrQuery(sbQuery.toString());
    solrQuery.setStart(0);
    solrQuery.setRows(0);
    solrQuery.addSort(SolrConstants.DATECREATED, ORDER.asc);
    QueryResponse resp = server.query(solrQuery);

    long num = resp.getResults().getNumFound();
    logger.debug("Total hits: {}", num);
    return num;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:28,代码来源:SolrSearchIndex.java

示例5: attachSortClause

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
/**
 * Sets up the sorting criteria. This will support sorting by multiple fields at a time
 * 
 * @param query
 * @param searchCriteria
 */
protected void attachSortClause(SolrQuery query, ProductSearchCriteria searchCriteria, String defaultSort) {
    Map<String, String> solrFieldKeyMap = getSolrFieldKeyMap(searchCriteria);

    String sortQuery = searchCriteria.getSortQuery();
    if (StringUtils.isBlank(sortQuery)) {
        sortQuery = defaultSort;
    }

    if (StringUtils.isNotBlank(sortQuery)) {
        String[] sortFields = sortQuery.split(",");
        for (String sortField : sortFields) {
            String field = sortField.split(" ")[0];
            if (solrFieldKeyMap.containsKey(field)) {
                field = solrFieldKeyMap.get(field);
            }
            ORDER order = "desc".equals(sortField.split(" ")[1]) ? ORDER.desc : ORDER.asc;

            if (field != null) {
                query.addSortField(field, order);
            }
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:30,代码来源:SolrSearchServiceImpl.java

示例6: addQueryOption

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
@Override
public void addQueryOption(String key, String value, SolrQuery query) {
	switch(value){
	case "name_asc":
		query.setSort("taxon.rank_s_lower", ORDER.asc);
		query.addSort("sortable", ORDER.asc);
		break;
	case "name_desc":
		query.setSort("taxon.rank_s_lower", ORDER.asc);
		query.addSort("sortable", ORDER.desc);
		break;
	case "relevance":
		query.setSort("score", ORDER.desc);
		query.addSort("taxon.rank_s_lower", ORDER.asc);
		query.addSort("sortable", ORDER.asc);
		break;
	}
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:19,代码来源:SortQuery.java

示例7: attachSortClause

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
@Override
public void attachSortClause(SolrQuery query, SearchCriteria searchCriteria, String defaultSort, List<Field> fields) {
    Map<String, String> solrFieldKeyMap = getSolrFieldKeyMap(searchCriteria, fields);

    String sortQuery = searchCriteria.getSortQuery();
    if (StringUtils.isBlank(sortQuery)) {
        sortQuery = defaultSort;
    }

    if (StringUtils.isNotBlank(sortQuery)) {
        String[] sortFields = sortQuery.split(",");
        for (String sortField : sortFields) {
            String field = sortField.split(" ")[0];
            if (solrFieldKeyMap.containsKey(field)) {
                field = solrFieldKeyMap.get(field);
            }
            ORDER order = "desc".equals(sortField.split(" ")[1]) ? ORDER.desc : ORDER.asc;

            if (field != null) {
                query.addSort(new SortClause(field, order));
            }
        }
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:25,代码来源:SolrHelperServiceImpl.java

示例8: list

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
@Override
protected void list(final PatientSearch search, FrameTask task) throws FrameException {
	if (!search.searchType("task")) return;
	SolrQuery query = search.initQuery();
	query.setQuery("domain:\"" + search.getQueryStr() + "\"");
    query.addFilterQuery("domain:task");
	query.addSort(SearchService.DATETIME, ORDER.desc);
	QueryResponse results = execSolrQuery(query, task);
	task.addAction(new SolrSearchAction(query, results) {
		@Override
		public List<SummaryItem> createSummaryItems(QueryResponse response) {
			if (!search.searchType("task")) return null; // don't create results if we documents are filtered out 
			return super.createSummaryItems(response);
		}
	});
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:17,代码来源:GoldSearchFrame.java

示例9: configureQueryForDocuments

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
private void configureQueryForDocuments(SolrQuery query) {
    query.addFilterQuery("domain:document");
    query.addSort("reference_date_time", ORDER.desc);

    query.addField(Document.SOLR_LOCAL_TITLE_FIELD);
    query.addField(Document.SOLR_DOC_DEF_UID_FIELD);
    query.addField(Document.SOLR_DOCUMENT_STATUS_FIELD);
    query.addField(Document.SOLR_AUTHOR_UID_FIELD);
    query.addField(Document.SOLR_SIGNER_UID_FIELD);
    query.addField(Document.SOLR_COSIGNER_UID_FIELD);
    query.addField((Document.SOLR_ATTENDING_UID_FIELD));
    query.addField(Document.SOLR_IS_INTERDISCIPLINARY_FIELD);
    query.addField(Document.SOLR_INTERDISCIPLINARY_TYPE_FIELD);

    query.addField(SearchService.PHRASE);

    query.set(GroupParams.GROUP, true);
    query.set(GroupParams.GROUP_FIELD, Document.SOLR_LOCAL_TITLE_FIELD);
    query.setHighlight(true);
    query.addHighlightField("body").addHighlightField("subject");
    query.setHighlightFragsize(45);
    query.setHighlightSnippets(5);
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:24,代码来源:GoldSearchFrame.java

示例10: exec

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
@Override
public void exec(PatientSearch search, FrameTask task) throws FrameException {
	// create + exec SOLR query
	SolrQuery query = search.initQuery();
	query.setParam("q.op", "OR");

	query.setQuery("+all:\"" + ClientUtils.escapeQueryChars(search.getQueryStr()) + '"');
	
	// search for the specific domains we don't have frames for
	String domains = "obs procedure "; // encounter stuff
	domains += "mh "; // other patient stuff
	domains += "roadtrip auxiliary "; // CPE specific stuff
	domains += "pov skin diagnosis ptf exam treatment"; // encounter flags
	query.addFilterQuery("+domain: (" + domains + ")");
	query.addFilterQuery("-removed:true"); 
	
	query.addSort(SearchService.DATETIME, ORDER.desc);
	query.setFields(SearchService.UID, SearchService.DATETIME,
			SearchService.SUMMARY, SearchService.URL_FIELD,
			SearchService.DOMAIN, SearchService.KIND,
			SearchService.FACILITY);
	task.addAction(new SolrSearchAction(query, execSolrQuery(query, task)));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:24,代码来源:GoldSearchFrame.java

示例11: prepareQuery

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
private SolrQuery prepareQuery(PatientSearch search, boolean highlight) {
	SolrQuery query = search.initQuery();
	query.addFilterQuery("domain:med");
	query.addSort("overall_stop", ORDER.desc);
	query.addField("qualified_name");
	query.addField("va_type");
	query.addField("last_filled");
	query.addField("last_give");
	query.addField(CLASS_FIELD);
	query.set(GroupParams.GROUP, true);
	query.set(GroupParams.GROUP_FIELD, "kind");
	query.add(GroupParams.GROUP_FIELD, "qualified_name");
	
	if (highlight) {
		query.setHighlight(true);
	    query.addHighlightField("administration_comment");
	    query.addHighlightField("prn_reason");
	    query.setHighlightFragsize(72);
	    query.setHighlightSnippets(5);
	}
	
	return query;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:24,代码来源:MedsSearchFrame.java

示例12: testSimpleAgent

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
@Test
public void testSimpleAgent() {
    assertEquals(0, this.commitAndGetSolrDocumentCount("*:*"));

    HqAgentController.install("1", HQ_URL, QUEUE_DIRECTORY, SPACE_TOKEN, MARKER);
    TestAgent testAgent = new TestAgent();
    this.waitFor(5, SECONDS);
    AgentControllerProvider.shutdown();

    assertTrue(testAgent.getEventCount() > 0);
    assertEquals(testAgent.getEventCount(), this.commitAndGetSolrDocumentCount("*:*"));

    SolrQuery solrQuery = new SolrQuery("*:*");
    solrQuery.addSort("global_id", ORDER.asc);

    QueryResponse queryResponse = this.querySolr(solrQuery);

    int documentCount = 0;
    for (SolrDocument eachDocument : queryResponse.getResults()) {
        assertEquals(String.valueOf(++documentCount), eachDocument.getFirstValue("global_id"));
        assertEquals(MARKER, eachDocument.getFirstValue("marker"));
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:24,代码来源:SimpleIntegrationTest.java

示例13: setSort

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
/**
 * Sets the sort criteria for the query.
 * @return query the SolrQuery
 */
private SolrQuery setSort(SolrQuery query, ElaborateSearchParameters sp) {
	LinkedHashSet<SortParameter> sortParameters = sp.getSortParameters();
	for (SortParameter sortParameter : sortParameters) {
		if (StringUtils.isNotBlank(sortParameter.getFieldname())) {
			String facetName = SolrUtils.facetName(sortParameter.getFieldname());
			ORDER solrOrder = solrOrder(sortParameter.getDirection());
			query.addSort(facetName, solrOrder);
		}
	}

	LinkedHashSet<String> levelFields = Sets.newLinkedHashSet(ImmutableList.of(sp.getLevel1Field(), sp.getLevel2Field(), sp.getLevel3Field(), SolrFields.NAME));
	for (String sortField : levelFields) {
		query.addSort(sortField, SolrQuery.ORDER.asc);
	}
	return query;
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:21,代码来源:AbstractSolrServer.java

示例14: appendSort

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
/**
 * Append sorting parameters to {@link SolrQuery}
 * 
 * @param solrQuery
 * @param sort
 */
@SuppressWarnings("deprecation")
protected void appendSort(SolrQuery solrQuery, Sort sort) {
	if (sort == null) {
		return;
	}

	for (Order order : sort) {
		// addSort which is to be used instead of addSortField is not available in versions below 4.2.0
		if (VersionUtil.isSolr420Available()) {
			solrQuery.addSort(order.getProperty(), order.isAscending() ? ORDER.asc : ORDER.desc);
		} else {
			solrQuery.addSortField(order.getProperty(), order.isAscending() ? ORDER.asc : ORDER.desc);
		}
	}
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:22,代码来源:DefaultQueryParser.java

示例15: searchUsers

import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入依赖的package包/类
public SolrDocumentList searchUsers (String searchTerms, int limit, int offset) 
		throws SolrServerException, IOException {
	client.setBaseURL(solrUrl+ "/" + coreName);

	SolrQuery solrQuery = new SolrQuery();	
		
	solrQuery.setQuery(searchTerms).setFields(UUID);
	if ( searchTerms.equalsIgnoreCase("*:*"))
		solrQuery.setSort(UUID, ORDER.desc);
	if ( offset >=0)
	  solrQuery.setStart(offset);
	if ( limit >0 )
		solrQuery.setRows(limit);
	
//	solrQuery.setFilterQueries(resultFilter) ;
	
	QueryResponse rsp = client.query(solrQuery);		
		
	SolrDocumentList  dds = rsp.getResults();
	
	return dds;	
	
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:24,代码来源:UserIndexManager.java


注:本文中的org.apache.solr.client.solrj.SolrQuery.ORDER类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。