本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.addFacetQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.addFacetQuery方法的具體用法?Java SolrQuery.addFacetQuery怎麽用?Java SolrQuery.addFacetQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.addFacetQuery方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: attachFacets
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Notifies solr about which facets you want it to determine results and counts for
*
* @param query
* @param namedFacetMap
*/
protected void attachFacets(SolrQuery query, Map<String, SearchFacetDTO> namedFacetMap) {
query.setFacet(true);
for (Entry<String, SearchFacetDTO> entry : namedFacetMap.entrySet()) {
SearchFacetDTO dto = entry.getValue();
String facetTagField = entry.getValue().isActive() ? shs.getGlobalFacetTagField() : entry.getKey();
// Clone the list - we don't want to remove these facets from the DB
List<SearchFacetRange> facetRanges = new ArrayList<SearchFacetRange>(dto.getFacet().getSearchFacetRanges());
if (extensionManager != null) {
extensionManager.getProxy().filterSearchFacetRanges(dto, facetRanges);
}
if (facetRanges != null && facetRanges.size() > 0) {
for (SearchFacetRange range : facetRanges) {
query.addFacetQuery(getSolrTaggedFieldString(entry.getKey(), facetTagField, "ex", range));
}
} else {
query.addFacetField(getSolrTaggedFieldString(entry.getKey(), facetTagField, "ex", null));
}
}
}
示例2: attachFacets
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public void attachFacets(SolrQuery query, Map<String, SearchFacetDTO> namedFacetMap) {
query.setFacet(true);
for (Entry<String, SearchFacetDTO> entry : namedFacetMap.entrySet()) {
SearchFacetDTO dto = entry.getValue();
// Clone the list - we don't want to remove these facets from the DB
List<SearchFacetRange> facetRanges = new ArrayList<SearchFacetRange>(dto.getFacet().getSearchFacetRanges());
if (extensionManager != null) {
extensionManager.getProxy().filterSearchFacetRanges(dto, facetRanges);
}
if (facetRanges != null && facetRanges.size() > 0) {
for (SearchFacetRange range : facetRanges) {
query.addFacetQuery(getSolrTaggedFieldString(entry.getKey(), "key", range));
}
} else {
query.addFacetField(getSolrTaggedFieldString(entry.getKey(), "key", null));
}
}
}
示例3: createQueryException
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private QueryException createQueryException() {
QueryException queryException = new QueryException();
SolrQuery query = new SolrQuery();
query.setQuery("test");
query.setFilterQueries("field=value");
query.addFacetQuery("filterQuery=value");
queryException.setQuery(query);
return queryException;
}
示例4: appendFacetingQueries
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void appendFacetingQueries(SolrQuery solrQuery, FacetQuery query) {
FacetOptions facetOptions = query.getFacetOptions();
for (SolrDataQuery fq : facetOptions.getFacetQueries()) {
String facetQueryString = getQueryString(fq);
if (StringUtils.isNotBlank(facetQueryString)) {
solrQuery.addFacetQuery(facetQueryString);
}
}
}
示例5: initQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public SolrQuery initQuery() {
// create default SOLR query
SolrQuery query = new SolrQuery(ClientUtils.escapeQueryChars(getQueryStr()));
query.addFilterQuery("pid:" + pid); // specific to the current patient
query.setParam("q.op", "AND");
query.setRows(101); // limit to 100 rows
// default fields to fetch
query.setFields(UID, DATETIME, SUMMARY, URL_FIELD, DOMAIN, KIND, FACILITY);
// apply range filter (if specified)
if (hasFilter("range")) {
String range = getFilter("range");
query.addFilterQuery("{!tag=dt}datetime:[" + new PointInTime(range) + " TO *]");
}
// apply kind(s) filter (if specified)
if (hasFilter("kinds")) {
Set<String> kinds = StringUtils.commaDelimitedListToSet(getFilter("kinds"));
String kindFilter = StringUtils.collectionToDelimitedString(kinds, " OR ", "\"", "\"");
query.addFilterQuery("kind:(" + kindFilter + ")");
}
// apply types filter (if specified)
if (hasFilter("types")) {
Set<String> types = StringUtils.commaDelimitedListToSet(getFilter("types"));
String typeFilter = StringUtils.collectionToDelimitedString(types, " OR ", "\"", "\"");
query.addFilterQuery("{!tag=domain}domain:(" + typeFilter + ")");
}
// add date range facets
for (String s : facetsNames.keySet()) {
query.addFacetQuery(s);
}
query.addFacetField("{!ex=domain}domain");
query.setFacetMinCount(1);
// extra debug stuff
if (isDebugEnabled()) {
query.set("debug", "true");
}
// System.out.println(URLDecoder.decode(query.toString()));
return query;
}