2007-09-14
solr改造篇
关键字: solr hadoop hdfs
solr本身支持分布式索引,是利用rsync来做的,
详见文档:
http://wiki.apache.org/solr/CollectionDistribution
但是,我是想利用hdfs来作这件事,在看了solr的源代码后,发现其并不能配置为直接支持hdfs,他默认就是读取写入本地文件系统,代码片段如下:
目前手工hack了SolrCore.java,让其支持HDFS
搜索部分的切换:
目前可以通过HDFS来读取索引文件并完成查询
详见文档:
http://wiki.apache.org/solr/CollectionDistribution
但是,我是想利用hdfs来作这件事,在看了solr的源代码后,发现其并不能配置为直接支持hdfs,他默认就是读取写入本地文件系统,代码片段如下:
File dirFile = new File(getIndexDir()); Directory dir = FSDirectory.getDirectory(d irFile, !indexExists);
目前手工hack了SolrCore.java,让其支持HDFS
InetSocketAddress addr = DataNode.createSocketAddr("10.88.15.59:9000");
FileSystem fs = new DistributedFileSystem(addr, conf);
FsDirectory dir = new FsDirectory(fs, new Path(getIndexDir()),false, conf);
boolean indexExists = fs.exists(new Path(getIndexDir()));
搜索部分的切换:
Configuration conf = new Configuration();
InetSocketAddress addr = DataNode.createSocketAddr("10.88.15.59:9000");
FileSystem fs = new DistributedFileSystem(addr, conf);
FsDirectory dir=new FsDirectory(fs, new Path(index_path), false, conf);
IndexReader reader = IndexReader.open(dir);
tmp = new SolrIndexSearcher(schema, "main", reader, true);
目前可以通过HDFS来读取索引文件并完成查询
发表评论
- 浏览: 3335 次
- 性别:


- 详细资料
搜索本博客
最近加入圈子
最新评论
-
solr弯路篇
lucene,solr,hadoop,nutch,这几者更适合作什么呢? 个人 ...
-- by chenlb -
Hadoop and Lucene
汗,来点实际的。这些算什么东西,光概念
-- by 火柴天堂 -
solr弯路篇
有详细的资料吗,我想学习一下.谢谢
-- by surpass_li -
solr改造篇
看了CollectionDistribution的过程,因为是E文的,而且也说的 ...
-- by tovegar -
Hadoop and Lucene
呵呵,期待看到你更多的成果
-- by 老熊






评论排行榜