开发者

Lucene index over multiple tables

开发者 https://www.devze.com 2023-03-26 23:25 出处:网络
I have three tables in my database: Table:queries Fields->queryID,query Table:keywords Fileds->keyID,keyword

I have three tables in my database:

Table:queries Fields->queryID,query

Table:keywords Fileds->keyID,keyword

Table:queryTag Fileds->queryID,keyID This table has foreign key to the previous 2 tables

Now i would like to create an index in Lucene such that when i search for a particular keyword I am able to retrieve corresponding query from the queries table. I was thinking of creating an index in Lucene from the result of the follwoing query

Select queryTag.queryID,queries.query,keywords.keyword,queryTag.keyID from queries, queryTag, keywords where queryTag.queryID=queries.queryID and queryTag.keyID=keywords.keyID

Do you think this is the right approach?? and also when I use this aproach there will be no unique field in my Lucene document since queri开发者_StackOverflow社区es and keywords have many to many relationship.Will that affect the searching?


Building an lucene index without an primary key is possible, but not in every case an good idea. For example distributed search or adding new documents (incremental) will not work. So you have to create your index from zero, every time you will add new data. http://wiki.apache.org/solr/UniqueKey

So it's the better way to generate an unique field in your sql-statement (for example by concatenating existing fields to one)

How you access the lucene index? With your java application? If you are using an "proxy" like solr, you could use the dataimport-mechanism from that "proxy".. For example solr provides the data import handler, which allows you to define an SQL statement (like yours). Solr executes this statement at your database and inserts the resultset into lucene index.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号