Commit 154154ed authored by Jeremy Hylton's avatar Jeremy Hylton

Make OkapiIndex the default index.

ZCTextIndex has grown a new argument with a default value that can be
used to specify an Index class to use.  The default is OkapiIndex.Index.

There is a little kludge to make the test succeed.
testZCTestIndex.IndexTests uses the Index.Index tests instead of
OkapiIndex.Index.  Tim will probably fix this.
parent b3cb1b87
......@@ -27,7 +27,7 @@ from Products.PluginIndexes.common.PluggableIndex \
import PluggableIndexInterface
from Products.PluginIndexes.common.util import parseIndexRequest
from Products.ZCTextIndex.Index import Index
from Products.ZCTextIndex.OkapiIndex import Index
from Products.ZCTextIndex.ILexicon import ILexicon
from Products.ZCTextIndex.Lexicon \
import Lexicon, Splitter, CaseNormalizer, StopWordRemover
......@@ -47,7 +47,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
query_options = ['query']
def __init__(self, id, extra, caller):
def __init__(self, id, extra, caller, index_factory=Index):
self.id = id
self._fieldname = extra.doc_attr
lexicon = getattr(caller, extra.lexicon_id, None)
......@@ -61,7 +61,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
% lexicon.getId()
self.lexicon = lexicon
self.index = Index(self.lexicon)
self.index = index_factory(self.lexicon)
self.parser = QueryParser()
## Pluggable Index APIs ##
......
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
from Products.ZCTextIndex.tests \
import testIndex, testQueryEngine, testQueryParser
from Products.ZCTextIndex.Index import scaled_int, SCALE_FACTOR
from Products.ZCTextIndex.Index import scaled_int, SCALE_FACTOR, Index
from Products.ZCTextIndex.Lexicon import Lexicon, Splitter
from Products.ZCTextIndex.Lexicon import CaseNormalizer, StopWordRemover
......@@ -35,7 +35,7 @@ class IndexTests(testIndex.IndexTest):
extra.lexicon_id = 'lexicon'
caller = LexiconHolder(Lexicon(Splitter(), CaseNormalizer(),
StopWordRemover()))
self.zc_index = ZCTextIndex('name', extra, caller)
self.zc_index = ZCTextIndex('name', extra, caller, Index)
self.index = self.zc_index.index
self.lexicon = self.zc_index.lexicon
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment