Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

api - Can a raw Lucene index be loaded by Solr?

Some colleagues of mine have a large Java web app that uses a search system built with Lucene Java. What I'd like to do is have a nice HTTP-based API to access those existing search indexes. I've used Nutch before and really liked how simple the OpenSearch implementation made it to grab results as RSS.

I've tried setting Solr's dataDir in solrconfig.xml, hoping it would happily pick up the existing index files, but it seems to just ignore them.

My main question is:

Can Solr be used to access Lucene indexes created elsewhere? Or might there be a better solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Success! With Pascal's suggestion of changes to schema.xml I got it working in no time. Thanks!

Here are my complete steps for anyone interested:

  1. Downloaded Solr and copied dist/apache-solr-1.4.0.war to tomcat/webapps
  2. Copied example/solr/conf to /usr/local/solr/
  3. Copied pre-existing Lucene index files to /usr/local/solr/data/index
  4. Set solr.home to /usr/local/solr
  5. In solrconfig.xml, changed dataDir to /usr/local/solr/data (Solr looks for the index directory inside)
  6. Loaded my Lucene indexes into Luke for browsing (awesome tool)
  7. In the example schema.xml, removed all fields and field types except for "string"
  8. In the example schema.xml, added 14 field definitions corresponding to the 14 fields shown in Luke. Example: <field name="docId" type="string" indexed="true" stored="true"/>
  9. In the example schema.xml, changed uniqueKey to the field in my index that seemed to be a document id
  10. In the example schema.xml, changed defaultSearchField to the field in my index that seemed to contain terms
  11. Started tomcat, saw no exceptions finally, and successfully ran some queries in localhost:8080/solr/admin

This is just proof for me that it can work. Obviously there's a lot more configuration to be done.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...