本文整理汇总了Java中org.apache.lucene.search.spans.Spans.isPayloadAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java Spans.isPayloadAvailable方法的具体用法?Java Spans.isPayloadAvailable怎么用?Java Spans.isPayloadAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.spans.Spans
的用法示例。
在下文中一共展示了Spans.isPayloadAvailable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPayloads
import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
throws IOException {
Map<Term,TermContext> termContexts = new HashMap<>();
TreeSet<Term> terms = new TreeSet<>();
query.extractTerms(terms);
for (Term term : terms) {
termContexts.put(term, TermContext.build(context, term));
}
for (AtomicReaderContext atomicReaderContext : context.leaves()) {
final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
while (spans.next() == true) {
if (spans.isPayloadAvailable()) {
Collection<byte[]> payload = spans.getPayload();
for (byte [] bytes : payload) {
payloads.add(bytes);
}
}
}
}
}
示例2: CandidateSpan
import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
/**
* Constructs a CandidateSpan for the given Span.
*
* @param span
* a Span
* @throws IOException
*/
public CandidateSpan (Spans span) throws IOException {
this.doc = span.doc();
this.start = span.start();
this.end = span.end();
this.cost = span.cost();
this.payloads = new ArrayList<>();
if (span.isPayloadAvailable()) {
setPayloads(span.getPayload());
}
if (span instanceof SimpleSpans) {
SimpleSpans temp = (SimpleSpans) span;
this.spanId = temp.getSpanId();
this.hasSpanId = temp.hasSpanId;
}
else if (span instanceof ClassSpans) {
this.spanId = ((ClassSpans) span).getNumber();
this.hasSpanId = true;
}
}
示例3: getPayloads
import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
throws IOException {
Map<Term,TermContext> termContexts = new HashMap<Term,TermContext>();
TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms);
for (Term term : terms) {
termContexts.put(term, TermContext.build(context, term, true));
}
for (AtomicReaderContext atomicReaderContext : context.leaves()) {
final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
while (spans.next() == true) {
if (spans.isPayloadAvailable()) {
Collection<byte[]> payload = spans.getPayload();
for (byte [] bytes : payload) {
payloads.add(bytes);
}
}
}
}
}
示例4: getPayloads
import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
throws IOException {
Map<Term,TermContext> termContexts = new HashMap<Term,TermContext>();
TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms);
for (Term term : terms) {
termContexts.put(term, TermContext.build(context, term));
}
for (AtomicReaderContext atomicReaderContext : context.leaves()) {
final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
while (spans.next() == true) {
if (spans.isPayloadAvailable()) {
Collection<byte[]> payload = spans.getPayload();
for (byte [] bytes : payload) {
payloads.add(bytes);
}
}
}
}
}
示例5: getSpanInfo
import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
public static List<String> getSpanInfo (IndexReader reader, SpanQuery query)
throws IOException {
Map<Term, TermContext> termContexts = new HashMap<>();
List<String> spanArray = new ArrayList<>();
for (LeafReaderContext atomic : reader.leaves()) {
Bits bitset = atomic.reader().getLiveDocs();
// Spans spans = NearSpansOrdered();
Spans spans = query.getSpans(atomic, bitset, termContexts);
while (spans.next()) {
StringBuffer payloadString = new StringBuffer();
int docid = atomic.docBase + spans.doc();
if (spans.isPayloadAvailable()) {
for (byte[] payload : spans.getPayload()) {
/* retrieve payload for current matching span */
payloadString.append(byte2int(payload)).append(",");
payloadString.append(byte2int(payload, 2));
// payloadString.append(byte2int(payload, 1));
payloadString.append(" (" + payload.length + ")");
payloadString.append(" | ");
};
};
spanArray.add("Doc: " + docid + " with " + spans.start() + "-"
+ spans.end() + " || " + payloadString.toString());
};
};
return spanArray;
}