本文整理汇总了Java中org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy.createIndexableFields方法的典型用法代码示例。如果您正苦于以下问题:Java TermQueryPrefixTreeStrategy.createIndexableFields方法的具体用法?Java TermQueryPrefixTreeStrategy.createIndexableFields怎么用?Java TermQueryPrefixTreeStrategy.createIndexableFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy
的用法示例。
在下文中一共展示了TermQueryPrefixTreeStrategy.createIndexableFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBadPrefixTreePrune
import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy; //导入方法依赖的package包/类
/**
* A PrefixTree pruning optimization gone bad.
* See <a href="https://issues.apache.org/jira/browse/LUCENE-4770>LUCENE-4770</a>.
*/
@Test
public void testBadPrefixTreePrune() throws Exception {
trie = new QuadPrefixTree(ctx, 12);
TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
Document doc = new Document();
doc.add(new TextField("id", "1", Store.YES));
Shape area = ctx.makeRectangle(-122.82, -122.78, 48.54, 48.56);
Field[] fields = strategy.createIndexableFields(area, 0.025);
for (Field field : fields) {
doc.add(field);
}
addDocument(doc);
Point upperleft = ctx.makePoint(-122.88, 48.54);
Point lowerright = ctx.makePoint(-122.82, 48.62);
Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));
commit();
TopDocs search = indexSearcher.search(query, 10);
ScoreDoc[] scoreDocs = search.scoreDocs;
for (ScoreDoc scoreDoc : scoreDocs) {
System.out.println(indexSearcher.doc(scoreDoc.doc));
}
assertEquals(1, search.totalHits);
}