我有一个记录列表,其中包含国家、城市、地区和建筑物名称信息(超过 50,000 条记录),其中每条记录的建筑物名称都是唯一的。
我想搜索建筑物、地区和城市。但是,如果我将国家/地区传递给方法,例如,我想获得城市列表。获取(字符串国家)。或者,如果我将国家和城市传递给该方法,则获取地区列表,例如get(字符串国家,字符串城市)。
是否有任何现有的集合/库/数据结构可以执行类似的操作?我正在考虑树状结构/ map 。我尝试了 MultiKeyMap,但它不返回值列表,而且它不是线程安全的。另外,我不想使用数据库来执行此操作。
预先感谢您的帮助。
最佳答案
SolR可能会完成您想要的工作:
Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly scalable, providing distributed search and index replication, and it powers the search and navigation features of many of the world's largest internet sites...
它应该允许您创建查询,从而允许您搜索记录。
您还可以通过 Solrj 与 SolR 交互:
Solrj is a java client to access solr. It offers a java interface to add, update, and query the solr index.
关于Java 多个关键字搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11663145/