好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

lucene 多域搜索

lucene 多域搜索

http://blog.sina.com.cn/s/blog_60452f7d0100lv5g.html


lucene 多字段多域搜索 (2010-10-19 15:29:38)

标签:

杂谈 分类: 搜索引擎

诶 

  先来个浅显能用的,有两种方法:

1.使用 MultiFieldQueryParser:
BooleanClause.Occur[] clauses = {
                                BooleanClause.Occur.SHOULD,
                                BooleanClause.Occur.SHOULD
                          };
              Query query = MultiFieldQueryParser.parse(Version.LUCENE_30, queries, fields, clauses, new StandardAnalyzer(Version.LUCENE_30));

2.使用 BooleanQuery 动态 add query 对象:
BooleanQuery booleanQuery = new BooleanQuery();
     
            QueryParser parser1 = new QueryParser(Version.LUCENE_30, "chapter_name", new StandardAnalyzer(Version.LUCENE_30));
            Query titleQuery = parser1.parse("家");
            booleanQuery.add(titleQuery, BooleanClause.Occur.SHOULD);
     
            QueryParser parser2 = new QueryParser(Version.LUCENE_30, "content", new StandardAnalyzer(Version.LUCENE_30));
            Query contentQuery = parser2.parse("家");
            booleanQuery.add(contentQuery, BooleanClause.Occur.SHOULD);

学习劲头蜗牛爬哇,不过有爬总比趴着好啊



查看更多关于lucene 多域搜索的详细内容...

  阅读:38次

上一篇: mmseg4j相关

下一篇:liststyle