本文整理汇总了Java中org.apache.lucene.search.Hit类的典型用法代码示例。如果您正苦于以下问题:Java Hit类的具体用法?Java Hit怎么用?Java Hit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hit类属于org.apache.lucene.search包,在下文中一共展示了Hit类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getProperty
import org.apache.lucene.search.Hit; //导入依赖的package包/类
private String getProperty(final String propertyName) throws IOException {
if (_dir == null) {
return null;
}
try {
return doReadOperation(new ReadOperation<String>() {
public String execute(final IndexReader reader, final Searcher searcher, final Analyzer analyzer) throws IOException, ParseException {
Hits hits = searcher.search(new TermQuery(new Term(FIELD_PROPERTY_KEY, propertyName)));
Iterator<?> iterator = hits.iterator();
if (iterator.hasNext()) {
return ((Hit) iterator.next()).get(FIELD_PROPERTY_VALUE);
}
return null;
}
}, false);
}
catch (QuerySyntaxException ex) {
throw new NoQueryPerformedException(ex);
}
}
开发者ID:CoreFiling,项目名称:reviki,代码行数:21,代码来源:LuceneSearcher.java
示例2: iterator
import org.apache.lucene.search.Hit; //导入依赖的package包/类
@Override
public Iterator<Conversation> iterator() {
final Iterator<Hit> hitsIterator = hits.iterator();
// Advance the iterator until we hit the index.
for (int i=0; i<index; i++) {
hitsIterator.next();
}
return new Iterator<Conversation>() {
private Conversation nextElement = null;
public boolean hasNext() {
if (nextElement == null) {
nextElement = getNextElement();
if (nextElement == null) {
return false;
}
}
return true;
}
public Conversation next() {
Conversation element;
if (nextElement != null) {
element = nextElement;
nextElement = null;
}
else {
element = getNextElement();
if (element == null) {
throw new NoSuchElementException();
}
}
return element;
}
public void remove() {
throw new UnsupportedOperationException();
}
private Conversation getNextElement() {
if (!hitsIterator.hasNext()) {
return null;
}
// If we've reached the end index, stop iterating.
else if (index >= endIndex) {
return null;
}
while (hitsIterator.hasNext()) {
try {
Hit hit = hitsIterator.next();
// Advance the index.
index++;
long conversationID = Long.parseLong(hit.get("conversationID"));
return new Conversation(conversationManager, conversationID);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
return null;
}
};
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:66,代码来源:ArchiveSearcher.java
示例3: iterator
import org.apache.lucene.search.Hit; //导入依赖的package包/类
@Override
public Iterator<Conversation> iterator() {
final Iterator<Hit> hitsIterator = hits.iterator();
// Advance the iterator until we hit the index.
for (int i=0; i<index; i++) {
hitsIterator.next();
}
return new Iterator<Conversation>() {
private Conversation nextElement = null;
public boolean hasNext() {
if (nextElement == null) {
nextElement = getNextElement();
if (nextElement == null) {
return false;
}
}
return true;
}
public Conversation next() {
Conversation element;
if (nextElement != null) {
element = nextElement;
nextElement = null;
}
else {
element = getNextElement();
if (element == null) {
throw new NoSuchElementException();
}
}
return element;
}
public void remove() {
throw new UnsupportedOperationException();
}
private Conversation getNextElement() {
if (!hitsIterator.hasNext()) {
return null;
}
// If we've reached the end index, stop iterating.
else if (index >= endIndex) {
return null;
}
while (hitsIterator.hasNext()) {
try {
Hit hit = hitsIterator.next();
// Advance the index.
index++;
long conversationID = Long.parseLong(hit.get("conversationID"));
return new Conversation(conversationManager, conversationID);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
return null;
}
};
}
开发者ID:coodeer,项目名称:g3server,代码行数:66,代码来源:ArchiveSearcher.java
注:本文中的org.apache.lucene.search.Hit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论