本文整理汇总了Java中org.apache.lucene.search.grouping.SearchGroup类的典型用法代码示例。如果您正苦于以下问题:Java SearchGroup类的具体用法?Java SearchGroup怎么用?Java SearchGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchGroup类属于org.apache.lucene.search.grouping包,在下文中一共展示了SearchGroup类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transform
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public NamedList transform(List<Command> data) throws IOException {
NamedList<NamedList> result = new NamedList<>();
for (Command command : data) {
final NamedList<Object> commandResult = new NamedList<>();
if (SearchGroupsFieldCommand.class.isInstance(command)) {
SearchGroupsFieldCommand fieldCommand = (SearchGroupsFieldCommand) command;
Pair<Integer, Collection<SearchGroup<BytesRef>>> pair = fieldCommand.result();
Integer groupedCount = pair.getA();
Collection<SearchGroup<BytesRef>> searchGroups = pair.getB();
if (searchGroups != null) {
commandResult.add("topGroups", serializeSearchGroup(searchGroups, fieldCommand.getGroupSort()));
}
if (groupedCount != null) {
commandResult.add("groupCount", groupedCount);
}
} else {
continue;
}
result.add(command.getKey(), commandResult);
}
return result;
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:SearchGroupsResultTransformer.java
示例2: serializeSearchGroup
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data, Sort groupSort) {
NamedList<Object[]> result = new NamedList<>();
for (SearchGroup<BytesRef> searchGroup : data) {
Object[] convertedSortValues = new Object[searchGroup.sortValues.length];
for (int i = 0; i < searchGroup.sortValues.length; i++) {
Object sortValue = searchGroup.sortValues[i];
SchemaField field = groupSort.getSort()[i].getField() != null ? searcher.getSchema().getFieldOrNull(groupSort.getSort()[i].getField()) : null;
if (field != null) {
FieldType fieldType = field.getType();
if (sortValue != null) {
sortValue = fieldType.marshalSortValue(sortValue);
}
}
convertedSortValues[i] = sortValue;
}
String groupValue = searchGroup.groupValue != null ? searchGroup.groupValue.utf8ToString() : null;
result.add(groupValue, convertedSortValues);
}
return result;
}
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:SearchGroupsResultTransformer.java
示例3: result
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
@Override
public Pair<Integer, Collection<SearchGroup<BytesRef>>> result() {
final Collection<SearchGroup<BytesRef>> topGroups;
if (topNGroups > 0) {
topGroups = firstPassGroupingCollector.getTopGroups(0, true);
} else {
topGroups = Collections.emptyList();
}
final Integer groupCount;
if (includeGroupCount) {
groupCount = allGroupsCollector.getGroupCount();
} else {
groupCount = null;
}
return new Pair<>(groupCount, topGroups);
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SearchGroupsFieldCommand.java
示例4: transform
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public NamedList transform(List<Command> data) throws IOException {
NamedList<NamedList> result = new NamedList<NamedList>();
for (Command command : data) {
final NamedList<Object> commandResult = new NamedList<Object>();
if (SearchGroupsFieldCommand.class.isInstance(command)) {
SearchGroupsFieldCommand fieldCommand = (SearchGroupsFieldCommand) command;
Pair<Integer, Collection<SearchGroup<BytesRef>>> pair = fieldCommand.result();
Integer groupedCount = pair.getA();
Collection<SearchGroup<BytesRef>> searchGroups = pair.getB();
if (searchGroups != null) {
commandResult.add("topGroups", serializeSearchGroup(searchGroups, fieldCommand.getGroupSort()));
}
if (groupedCount != null) {
commandResult.add("groupCount", groupedCount);
}
} else {
continue;
}
result.add(command.getKey(), commandResult);
}
return result;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:SearchGroupsResultTransformer.java
示例5: transformToNative
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> transformToNative(NamedList<NamedList> shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) {
Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> result = new HashMap<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>>();
for (Map.Entry<String, NamedList> command : shardResponse) {
List<SearchGroup<BytesRef>> searchGroups = new ArrayList<SearchGroup<BytesRef>>();
NamedList topGroupsAndGroupCount = command.getValue();
@SuppressWarnings("unchecked")
NamedList<List<Comparable>> rawSearchGroups = (NamedList<List<Comparable>>) topGroupsAndGroupCount.get("topGroups");
if (rawSearchGroups != null) {
for (Map.Entry<String, List<Comparable>> rawSearchGroup : rawSearchGroups){
SearchGroup<BytesRef> searchGroup = new SearchGroup<BytesRef>();
searchGroup.groupValue = rawSearchGroup.getKey() != null ? new BytesRef(rawSearchGroup.getKey()) : null;
searchGroup.sortValues = rawSearchGroup.getValue().toArray(new Comparable[rawSearchGroup.getValue().size()]);
searchGroups.add(searchGroup);
}
}
Integer groupCount = (Integer) topGroupsAndGroupCount.get("groupCount");
result.put(command.getKey(), new Pair<Integer, Collection<SearchGroup<BytesRef>>>(groupCount, searchGroups));
}
return result;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:SearchGroupsResultTransformer.java
示例6: result
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
@Override
public Pair<Integer, Collection<SearchGroup<BytesRef>>> result() {
final Collection<SearchGroup<BytesRef>> topGroups;
if (topNGroups > 0) {
topGroups = firstPassGroupingCollector.getTopGroups(0, true);
} else {
topGroups = Collections.emptyList();
}
final Integer groupCount;
if (includeGroupCount) {
groupCount = allGroupsCollector.getGroupCount();
} else {
groupCount = null;
}
return new Pair<Integer, Collection<SearchGroup<BytesRef>>>(groupCount, topGroups);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:SearchGroupsFieldCommand.java
示例7: serializeSearchGroup
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data, Sort groupSort) {
NamedList<Object[]> result = new NamedList<Object[]>();
for (SearchGroup<BytesRef> searchGroup : data) {
Object[] convertedSortValues = new Object[searchGroup.sortValues.length];
for (int i = 0; i < searchGroup.sortValues.length; i++) {
Object sortValue = searchGroup.sortValues[i];
SchemaField field = groupSort.getSort()[i].getField() != null ? searcher.getSchema().getFieldOrNull(groupSort.getSort()[i].getField()) : null;
if (field != null) {
FieldType fieldType = field.getType();
if (sortValue != null) {
sortValue = fieldType.marshalSortValue(sortValue);
}
}
convertedSortValues[i] = sortValue;
}
String groupValue = searchGroup.groupValue != null ? searchGroup.groupValue.utf8ToString() : null;
result.add(groupValue, convertedSortValues);
}
return result;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:SearchGroupsResultTransformer.java
示例8: FunctionDistinctValuesCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
public FunctionDistinctValuesCollector(Map<?, ?> vsContext, ValueSource groupSource, ValueSource countSource, Collection<SearchGroup<MutableValue>> groups) {
this.vsContext = vsContext;
this.groupSource = groupSource;
this.countSource = countSource;
groupMap = new LinkedHashMap<>();
for (SearchGroup<MutableValue> group : groups) {
groupMap.put(group.groupValue, new GroupCount(group.groupValue));
}
}
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:FunctionDistinctValuesCollector.java
示例9: TermSecondPassGroupingCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
public TermSecondPassGroupingCollector(String groupField, Collection<SearchGroup<BytesRef>> groups, Sort groupSort, Sort withinGroupSort,
int maxDocsPerGroup, boolean getScores, boolean getMaxScores, boolean fillSortFields)
throws IOException {
super(groups, groupSort, withinGroupSort, maxDocsPerGroup, getScores, getMaxScores, fillSortFields);
ordSet = new SentinelIntSet(groupMap.size(), -2);
this.groupField = groupField;
groupDocs = (SearchGroupDocs<BytesRef>[]) new SearchGroupDocs[ordSet.keys.length];
}
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:TermSecondPassGroupingCollector.java
示例10: TermDistinctValuesCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* Constructs {@link TermDistinctValuesCollector} instance.
*
* @param groupField The field to group by
* @param countField The field to count distinct values for
* @param groups The top N groups, collected during the first phase search
*/
public TermDistinctValuesCollector(String groupField, String countField, Collection<SearchGroup<BytesRef>> groups) {
this.groupField = groupField;
this.countField = countField;
this.groups = new ArrayList<>(groups.size());
for (SearchGroup<BytesRef> group : groups) {
this.groups.add(new GroupCount(group.groupValue));
}
ordSet = new SentinelIntSet(groups.size(), -2);
groupCounts = new GroupCount[ordSet.keys.length];
}
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:TermDistinctValuesCollector.java
示例11: transformToNative
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> transformToNative(NamedList<NamedList> shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) {
Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> result = new HashMap<>();
for (Map.Entry<String, NamedList> command : shardResponse) {
List<SearchGroup<BytesRef>> searchGroups = new ArrayList<>();
NamedList topGroupsAndGroupCount = command.getValue();
@SuppressWarnings("unchecked")
NamedList<List<Comparable>> rawSearchGroups = (NamedList<List<Comparable>>) topGroupsAndGroupCount.get("topGroups");
if (rawSearchGroups != null) {
for (Map.Entry<String, List<Comparable>> rawSearchGroup : rawSearchGroups){
SearchGroup<BytesRef> searchGroup = new SearchGroup<>();
searchGroup.groupValue = rawSearchGroup.getKey() != null ? new BytesRef(rawSearchGroup.getKey()) : null;
searchGroup.sortValues = rawSearchGroup.getValue().toArray(new Comparable[rawSearchGroup.getValue().size()]);
for (int i = 0; i < searchGroup.sortValues.length; i++) {
SchemaField field = groupSort.getSort()[i].getField() != null ? searcher.getSchema().getFieldOrNull(groupSort.getSort()[i].getField()) : null;
if (field != null) {
FieldType fieldType = field.getType();
if (searchGroup.sortValues[i] != null) {
searchGroup.sortValues[i] = fieldType.unmarshalSortValue(searchGroup.sortValues[i]);
}
}
}
searchGroups.add(searchGroup);
}
}
Integer groupCount = (Integer) topGroupsAndGroupCount.get("groupCount");
result.put(command.getKey(), new Pair<Integer, Collection<SearchGroup<BytesRef>>>(groupCount, searchGroups));
}
return result;
}
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:SearchGroupsResultTransformer.java
示例12: createRequestForSpecificShards
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private ShardRequest[] createRequestForSpecificShards(ResponseBuilder rb) {
// Determine all unique shards to query for TopGroups
Set<String> uniqueShards = new HashSet<>();
for (String command : rb.searchGroupToShards.keySet()) {
Map<SearchGroup<BytesRef>, Set<String>> groupsToShard = rb.searchGroupToShards.get(command);
for (Set<String> shards : groupsToShard.values()) {
uniqueShards.addAll(shards);
}
}
return createRequest(rb, uniqueShards.toArray(new String[uniqueShards.size()]));
}
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TopGroupsShardRequestFactory.java
示例13: TopGroupsFieldCommand
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private TopGroupsFieldCommand(SchemaField field,
Sort groupSort,
Sort sortWithinGroup,
Collection<SearchGroup<BytesRef>> firstPhaseGroups,
int maxDocPerGroup,
boolean needScores,
boolean needMaxScore) {
this.field = field;
this.groupSort = groupSort;
this.sortWithinGroup = sortWithinGroup;
this.firstPhaseGroups = firstPhaseGroups;
this.maxDocPerGroup = maxDocPerGroup;
this.needScores = needScores;
this.needMaxScore = needMaxScore;
}
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TopGroupsFieldCommand.java
示例14: FunctionDistinctValuesCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
public FunctionDistinctValuesCollector(Map<?, ?> vsContext, ValueSource groupSource, ValueSource countSource, Collection<SearchGroup<MutableValue>> groups) {
this.vsContext = vsContext;
this.groupSource = groupSource;
this.countSource = countSource;
groupMap = new LinkedHashMap<MutableValue, GroupCount>();
for (SearchGroup<MutableValue> group : groups) {
groupMap.put(group.groupValue, new GroupCount(group.groupValue));
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:10,代码来源:FunctionDistinctValuesCollector.java
示例15: TermSecondPassGroupingCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public TermSecondPassGroupingCollector(String groupField, Collection<SearchGroup<BytesRef>> groups, Sort groupSort, Sort withinGroupSort,
int maxDocsPerGroup, boolean getScores, boolean getMaxScores, boolean fillSortFields)
throws IOException {
super(groups, groupSort, withinGroupSort, maxDocsPerGroup, getScores, getMaxScores, fillSortFields);
ordSet = new SentinelIntSet(groupMap.size(), -2);
this.groupField = groupField;
groupDocs = (SearchGroupDocs<BytesRef>[]) new SearchGroupDocs[ordSet.keys.length];
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:10,代码来源:TermSecondPassGroupingCollector.java
示例16: TermDistinctValuesCollector
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* Constructs {@link TermDistinctValuesCollector} instance.
*
* @param groupField The field to group by
* @param countField The field to count distinct values for
* @param groups The top N groups, collected during the first phase search
*/
public TermDistinctValuesCollector(String groupField, String countField, Collection<SearchGroup<BytesRef>> groups) {
this.groupField = groupField;
this.countField = countField;
this.groups = new ArrayList<GroupCount>(groups.size());
for (SearchGroup<BytesRef> group : groups) {
this.groups.add(new GroupCount(group.groupValue));
}
ordSet = new SentinelIntSet(groups.size(), -2);
groupCounts = new GroupCount[ordSet.keys.length];
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:TermDistinctValuesCollector.java
示例17: serializeSearchGroup
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data, Sort groupSort) {
NamedList<Comparable[]> result = new NamedList<Comparable[]>();
CharsRef spare = new CharsRef();
for (SearchGroup<BytesRef> searchGroup : data) {
Comparable[] convertedSortValues = new Comparable[searchGroup.sortValues.length];
for (int i = 0; i < searchGroup.sortValues.length; i++) {
Comparable sortValue = (Comparable) searchGroup.sortValues[i];
SchemaField field = groupSort.getSort()[i].getField() != null ? searcher.getSchema().getFieldOrNull(groupSort.getSort()[i].getField()) : null;
if (field != null) {
FieldType fieldType = field.getType();
if (sortValue instanceof BytesRef) {
UnicodeUtil.UTF8toUTF16((BytesRef)sortValue, spare);
String indexedValue = spare.toString();
sortValue = (Comparable) fieldType.toObject(field.createField(fieldType.indexedToReadable(indexedValue), 1.0f));
} else if (sortValue instanceof String) {
sortValue = (Comparable) fieldType.toObject(field.createField(fieldType.indexedToReadable((String) sortValue), 1.0f));
}
}
convertedSortValues[i] = sortValue;
}
String groupValue = searchGroup.groupValue != null ? searchGroup.groupValue.utf8ToString() : null;
result.add(groupValue, convertedSortValues);
}
return result;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:SearchGroupsResultTransformer.java
示例18: createRequestForSpecificShards
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
private ShardRequest[] createRequestForSpecificShards(ResponseBuilder rb) {
// Determine all unique shards to query for TopGroups
Set<String> uniqueShards = new HashSet<String>();
for (String command : rb.searchGroupToShards.keySet()) {
Map<SearchGroup<BytesRef>, Set<String>> groupsToShard = rb.searchGroupToShards.get(command);
for (Set<String> shards : groupsToShard.values()) {
uniqueShards.addAll(shards);
}
}
return createRequest(rb, uniqueShards.toArray(new String[uniqueShards.size()]));
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:13,代码来源:TopGroupsShardRequestFactory.java
示例19: transformToNative
import org.apache.lucene.search.grouping.SearchGroup; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> transformToNative(NamedList<NamedList> shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) {
Map<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>> result = new HashMap<String, Pair<Integer, Collection<SearchGroup<BytesRef>>>>();
for (Map.Entry<String, NamedList> command : shardResponse) {
List<SearchGroup<BytesRef>> searchGroups = new ArrayList<SearchGroup<BytesRef>>();
NamedList topGroupsAndGroupCount = command.getValue();
@SuppressWarnings("unchecked")
NamedList<List<Comparable>> rawSearchGroups = (NamedList<List<Comparable>>) topGroupsAndGroupCount.get("topGroups");
if (rawSearchGroups != null) {
for (Map.Entry<String, List<Comparable>> rawSearchGroup : rawSearchGroups){
SearchGroup<BytesRef> searchGroup = new SearchGroup<BytesRef>();
searchGroup.groupValue = rawSearchGroup.getKey() != null ? new BytesRef(rawSearchGroup.getKey()) : null;
searchGroup.sortValues = rawSearchGroup.getValue().toArray(new Comparable[rawSearchGroup.getValue().size()]);
for (int i = 0; i < searchGroup.sortValues.length; i++) {
SchemaField field = groupSort.getSort()[i].getField() != null ? searcher.getSchema().getFieldOrNull(groupSort.getSort()[i].getField()) : null;
if (field != null) {
FieldType fieldType = field.getType();
if (searchGroup.sortValues[i] != null) {
searchGroup.sortValues[i] = fieldType.unmarshalSortValue(searchGroup.sortValues[i]);
}
}
}
searchGroups.add(searchGroup);
}
}
Integer groupCount = (Integer) topGroupsAndGroupCount.get("groupCount");
result.put(command.getKey(), new Pair<Integer, Collection<SearchGroup<BytesRef>>>(groupCount, searchGroups));
}
return result;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:35,代码来源:SearchGroupsResultTransformer.java
注:本文中的org.apache.lucene.search.grouping.SearchGroup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论