Methods Summary |
---|
public void | addSpanNearQuery(org.apache.lucene.search.Query q)
if (q == SrndQuery.theEmptyLcnQuery)
return;
if (! (q instanceof SpanNearQuery))
throw new AssertionError("Expected SpanNearQuery: " + q.toString(getFieldName()));
/* CHECKME: wrap in Hashable...? */
addSpanQueryWeighted((SpanNearQuery)q, q.getBoost());
|
protected void | addSpanQueryWeighted(org.apache.lucene.search.spans.SpanQuery sq, float weight)
Float w = (Float) weightBySpanQuery.get(sq);
if (w != null)
w = new Float(w.floatValue() + weight);
else
w = new Float(weight);
weightBySpanQuery.put(sq, w);
|
public void | addTermWeighted(org.apache.lucene.index.Term t, float weight)
SpanTermQuery stq = qf.newSpanTermQuery(t);
/* CHECKME: wrap in Hashable...? */
addSpanQueryWeighted(stq, weight);
|
public void | clear()weightBySpanQuery.clear();
|
public BasicQueryFactory | getBasicQueryFactory()return qf;
|
public java.lang.String | getFieldName()return fieldName;
|
public org.apache.lucene.index.IndexReader | getIndexReader()return reader;
|
public org.apache.lucene.index.TermEnum | getTermEnum(java.lang.String termText)
return getIndexReader().terms(new Term(getFieldName(), termText));
|
public org.apache.lucene.search.spans.SpanQuery | makeSpanNearClause()
SpanQuery [] spanQueries = new SpanQuery[size()];
Iterator sqi = weightBySpanQuery.keySet().iterator();
int i = 0;
while (sqi.hasNext()) {
SpanQuery sq = (SpanQuery) sqi.next();
sq.setBoost(((Float)weightBySpanQuery.get(sq)).floatValue());
spanQueries[i++] = sq;
}
/* CHECKME: Does the underlying implementation of SpanQuery need sorting? */
if (false) /* true when sorting needed */
Arrays.sort(spanQueries, new Comparator() {
public int compare(Object o1, Object o2) {
SpanQuery sq1 = (SpanQuery) o1;
SpanQuery sq2 = (SpanQuery) o2;
/* compare the text of the first term of each SpanQuery */
return ((Term)sq1.getTerms().iterator().next()).text().compareTo(
((Term)sq2.getTerms().iterator().next()).text());
}
public boolean equals(Object o) {return false;}
});
if (spanQueries.length == 1)
return spanQueries[0];
else
return new SpanOrQuery(spanQueries);
|
public int | size()return weightBySpanQuery.size();
|