本文整理汇总了Python中meresco.lucene.fieldregistry.FieldRegistry.createField方法的典型用法代码示例。如果您正苦于以下问题:Python FieldRegistry.createField方法的具体用法?Python FieldRegistry.createField怎么用?Python FieldRegistry.createField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.lucene.fieldregistry.FieldRegistry
的用法示例。
在下文中一共展示了FieldRegistry.createField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTermVectorsForField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [as 别名]
def testTermVectorsForField(self):
registry = FieldRegistry(termVectorFields=['field1', 'field2'])
self.assertTrue(registry.isTermVectorField('field1'))
self.assertTrue(registry.isTermVectorField('field2'))
self.assertFalse(registry.isTermVectorField('field3'))
field = registry.createField('field1', 'id:1')
self.assertEquals({
"type": "TextField",
"name": "field1",
"value": "id:1",
"termVectors": True,
}, field)
field = registry.createField('field2', 'id:1')
self.assertEquals({
"type": "TextField",
"name": "field2",
"value": "id:1",
"termVectors": True,
}, field)
field = registry.createField('field3', 'id:1')
self.assertEquals({
"type": "TextField",
"name": "field3",
"value": "id:1",
}, field)
示例2: testSpecificField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [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)
示例3: testAddWithoutIdentifier
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [as 别名]
def testAddWithoutIdentifier(self):
registry = FieldRegistry()
fields = [registry.createField("id", "id1")]
consume(self._lucene.addDocument(fields=fields))
self.assertEqual(1, len(self.post))
self.assertEqual('/lucene/update/?', self.post[0]['path'])
self.assertEqual('[{"type": "TextField", "name": "id", "value": "id1"}]', self.post[0]['data'])
示例4: testNumericField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [as 别名]
def testNumericField(self):
registry = FieldRegistry()
registry.register('fieldname', NUMERICFIELD)
field = registry.createField('fieldname', 2010)
self.assertEquals({
"type": "NumericField",
"name": "fieldname",
"value": 2010,
}, field)
示例5: testNoTermsFreqField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [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)
示例6: testDefault
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [as 别名]
def testDefault(self):
registry = FieldRegistry()
field = registry.createField('__id__', 'id:1')
self.assertEquals({
"type": "StringField",
"name": "__id__",
"value": "id:1",
"stored": True
}, field)
示例7: testDefaultDefinition
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [as 别名]
def testDefaultDefinition(self):
registry = FieldRegistry()
field = registry.createField('aField', 'id:1')
self.assertEquals({
"type": "TextField",
"name": "aField",
"value": "id:1",
}, field)
self.assertFalse(registry.isUntokenized('aField'))
registry = FieldRegistry(defaultDefinition=STRINGFIELD)
field = registry.createField('aField', 'id:1')
self.assertEquals({
"type": "StringField",
"name": "aField",
"value": "id:1",
}, field)
self.assertTrue(registry.isUntokenized('aField'))
示例8: testSortField
# 需要导入模块: from meresco.lucene.fieldregistry import FieldRegistry [as 别名]
# 或者: from meresco.lucene.fieldregistry.FieldRegistry import createField [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)