知识大全 Java Lucene排重实现group by

Posted 文字

篇首语:赋料扬雄敌,诗看子建亲。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 Java Lucene排重实现group by相关的知识,希望对你有一定的参考价值。

Java Lucene排重实现group by  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  package loongtao lucene test;

  import java io IOException;

  import apache lucene analysis standard StandardAnalyzer;

  import apache lucene document Document;

  import apache lucene document Field;

  import apache lucene document Field Index;

  import apache lucene document Field Store;

  import apache lucene index CorruptIndexException;

  import apache lucene index IndexWriter;

  import apache lucene index Term;

  import apache lucene index IndexWriter MaxFieldLength;

  import apache lucene search DuplicateFilter;

  import apache lucene search Filter;

  import apache lucene search IndexSearcher;

  import apache lucene search Query;

  import apache lucene search ScoreDoc;

  import apache lucene search TermQuery;

  import apache lucene search TopDocs;

  import apache lucene store Directory;

  import apache lucene store LockObtainFailedException;

  import apache lucene store RAMDirectory;

  import apache lucene util Version;

  public class DuplicateFilterTest

  public static void main(String[] args)

  Directory dir = new RAMDirectory();

  Document doc = new Document();

  doc add(new Field( id binbin Store YES Index NOT_ANALYZED));

  doc add(new Field( string haha Store YES Index NOT_ANALYZED));

  doc add(new Field( time Store YES Index NOT_ANALYZED));

  doc add(new Field( duplicate Store YES Index NOT_ANALYZED));

  Document doc = new Document();

  doc add(new Field( id yaoyao Store YES Index NOT_ANALYZED));

  doc add(new Field( string haha Store YES Index NOT_ANALYZED));

  doc add(new Field( time Store YES Index NOT_ANALYZED));

  doc

   add(new Field( duplicate Store YES

  Index NOT_ANALYZED));

  Document doc = new Document();

  doc add(new Field( id zhangjian Store YES Index NOT_ANALYZED));

  doc add(new Field( string haha Store YES Index NOT_ANALYZED));

  doc add(new Field( time Store YES Index NOT_ANALYZED));

  doc

   add(new Field( duplicate Store YES

  Index NOT_ANALYZED));

  Document doc = new Document();

  doc add(new Field( id liweicheng Store YES Index NOT_ANALYZED));

  doc add(new Field( string haha Store YES Index NOT_ANALYZED));

  doc add(new Field( time Store YES Index NOT_ANALYZED));

  doc

   add(new Field( duplicate Store YES

  Index NOT_ANALYZED));

  try

  IndexWriter indexWriter = new IndexWriter(dir

  new StandardAnalyzer(Version LUCENE_ ) true

  MaxFieldLength LIMITED);

  indexWriter addDocument(doc);

  indexWriter addDocument(doc );

  indexWriter addDocument(doc );

  indexWriter addDocument(doc );

  indexWriter close();

  Query query = new TermQuery(new Term( string haha ));

  Filter filter = new DuplicateFilter( duplicate );

  IndexSearcher indexSearcher = new IndexSearcher(dir);

  TopDocs top = indexSearcher search(query filter );

  ScoreDoc[] scoreDocs = top scoreDocs;

  for (ScoreDoc scoreDoc : scoreDocs)

  Document rdoc = indexSearcher doc(scoreDoc doc);

  System out print( id: +rdoc get( id ) +   排重ID: +rdoc get( duplicate ));

  Query queryDuplicate = new TermQuery(new Term( duplicate rdoc get( duplicate )));

  System out println( 转载: + indexSearcher search(queryDuplicate ) totalHits

  );

  

   catch (CorruptIndexException e)

  e printStackTrace();

   catch (LockObtainFailedException e)

  e printStackTrace();

   catch (IOException e)

  // TODO Auto generated catch block

  e printStackTrace();

  

  

cha138/Article/program/Java/hx/201311/25714

相关参考

知识大全 深入讲解如何使用rollup配合group by命令

  Oracle数据库中的rollup配合groupby命令使用可以提供信息汇总功能(与小计相似)  示例如下  SQL>selectjobdeptnosalfromemp;  JOBDEPTN

知识大全 用Lucene做一个简单的Java搜索工具

用Lucene做一个简单的Java搜索工具  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  初学L

知识大全 如何利用php数组对百万数据进行排重

  如何利用php数组对百万数据进行排重  在平时的工作中经常接到要对网站的会员进行站内信手机短信email进行群发信息的通知用户列表一般由别的同事提供当中难免会有重复为了避免重复发送所以我在进行发送

知识大全 editplus能够编译java嘛? 如何设置

  先要将JAVA的运行环境安装并且调试好  首先从菜单工具(Tools)>配置用户工具进入用户工具设置  在类别里展开工具树形菜单>用户工具选择组和工具项目中的Group点击面板右边的组

知识大全 Lucene 挖掘相关搜索词

Lucene挖掘相关搜索词  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  搜索引擎中往往有一个可

知识大全 Lucene.net的全新体验

Lucene.net的全新体验  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  

知识大全 Lucene在多个索引上进行搜索

Lucene在多个索引上进行搜索  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  代码如下  vi

知识大全 如何使用Lucene对html文件进行索引

如何使用Lucene对html文件进行索引  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  我修改

知识大全 定义Lucene 1.3 用到的索引文件格式

定义Lucene1.3用到的索引文件格式  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  Jaka

知识大全 lucene中对不同的域使用不同的分析器

  在lucene使用过程中如果要对同一IndexWriter中不同Document不同Field中使用不同的analyzer我们该如何实现呢?  通过对《luceneinaction》的阅读发现是可