JDBC存储中的共享指南针/ Lucene索引

时间:2012-05-30 08:55:32

标签: grails jdbc lucene searchable compass-lucene

使用Grails中的可搜索插件(在引擎盖下使用Compass / Lucene),我们尝试在两个不同的Web应用程序之间共享搜索索引。一个应用程序仅以只读方式访问数据。另一个应用程序允许修改数据,并负责在任何更改时更新索引或根据需要执行完整的重新索引。

要存储我们正在使用JDBC存储的索引(两个应用程序都指向同一个数据库)http://www.compass-project.org/docs/latest/reference/html/core-connection.html

不幸的是,只要我们在一个应用程序中重建整个索引,另一个应用程序似乎缓存了无效数据,并且如果执行搜索则抛出异常:

| Error 2012-05-30 09:22:07,560 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver  - IndexOutOfBoundsException occurred when processing request: [POST] /search
Index: 45, Size: 13. Stacktrace follows:
Message: Index: 45, Size: 13
   Line | Method
->> 547 | RangeCheck  in java.util.ArrayList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   322 | get         in     ''
|   265 | fieldInfo . in org.apache.lucene.index.FieldInfos
|   254 | fieldName   in     ''
|    86 | read . . .  in org.apache.lucene.index.TermBuffer
|   127 | next        in org.apache.lucene.index.SegmentTermEnum
|   158 | scanTo . .  in     ''
|   271 | get         in org.apache.lucene.index.TermInfosReader
|   332 | terms . . . in     ''
|   717 | terms       in org.apache.lucene.index.SegmentReader
|    93 | generate .  in org.apache.lucene.search.PrefixGenerator
|    58 | getDocIdSet in org.apache.lucene.search.PrefixFilter
|   116 | <init> . .  in org.apache.lucene.search.ConstantScoreQuery$ConstantScorer
|    81 | scorer      in org.apache.lucene.search.ConstantScoreQuery$ConstantWeight
|   230 | scorer . .  in org.apache.lucene.search.BooleanQuery$BooleanWeight
|   131 | search      in org.apache.lucene.search.IndexSearcher
|   112 | search . .  in     ''
|   204 | search      in org.apache.lucene.search.MultiSearcher
|   113 | getMoreDocs in org.apache.lucene.search.Hits
|    90 | <init>      in     ''
|    61 | search . .  in org.apache.lucene.search.Searcher
|   146 | findByQuery in org.compass.core.lucene.engine.transaction.support.AbstractTransactionProcessor
|   259 | doFind . .  in org.compass.core.lucene.engine.transaction.readcommitted.ReadCommittedTransactionProcessor
|   246 | find        in org.compass.core.lucene.engine.transaction.support.AbstractConcurrentTransactionProcessor
|   352 | find . . .  in org.compass.core.lucene.engine.LuceneSearchEngine
|   188 | hits        in org.compass.core.lucene.engine.LuceneSearchEngineQuery
|   199 | hits . . .  in org.compass.core.impl.DefaultCompassQuery
|   104 | doInCompass in grails.plugin.searchable.internal.compass.search.DefaultSearchMethod$SearchCompassCallback
|   133 | execute . . in org.compass.core.CompassTemplate
|    57 | doInCompass in grails.plugin.searchable.internal.compass.support.AbstractSearchableMethod
|    66 | invoke . .  in grails.plugin.searchable.internal.compass.search.DefaultSearchMethod
|    37 | search      in grails.plugin.searchable.SearchableService

我们可以传达索引从一个应用程序重建到另一个应用程序的事实,以便可以执行一些清理。

  • Grails和Searchable插件是否有类似的问题?
  • 是否可以丢弃Compass / Lucene缓存的数据?
  • 一般可以禁用缓存吗?

1 个答案:

答案 0 :(得分:1)

在搜索之前清除所有缓存似乎解决了这个问题......

searchableService.compass.compass.searchEngineFactory.indexManager.clearCache()