当前位置: 首页>>代码示例>>Python>>正文


Python FieldRegistry.createField方法代码示例

本文整理汇总了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)
开发者ID:,项目名称:,代码行数:27,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:18,代码来源:

示例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'])
开发者ID:,项目名称:,代码行数:9,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例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'))
开发者ID:,项目名称:,代码行数:20,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:21,代码来源:


注:本文中的meresco.lucene.fieldregistry.FieldRegistry.createField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。