本文整理汇总了Java中org.apache.lucene.index.TermPositions类的典型用法代码示例。如果您正苦于以下问题:Java TermPositions类的具体用法?Java TermPositions怎么用?Java TermPositions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TermPositions类属于org.apache.lucene.index包,在下文中一共展示了TermPositions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: scorer
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
final Scorer scorer(IndexReader reader) throws IOException {
if (terms.size() == 0) // optimize zero-term case
return null;
if (terms.size() == 1) { // optimize one-term case
Term term = (Term)terms.elementAt(0);
TermDocs docs = reader.termDocs(term);
if (docs == null)
return null;
return new TermScorer(docs, reader.norms(term.field()), weight);
}
TermPositions[] tps = new TermPositions[terms.size()];
for (int i = 0; i < terms.size(); i++) {
TermPositions p = reader.termPositions((Term)terms.elementAt(i));
if (p == null)
return null;
tps[i] = p;
}
if (slop == 0) // optimize exact case
return new ExactPhraseScorer(tps, reader.norms(field), weight);
else
return
new SloppyPhraseScorer(tps, slop, reader.norms(field), weight);
}
开发者ID:SpoonLabs,项目名称:gumtree-spoon-ast-diff,代码行数:27,代码来源:right_PhraseQuery_1.5.java
示例2: getTerms
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
public Set<FieldValue> getTerms(int docId, Set<String> fieldNameSet) throws IOException {
TermPositions termPosition = indexReader.termPositions();
Set<FieldValue> fieldValueSet = new HashSet<FieldValue>();
for (String fieldName : fieldNameSet) {
List<FieldValueItem> fieldValueItemList = new ArrayList<FieldValueItem>();
TermEnum termEnum = indexReader.terms(new Term(fieldName, ""));
if (termEnum == null)
continue;
Term term = termEnum.term();
if (!term.field().equals(fieldName))
continue;
do {
term = termEnum.term();
if (!term.field().equals(fieldName))
break;
termPosition.seek(term);
if (!termPosition.skipTo(docId) || termPosition.doc() != docId)
continue;
fieldValueItemList.add(new FieldValueItem(FieldValueOriginEnum.TERM_ENUM, term.text()));
} while (termEnum.next());
termEnum.close();
if (fieldValueItemList.size() > 0)
fieldValueSet.add(new FieldValue(fieldName, fieldValueItemList));
}
return fieldValueSet;
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:27,代码来源:ReaderLocal.java
示例3: joinTermAllMatches
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public Result joinTermAllMatches(Result result, TermPositions term,
NodeDataBuffer previous, byte[] payloadBuffer,
int[] positionsBuffer, TreeAxis axis, int termId) throws IOException {
int freq = term.freq();
int bufferPtr = 0;
int validInstances = 0;
for (int i = 0; i < freq && validInstances < NodeDataBuffer.BUFFER_SIZE; i++) {
positionsBuffer[validInstances] = term.nextPosition();
int position = positionsBuffer[validInstances];
if (shouldLoadPayload(position, previous)) {
bufferPtr = NodeDataBuffer.PAYLOAD_LENGTH * validInstances;
term.getPayload(payloadBuffer, bufferPtr);
boolean updatedValidInstanceFlag = false;
for (int j = previous.size - 1; j >= 0
&& validInstances < NodeDataBuffer.BUFFER_SIZE
&& position <= previous.positions[j]; j--) {
byte[] start = previous.getAsBytes(j);
if (logic.joinBytesWithBytes(start, 0, payloadBuffer,
bufferPtr)) {
if (!updatedValidInstanceFlag) {
validInstances++;
updatedValidInstanceFlag = true;
}
byte[] end = getByteArray(payloadBuffer, bufferPtr);
result.addNew(start, end, axis, termId);
}
}
}
}
return result;
}
开发者ID:arne-cl,项目名称:fangorn,代码行数:34,代码来源:LastToFirstJoin.java
示例4: joinTerm
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public int joinTerm(TermPositions term, NodeDataBuffer previous,
byte[] payloadBuffer, int[] positionsBuffer,
LookaheadOptimization optimization, boolean stopAtFirst)
throws IOException {
int freq = term.freq();
int bufferPtr = 0;
int validInstances = 0;
int val;
for (int i = 0; i < freq && validInstances < NodeDataBuffer.BUFFER_SIZE; i++) {
term.nextPosition();
bufferPtr = NodeDataBuffer.PAYLOAD_LENGTH * validInstances;
term.getPayload(payloadBuffer, bufferPtr);
val = LookaheadOptimization.WRITE;
if (!optimization.equals(LookaheadOptimization.NONE)
&& validInstances > 0) {
val = optimization.check(payloadBuffer, validInstances - 1);
if (val == LookaheadOptimization.IGNORE)
continue;
}
for (int j = previous.size - 1; j >= 0
&& validInstances < NodeDataBuffer.BUFFER_SIZE; j--) {
if (logic.joinBufWithBytes(previous, j, payloadBuffer,
bufferPtr)) {
if (val == LookaheadOptimization.WRITE) {
validInstances++;
} else if (val == LookaheadOptimization.OVERWRITE) {
overwritePrevPayloadBuf(payloadBuffer, validInstances);
}
if (stopAtFirst)
return 1;
break;
}
}
}
return validInstances;
}
开发者ID:arne-cl,项目名称:fangorn,代码行数:39,代码来源:LastToFirstJoin.java
示例5: joinTermAllMatches
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public Result joinTermAllMatches(Result result, TermPositions term,
NodeDataBuffer previous, byte[] payloadBuffer,
int[] positionsBuffer, TreeAxis axis, int termId) throws IOException {
int freq = term.freq();
int bufferPtr = 0;
int validInstances = 0;
for (int i = 0; i < freq && validInstances < NodeDataBuffer.BUFFER_SIZE; i++) {
positionsBuffer[validInstances] = term.nextPosition();
int position = positionsBuffer[validInstances];
if (shouldLoadPayload(position, previous)) {
bufferPtr = NodeDataBuffer.PAYLOAD_LENGTH * validInstances;
term.getPayload(payloadBuffer, bufferPtr);
boolean updatedValidInstanceFlag = false;
for (int j = 0; j < previous.size()
&& validInstances < NodeDataBuffer.BUFFER_SIZE
&& position >= previous.positions[j]; j++) {
byte[] start = previous.getAsBytes(j);
if (logic.joinBytesWithBytes(start, 0, payloadBuffer,
bufferPtr)) {
if (!updatedValidInstanceFlag) {
validInstances++;
updatedValidInstanceFlag = true;
}
byte[] end = getByteArray(payloadBuffer, bufferPtr);
result.addNew(start, end, axis, termId);
}
}
}
}
return result;
}
开发者ID:arne-cl,项目名称:fangorn,代码行数:34,代码来源:FirstToLastJoin.java
示例6: joinTerm
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public int joinTerm(TermPositions term, NodeDataBuffer previous,
byte[] payloadBuffer, int[] positionsBuffer,
LookaheadOptimization optimization, boolean stopAtFirst)
throws IOException {
int freq = term.freq();
int bufferPtr = 0;
int validInstances = 0;
int val;
for (int i = 0; i < freq && validInstances < NodeDataBuffer.BUFFER_SIZE; i++) {
term.nextPosition();
bufferPtr = NodeDataBuffer.PAYLOAD_LENGTH * validInstances;
term.getPayload(payloadBuffer, bufferPtr);
val = LookaheadOptimization.WRITE;
if (!optimization.equals(LookaheadOptimization.NONE)
&& validInstances > 0) {
val = optimization.check(payloadBuffer, validInstances - 1);
if (val == LookaheadOptimization.IGNORE)
continue;
}
for (int j = 0; j < previous.size()
&& validInstances < NodeDataBuffer.BUFFER_SIZE; j++) {
if (logic.joinBufWithBytes(previous, j, payloadBuffer,
bufferPtr)) {
if (val == LookaheadOptimization.WRITE) {
validInstances++;
} else if (val == LookaheadOptimization.OVERWRITE) {
overwritePrevPayloadBuf(payloadBuffer, validInstances);
}
if (stopAtFirst)
return 1;
break;
}
}
}
return validInstances;
}
开发者ID:arne-cl,项目名称:fangorn,代码行数:39,代码来源:FirstToLastJoin.java
示例7: getTermPostings
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/**
* Devuelve los postings de un término dado
*
* @param term Termino a buscar para devolver sus postings
* @return lista de postings de un termino
*/
@Override
public List<Posting> getTermPostings(String term) {
ArrayList<Posting> postingList = new ArrayList<>();
try {
TermDocs termDocs = ireader.termDocs(new Term("content", term));
TermPositions termPositions = ireader.termPositions(new Term("content", term));
//si se usa seek termDocs se borra
//termDocs.seek(new Term(term));
while(termDocs.next()) {
int docId = termDocs.doc();
int freq = termDocs.freq();
ArrayList<Long> positions = new ArrayList<>();
while (termPositions.next()) {
positions.add((long)termPositions.nextPosition());
}
Posting p = new Posting(docId + "", freq, positions);
postingList.add(p);
}
return postingList;
} catch (IOException ex) {
Logger.getLogger(LuceneIndexing.class.getName()).log(Level.SEVERE, null, ex);
}
return postingList;
}
开发者ID:garnachod,项目名称:mineria2,代码行数:34,代码来源:LuceneIndexing.java
示例8: LeafScorer
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/**
* Constructor - should use an arg object ...
*
* @param weight
* @param root
* @param level0
* @param containerScorer
* @param sfps
* @param followParentInLevel0
* @param selfIds
* @param reader
* @param similarity
* @param norms
* @param dictionaryService
* @param repeat
*/
public LeafScorer(Weight weight, TermPositions root, TermPositions level0, ContainerScorer containerScorer, StructuredFieldPosition[] sfps, boolean followParentInLevel0,
HashMap<String, Counter> selfIds, IndexReader reader, Similarity similarity, byte[] norms, DictionaryService dictionaryService, boolean repeat)
{
super(similarity);
this.root = root;
this.containerScorer = containerScorer;
this.sfps = sfps;
//A this.allNodes = allNodes;
// this.tp = tp;
if (selfIds == null)
{
this.selfIds = new HashMap<String, Counter>();
hasSelfScorer = false;
}
else
{
this.selfIds = selfIds;
hasSelfScorer = true;
}
this.reader = reader;
this.level0 = level0;
this.dictionaryService = dictionaryService;
this.repeat = repeat;
this.followParentInLevel0 = followParentInLevel0;
matchAllLeaves = allNodes();
try
{
initialise();
}
catch (IOException e)
{
throw new LeafScorerException("IO Error:", e);
}
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:53,代码来源:LeafScorer.java
示例9: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public void termPositions(final FunctionUtils.ConsumerEx<TermPositions, IOException> termPositionsConsumer)
throws IOException {
try (final TermPositions termPositions = indexReader.termPositions()) {
termPositionsConsumer.accept(termPositions);
}
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:8,代码来源:ReaderLocal.java
示例10: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
final public void termPositions(FunctionUtils.ConsumerEx<TermPositions, IOException> termPositionsConsumer)
throws IOException, SearchLibException {
checkOnline(true);
final ReaderLocal reader = acquire();
try {
reader.termPositions(termPositionsConsumer);
} finally {
release(reader);
}
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:12,代码来源:IndexSingle.java
示例11: FilterTermPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/**
* @param id String
* @param in TermPositions
*/
public FilterTermPositions(String id, TermPositions in)
{
super(id, in);
tp = in;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:FilterIndexReaderByStringId.java
示例12: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
@Override
public TermPositions termPositions() throws IOException
{
return new FilterTermPositions(id, super.termPositions());
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:6,代码来源:FilterIndexReaderByStringId.java
示例13: createPathScorer
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
public static SolrPathScorer createPathScorer(Similarity similarity, SolrPathQuery solrPathQuery, SolrIndexReader reader, Weight weight, DictionaryService dictionarySertvice, boolean repeat) throws IOException
{
StructuredFieldPosition last = null;
if(solrPathQuery.getPathStructuredFieldPositions().size() > 0)
{
last = solrPathQuery.getPathStructuredFieldPositions().get(solrPathQuery.getPathStructuredFieldPositions().size() - 1);
}
if (solrPathQuery.getPathStructuredFieldPositions().size() == 0)
{
ArrayList<StructuredFieldPosition> answer = new ArrayList<StructuredFieldPosition>(2);
answer.add(new SelfAxisStructuredFieldPosition());
answer.add(new SelfAxisStructuredFieldPosition());
solrPathQuery.appendQuery(answer);
}
for (StructuredFieldPosition sfp : solrPathQuery.getPathStructuredFieldPositions())
{
if (sfp.getTermText() != null)
{
TermPositions p = reader.termPositions(new Term(solrPathQuery.getPathField(), sfp.getTermText()));
if (p == null)
return null;
CachingTermPositions ctp = new CachingTermPositions(p);
sfp.setCachingTermPositions(ctp);
}
}
SolrContainerScorer cs = null;
TermPositions rootContainerPositions = null;
if (solrPathQuery.getPathRootTerm() != null)
{
rootContainerPositions = reader.termPositions(solrPathQuery.getPathRootTerm());
}
if (solrPathQuery.getPathStructuredFieldPositions().size() > 0)
{
cs = new SolrContainerScorer(weight, rootContainerPositions, (StructuredFieldPosition[]) solrPathQuery.getPathStructuredFieldPositions().toArray(new StructuredFieldPosition[] {}),
similarity, reader.norms(solrPathQuery.getPathField()));
}
return new SolrPathScorer(similarity, cs);
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:50,代码来源:SolrPathScorer.java
示例14: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
public TermPositions termPositions() throws IOException
{
// TODO Auto-generated method stub
throw new UnsupportedOperationException();
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:6,代码来源:DeltaReader.java
示例15: CachingTermPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
public CachingTermPositions(TermPositions delegate)
{
this.delegate = delegate;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:5,代码来源:CachingTermPositions.java
示例16: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
public TermPositions termPositions()
throws IOException
{
return new LimTermPositions(this, wrapped.termPositions());
}
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:6,代码来源:LimIndexReader.java
示例17: LimTermPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/** Create a new wrapper around a TermPositions */
public LimTermPositions(LimIndexReader reader, TermPositions toWrap) {
this.wrapped = toWrap;
this.reader = reader;
}
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:6,代码来源:LimTermPositions.java
示例18: termPositions
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
void termPositions(FunctionUtils.ConsumerEx<TermPositions, IOException> TermPositions) throws IOException,
SearchLibException;
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:3,代码来源:ReaderInterface.java
示例19: SolrContainerScorer
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/**
* The arguments here follow the same pattern as used by the PhraseQuery.
* (It has the same unused arguments)
*
* @param weight -
* curently unsued
* @param root -
* the term positions for documents with multiple entries - this
* may be null, or contain no matches - it specifies those things
* that appear under multiple categories etc.
* @param positions -
* the structured field positions - where terms should appear
* @param similarity -
* used in the abstract scorer implementation
* @param norms -
* unused
*/
public SolrContainerScorer(Weight weight, TermPositions root, StructuredFieldPosition[] positions, Similarity similarity, byte[] norms)
{
super(similarity);
this.weight = weight;
this.positions = positions;
this.norms = norms;
this.root = root;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:SolrContainerScorer.java
示例20: ContainerScorer
import org.apache.lucene.index.TermPositions; //导入依赖的package包/类
/**
* The arguments here follow the same pattern as used by the PhraseQuery.
* (It has the same unused arguments)
*
* @param weight -
* curently unsued
* @param root -
* the term positions for documents with multiple entries - this
* may be null, or contain no matches - it specifies those things
* that appear under multiple categories etc.
* @param positions -
* the structured field positions - where terms should appear
* @param containers TermPositions
* @param similarity -
* used in the abstract scorer implementation
* @param norms -
* unused
*/
public ContainerScorer(Weight weight, TermPositions root, StructuredFieldPosition[] positions, TermPositions containers, Similarity similarity, byte[] norms)
{
super(similarity);
this.weight = weight;
this.positions = positions;
this.norms = norms;
this.root = root;
this.containers = containers;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:28,代码来源:ContainerScorer.java
注:本文中的org.apache.lucene.index.TermPositions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论