本文整理汇总了Python中meresco.lucene.fieldregistry.FieldRegistry.register方法的典型用法代码示例。如果您正苦于以下问题:Python FieldRegistry.register方法的具体用法?Python FieldRegistry.register怎么用?Python FieldRegistry.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.lucene.fieldregistry.FieldRegistry
的用法示例。
在下文中一共展示了FieldRegistry.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testExcludeUnqualifiedFieldForWhichNoPhraseQueryIsPossibleInCaseOfPhraseQuery
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testExcludeUnqualifiedFieldForWhichNoPhraseQueryIsPossibleInCaseOfPhraseQuery(self):
fieldRegistry = FieldRegistry()
fieldRegistry.register('noTermFreqField', NO_TERMS_FREQUENCY_FIELDTYPE)
self.composer = LuceneQueryComposer(unqualifiedTermFields=[("unqualified", 1.0), ('noTermFreqField', 2.0)], luceneSettings=LuceneSettings(fieldRegistry=fieldRegistry))
expected = PhraseQuery()
expected.add(Term("unqualified", "phrase query"))
self.assertConversion(expected, '"phrase query"')
示例2: testIsUntokenized
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testIsUntokenized(self):
registry = FieldRegistry(drilldownFields=[DrilldownField('aDrilldownField')])
self.assertTrue(registry.isUntokenized('aDrilldownField'))
self.assertTrue(registry.isUntokenized('untokenized.some.field'))
self.assertFalse(registry.isUntokenized('other.field'))
registry.register('fieldname', STRINGFIELD)
self.assertTrue(registry.isUntokenized('fieldname'))
registry.register('fieldname', TEXTFIELD)
self.assertFalse(registry.isUntokenized('fieldname'))
示例3: testNumericField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testNumericField(self):
registry = FieldRegistry()
registry.register('fieldname', NUMERICFIELD)
field = registry.createField('fieldname', 2010)
self.assertEquals({
"type": "NumericField",
"name": "fieldname",
"value": 2010,
}, field)
示例4: testNoTermsFreqField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testNoTermsFreqField(self):
registry = FieldRegistry()
registry.register('fieldname', NO_TERMS_FREQUENCY_FIELD)
field = registry.createField('fieldname', 'value')
self.assertEquals({
"type": "NoTermsFrequencyField",
"name": "fieldname",
"value": "value",
}, field)
示例5: testIsNumeric
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testIsNumeric(self):
registry = FieldRegistry()
registry.register("longfield", fieldDefinition=LONGFIELD)
registry.register("intfield", fieldDefinition=INTFIELD)
self.assertFalse(registry.isNumeric('field1'))
self.assertTrue(registry.isNumeric('longfield'))
self.assertTrue(registry.isNumeric('intfield'))
self.assertTrue(registry.isNumeric('range.double.afield'))
self.assertTrue(registry.isNumeric('__key__.field1'))
示例6: testSpecificField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testSpecificField(self):
registry = FieldRegistry()
field = registry.createField('fieldname', 'value')
self.assertEquals({
"type": "TextField",
"name": "fieldname",
"value": "value",
}, field)
registry.register('fieldname', STRINGFIELD_STORED)
field = registry.createField('fieldname', 'value')
self.assertEquals({
"type": "StringField",
"name": "fieldname",
"value": "value",
"stored": True
}, field)
示例7: testRangeQueryAndType
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testRangeQueryAndType(self):
registry = FieldRegistry()
registry.register("longfield", fieldDefinition=LONGFIELD)
registry.register("intfield", fieldDefinition=INTFIELD)
q, t = registry.rangeQueryAndType('longfield')
self.assertEqual("Long", q)
self.assertEqual(long, t)
q, t = registry.rangeQueryAndType('intfield')
self.assertEqual("Int", q)
self.assertEqual(int, t)
q, t = registry.rangeQueryAndType('range.double.field')
self.assertEqual("Double", q)
self.assertEqual(float, t)
q, t = registry.rangeQueryAndType('anyfield')
self.assertEqual("String", q)
self.assertEqual(str, t)
示例8: testSortField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testSortField(self):
registry = FieldRegistry()
registry.register("sorted.longfield", fieldDefinition=LONGFIELD)
registry.register("sorted.intfield", fieldDefinition=INTFIELD)
registry.register("sorted.stringfield", fieldDefinition=STRINGFIELD)
self.assertEqual("Long", registry.sortFieldType("sorted.longfield"))
self.assertEqual(None, registry.defaultMissingValueForSort("sorted.longfield", True))
self.assertEqual("Int", registry.sortFieldType("sorted.intfield"))
self.assertEqual(None, registry.defaultMissingValueForSort("sorted.intfield", True))
self.assertEqual("String", registry.sortFieldType("sorted.stringfield"))
self.assertEqual("STRING_FIRST", registry.defaultMissingValueForSort("sorted.stringfield", True))
self.assertEqual("STRING_LAST", registry.defaultMissingValueForSort("sorted.stringfield", False))
self.assertEqual(None, registry.defaultMissingValueForSort("score", False))
field = registry.createField('sorted.longfield', 'id:1')
self.assertEqual({'name': 'sorted.longfield', 'type': 'LongField', 'value': 'id:1', 'sort': True}, field)
示例9: testPhraseQueryPossible
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testPhraseQueryPossible(self):
registry = FieldRegistry()
registry.register('fieldname', NO_TERMS_FREQUENCY_FIELD)
self.assertFalse(registry.phraseQueryPossible('fieldname'))
self.assertTrue(registry.phraseQueryPossible('other.fieldname'))
示例10: QueryExpressionToLuceneQueryDictTest
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
#.........这里部分代码省略.........
self.assertEquals(query, self._convert("title =/boost=2.0 cats"))
def testWildcards(self):
query = prefixQuery('unqualified', 'prefix', 1.0)
self.assertEquals(query, self._convert('prefix*'))
self.assertEquals(query, self._convert('PREfix*'))
query = prefixQuery('field', 'prefix')
self.assertEquals(query, self._convert('field="PREfix*"'))
self.assertEquals(query, self._convert('field=prefix*'))
query = prefixQuery('field', 'oc-0123')
self.assertEquals(query, self._convert('field="oc-0123*"'))
query = termQuery('field', 'p')
self.assertEquals(query, self._convert('field="P*"'))
#only prefix queries for now
query = termQuery('field', 'post')
self.assertEquals(query, self._convert('field="*post"'))
query = termQuery('field', 'prefix')
self.assertEquals(query, self._convert('field=prefix**'))
self.unqualifiedFields = [("field0", 0.2), ("field1", 2.0)]
query = dict(type="BooleanQuery", clauses=[])
query["clauses"].append(prefixQuery("field0", "prefix", 0.2))
query["clauses"][0]["occur"] = "SHOULD"
query["clauses"].append(prefixQuery("field1", "prefix", 2.0))
query["clauses"][1]["occur"] = "SHOULD"
self.assertEquals(query, self._convert("prefix*"))
def testMagicExact(self):
exactResult = self._convert('animal exact "cats dogs"')
self.fieldRegistry = FieldRegistry()
self.fieldRegistry.register('animal', STRINGFIELD)
self.assertEquals(exactResult, self._convert('animal = "cats dogs"'))
def testTextRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm='value', upperTerm=None, includeLower=False, includeUpper=True)
self.assertEquals(q, self._convert('field > value'))
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm='value', upperTerm=None, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('field >= value'))
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm=None, upperTerm='value', includeLower=True, includeUpper=False)
self.assertEquals(q, self._convert('field < value'))
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm=None, upperTerm='value', includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('field <= value'))
def testIntRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=False, includeUpper=True)
self.assertEquals(q, self._convert('intField > 1'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField >= 1'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=True, includeUpper=False)
self.assertEquals(q, self._convert('intField < 3'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField <= 3'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=3, upperTerm=3, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField = 3'))
self.assertEquals(q, self._convert(QueryExpression.searchterm(index='intField', relation='exact', term=3)))
self.assertEquals(q, self._convert(QueryExpression.searchterm(index='intField', relation='=', term=3)))
def testLongRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="Long", field='longField', lowerTerm=1, upperTerm=None, includeLower=False, includeUpper=True)
self.assertEquals(q, self._convert('longField > 1'))
示例11: testMagicExact
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def testMagicExact(self):
exactResult = self.composer.compose(parseCql('animal exact "cats dogs"'))
fieldRegistry = FieldRegistry()
fieldRegistry.register('animal', StringField.TYPE_NOT_STORED)
self.composer = LuceneQueryComposer(unqualifiedTermFields=[("unqualified", 1.0)], luceneSettings=LuceneSettings(fieldRegistry=fieldRegistry))
self.assertConversion(exactResult, 'animal = "cats dogs"')
示例12: main
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def main(reactor, port, serverPort, autocompletePort, databasePath, **kwargs):
drilldownFields = [
DrilldownField('untokenized.field2'),
DrilldownField('untokenized.field2.copy', indexFieldName='copy'),
DrilldownField('untokenized.fieldHier', hierarchical=True)
]
fieldRegistry = FieldRegistry(drilldownFields)
fieldRegistry.register('intfield1', INTFIELD)
fieldRegistry.register('intfield2', INTFIELD)
fieldRegistry.register('intfield3', INTFIELD)
fieldRegistry.register('intfield_missing', INTFIELD)
fieldRegistry.register('sorted.intfield_missing', INTFIELD)
luceneSettings = LuceneSettings(
fieldRegistry=fieldRegistry,
commitCount=30,
commitTimeout=0.3,
#analyzer=MerescoDutchStemmingAnalyzer(["field4", "field5"]),
analyzer=dict(type="MerescoDutchStemmingAnalyzer", stemmingFields=['field4', 'field5'])
)
http11_request = be((HttpRequest1_1(),
(SocketPool(reactor=reactor, unusedTimeout=5, limits=dict(totalSize=100, destinationSize=10)),)
))
lucene = be((Lucene(host="localhost", port=serverPort, name='main', settings=luceneSettings),
(http11_request,)
))
lucene2Settings = LuceneSettings(fieldRegistry=fieldRegistry, commitTimeout=0.1)
lucene2 = be((Lucene(host="localhost", port=serverPort, name='main2', settings=lucene2Settings),
(http11_request,)
))
emptyLuceneSettings = LuceneSettings(commitTimeout=1)
multiLuceneHelix = (MultiLucene(host='localhost', port=serverPort, defaultCore='main'),
(Lucene(host='localhost', port=serverPort, name='empty-core', settings=emptyLuceneSettings),
(http11_request,)
),
(lucene,),
(lucene2,),
(http11_request,)
)
storageComponent = be(
(RetrieveDataToGetData(),
(StorageComponentAdapter(),
(MultiSequentialStorage(directory=join(databasePath, 'storage')),)
)
)
)
return \
(Observable(),
(ObservableHttpServer(reactor=reactor, port=port),
(BasicHttpHandler(),
(ApacheLogger(outputStream=stdout),
(PathFilter("/info", excluding=[
'/info/version',
'/info/name',
'/update',
'/sru',
'/remote',
'/via-remote-sru',
]),
(DynamicHtml(
[dynamicPath],
reactor=reactor,
indexPage='/info',
additionalGlobals={
'VERSION': version,
}
),
)
),
(PathFilter("/info/version"),
(StringServer(version, ContentTypePlainText), )
),
(PathFilter("/info/name"),
(StringServer('Meresco Lucene', ContentTypePlainText),)
),
(PathFilter("/static"),
(PathRename(lambda path: path[len('/static'):]),
(FileServer(staticPath),)
)
),
(PathFilter("/update_main", excluding=['/update_main2']),
uploadHelix(lucene, storageComponent, drilldownFields, fieldRegistry=luceneSettings.fieldRegistry),
),
(PathFilter("/update_main2"),
uploadHelix(lucene2, storageComponent, drilldownFields, fieldRegistry=lucene2Settings.fieldRegistry),
),
(PathFilter('/sru'),
(SruParser(defaultRecordSchema='record'),
(SruHandler(),
(AdapterToLuceneQuery(
defaultCore='main',
coreConverters={
"main": QueryExpressionToLuceneQueryDict([], luceneSettings=luceneSettings),
"main2": QueryExpressionToLuceneQueryDict([], luceneSettings=lucene2Settings),
"empty-core": QueryExpressionToLuceneQueryDict([], luceneSettings=emptyLuceneSettings),
}),
#.........这里部分代码省略.........
示例13: QueryExpressionToLuceneQueryDictTest
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
#.........这里部分代码省略.........
self.assertConversion(query, cql="title =/boost=2.0 cats")
def testWildcards(self):
query = prefixQuery('unqualified', 'prefix', 1.0)
self.assertConversion(query, cql='prefix*')
self.assertConversion(query, cql='PREfix*')
query = prefixQuery('field', 'prefix')
self.assertConversion(query, cql='field="PREfix*"')
self.assertConversion(query, cql='field=prefix*')
query = prefixQuery('field', 'oc-0123')
self.assertConversion(query, cql='field="oc-0123*"')
query = termQuery('field', 'p')
self.assertConversion(query, cql='field="P*"')
#only prefix queries for now
query = termQuery('field', 'post')
self.assertConversion(query, cql='field="*post"')
query = termQuery('field', 'prefix')
self.assertConversion(query, cql='field=prefix**')
self.unqualifiedFields = [("field0", 0.2), ("field1", 2.0)]
query = dict(type="BooleanQuery", clauses=[])
query["clauses"].append(prefixQuery("field0", "prefix", 0.2))
query["clauses"][0]["occur"] = "SHOULD"
query["clauses"].append(prefixQuery("field1", "prefix", 2.0))
query["clauses"][1]["occur"] = "SHOULD"
self.assertConversion(query, cql="prefix*")
def testMagicExact(self):
exactResult = self.convert(cql='animal exact "cats dogs"')
self.fieldRegistry = FieldRegistry()
self.fieldRegistry.register('animal', STRINGFIELD)
self.assertConversion(exactResult, cql='animal = "cats dogs"')
def testTextRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm='value', upperTerm=None, includeLower=False, includeUpper=False)
self.assertConversion(q, cql='field > value')
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm='value', upperTerm=None, includeLower=True, includeUpper=False)
self.assertConversion(q, cql='field >= value')
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm=None, upperTerm='value', includeLower=False, includeUpper=False)
self.assertConversion(q, cql='field < value')
q = dict(type="RangeQuery", rangeType="String", field='field', lowerTerm=None, upperTerm='value', includeLower=False, includeUpper=True)
self.assertConversion(q, cql='field <= value')
def testIntRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=False, includeUpper=False)
self.assertConversion(q, cql='intField > 1')
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=True, includeUpper=False)
self.assertConversion(q, cql='intField >= 1')
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=False, includeUpper=False)
self.assertConversion(q, cql='intField < 3')
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=False, includeUpper=True)
self.assertConversion(q, cql='intField <= 3')
def testLongRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="Long", field='longField', lowerTerm=1, upperTerm=None, includeLower=False, includeUpper=False)
self.assertConversion(q, cql='longField > 1')
q = dict(type="RangeQuery", rangeType="Long", field='longField', lowerTerm=1, upperTerm=None, includeLower=True, includeUpper=False)
self.assertConversion(q, cql='longField >= 1')
q = dict(type="RangeQuery", rangeType="Long", field='longField', lowerTerm=None, upperTerm=3, includeLower=False, includeUpper=False)
self.assertConversion(q, cql='longField < 3')
示例14: setUp
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
def setUp(self):
super(LuceneQueryComposerTest, self).setUp()
fieldRegistry = FieldRegistry()
fieldRegistry.register("intField", fieldDefinition=INTFIELD)
fieldRegistry.register("longField", fieldDefinition=LONGFIELD)
self.composer = LuceneQueryComposer(unqualifiedTermFields=[("unqualified", 1.0)], luceneSettings=LuceneSettings(fieldRegistry=fieldRegistry))
示例15: dirname
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import register [as 别名]
from digitalecollectie.erfgeo import VERSION_STRING
from digitalecollectie.erfgeo.namespaces import namespaces
from digitalecollectie.erfgeo.maybecombinewithsummary import COMBINED_METADATA_PREFIX
from digitalecollectie.erfgeo.index.constants import ALL_FIELD
from digitalecollectie.erfgeo.index.lxmltofieldslist import LxmlToFieldsList
from digitalecollectie.erfgeo.index.fieldslisttolucenedocument import FieldsListToLuceneDocument
from digitalecollectie.erfgeo.index.indexfields import IndexFields
workingPath = dirname(abspath(__file__))
unqualifiedTermFields = [(ALL_FIELD, 1.0)]
fieldRegistry = FieldRegistry(drilldownFields=IndexFields.drilldownFields)
fieldRegistry.register('dcterms:spatial.geo:long', fieldDefinition=DOUBLEFIELD)
fieldRegistry.register('dcterms:spatial.geo:lat', fieldDefinition=DOUBLEFIELD)
parseHugeOptions = dict(huge_tree=True, remove_blank_text=True)
def createErfGeoEnrichmentPeriodicDownloadHelix(reactor, lucene, config, statePath):
erfgeoEnrichPortNumber = int(config['erfgeoEnrich.portNumber'])
downloadName = 'erfgeoEnrich-%s' % COMBINED_METADATA_PREFIX
erfGeoEnrichPeriodicDownload = PeriodicDownload(
reactor,
host='127.0.0.1',
port=erfgeoEnrichPortNumber,
name=downloadName,
autoStart=True)