开发者

storage lucene index in database using data objects in java

Is this possible? I cannot access the database directly--only through data objects. Would I be able to search the index if the items are returned in something like ArrayList?

If this is not possi开发者_StackOverflow中文版ble, is there some way I can use Lucene (or some other tool) to do fuzzy matching against an object using java?

For example, I have a Person object that has a FirstName and LastName. I want to do a fuzzy match on the name. So, say I have an array of x amount of Person objects, would there be an efficient way of looping through each Person object and comparing the names?


Take those data objects and build a separate Lucene index over them, storing the fields you need. Using your Person example, every Lucene document would be [Id, FirstName, LastName]. A search on this index would return the Id required to query your database for the complete data object.

The actual indexing is easy, you just need to retrieve a list of data objects, iterate them, generate Lucene documents, and store them using an IndexWriter. You could work against either a filesystem directory for persistent storage, or a in-memory storage.


Those are the possible solutions I came up with-- however, I cannot store my index on FSDirectory (project specs do not allow this) and for RAMDirectory, there are going to be thousands of Person objects we'll need to search through so I don't know if in-memory storage is ideal for this situation.

Is there any other sort of fuzzy match algorithm I can use that will be efficient for large sets of data?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜