本文整理汇总了Python中meresco.lucene.fieldregistry.FieldRegistry类的典型用法代码示例。如果您正苦于以下问题:Python FieldRegistry类的具体用法?Python FieldRegistry怎么用?Python FieldRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FieldRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testAddWithoutIdentifier
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:,项目名称:,代码行数:7,代码来源:
示例2: testExcludeUnqualifiedFieldForWhichNoPhraseQueryIsPossibleInCaseOfPhraseQuery
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"')
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:7,代码来源:lucenequerycomposertest.py
示例3: testGenericDrilldownFields
def testGenericDrilldownFields(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
registry = FieldRegistry(isDrilldownFieldFunction=lambda name: name.startswith('drilldown'))
self.assertTrue(registry.isDrilldownField('drilldown.aap'))
self.assertTrue(registry.isDrilldownField('drilldown.noot'))
self.assertFalse(registry.isDrilldownField('noot'))
开发者ID:,项目名称:,代码行数:7,代码来源:
示例4: testIsNumeric
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'))
开发者ID:,项目名称:,代码行数:9,代码来源:
示例5: testDefault
def testDefault(self):
registry = FieldRegistry()
field = registry.createField('__id__', 'id:1')
self.assertEquals({
"type": "StringField",
"name": "__id__",
"value": "id:1",
"stored": True
}, field)
开发者ID:,项目名称:,代码行数:9,代码来源:
示例6: testNoTermsFreqField
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:,项目名称:,代码行数:9,代码来源:
示例7: testNumericField
def testNumericField(self):
registry = FieldRegistry()
registry.register('fieldname', NUMERICFIELD)
field = registry.createField('fieldname', 2010)
self.assertEquals({
"type": "NumericField",
"name": "fieldname",
"value": 2010,
}, field)
开发者ID:,项目名称:,代码行数:9,代码来源:
示例8: testIsUntokenized
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'))
开发者ID:,项目名称:,代码行数:9,代码来源:
示例9: testPostDictWithDrilldownFields
def testPostDictWithDrilldownFields(self):
fieldRegistry = FieldRegistry()
fieldRegistry.registerDrilldownField("field0", hierarchical=True, multiValued=False)
fieldRegistry.registerDrilldownField("field1", hierarchical=True, multiValued=True, indexFieldName="$facets_2")
settings = LuceneSettings(fieldRegistry=fieldRegistry)
soll = copy(DEFAULTS)
soll['drilldownFields'] = [
{'dim': 'field0', 'hierarchical': True, 'fieldname': None, 'multiValued': False},
{'dim': 'field1', 'hierarchical': True, 'fieldname': '$facets_2', 'multiValued': True}]
self.assertEquals(soll, settings.asPostDict())
开发者ID:seecr,项目名称:meresco-lucene,代码行数:10,代码来源:lucenesettingstest.py
示例10: testSpecificField
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:,项目名称:,代码行数:16,代码来源:
示例11: testDrilldownFieldQuery
def testDrilldownFieldQuery(self):
self.fieldRegistry = FieldRegistry([DrilldownField('field', hierarchical=True)])
self.assertEquals(
dict(type="TermQuery", term=dict(field="field", path=["value"], type="DrillDown")),
self._convert("field = value"))
self.assertEquals(
dict(type="TermQuery", term=dict(field="field", path=["value", "value1"], type="DrillDown")),
self._convert("field = \"value>value1\""))
开发者ID:seecr,项目名称:meresco-lucene,代码行数:8,代码来源:queryexpressiontolucenequerydicttest.py
示例12: testPostDictWithDrilldownFields
def testPostDictWithDrilldownFields(self):
fieldRegistry = FieldRegistry()
fieldRegistry.registerDrilldownField("field0", hierarchical=True, multiValued=False)
fieldRegistry.registerDrilldownField("field1", hierarchical=True, multiValued=True, indexFieldName="$facets_2")
settings = LuceneSettings(fieldRegistry=fieldRegistry)
self.assertEqual({
'lruTaxonomyWriterCacheSize': 4000,
'maxMergeAtOnce': 2,
'similarity': {'type': 'BM25Similarity'},
'numberOfConcurrentTasks': 6,
'segmentsPerTier': 8.0,
'analyzer': {'type': 'MerescoStandardAnalyzer'},
'drilldownFields': [
{'dim': 'field0', 'hierarchical': True, 'fieldname': None, 'multiValued': False},
{'dim': 'field1', 'hierarchical': True, 'fieldname': '$facets_2', 'multiValued': True}],
'commitCount': 100000,
'commitTimeout': 10
}, settings.asPostDict())
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:18,代码来源:lucenesettingstest.py
示例13: testExcludeUnqualifiedFieldForWhichNoPhraseQueryIsPossibleInCaseOfPhraseQuery
def testExcludeUnqualifiedFieldForWhichNoPhraseQueryIsPossibleInCaseOfPhraseQuery(self):
self.fieldRegistry = FieldRegistry()
self.fieldRegistry.register('noTermFreqField', NO_TERMS_FREQUENCY_FIELD)
self.unqualifiedFields = [("unqualified", 1.0), ('noTermFreqField', 2.0)]
expected = dict(type="PhraseQuery", terms=[
dict(field="unqualified", value="phrase"),
dict(field="unqualified", value="query")
], boost=1.0)
self.assertEquals(expected, self._convert('"phrase query"'))
开发者ID:seecr,项目名称:meresco-lucene,代码行数:9,代码来源:queryexpressiontolucenequerydicttest.py
示例14: testRangeQueryAndType
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)
开发者ID:,项目名称:,代码行数:17,代码来源:
示例15: testTermVectorsForField
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:,项目名称:,代码行数:25,代码来源:
示例16: testDefaultDefinition
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:,项目名称:,代码行数:18,代码来源:
示例17: testWildcardQuery
def testWildcardQuery(self):
self.fieldRegistry = FieldRegistry()
expected = dict(type="WildcardQuery", term=dict(field="field", value="???*"))
self.assertConversion(expected, cql='field=???*')
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:4,代码来源:queryexpressiontolucenequerydicttest.py
示例18: testSortField
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:,项目名称:,代码行数:19,代码来源:
示例19: testMagicExact
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"'))
开发者ID:seecr,项目名称:meresco-lucene,代码行数:5,代码来源:queryexpressiontolucenequerydicttest.py
示例20: testDrilldownFields
def testDrilldownFields(self):
drilldownFields = [DrilldownField(name='aap'), DrilldownField(name='noot', hierarchical=True)]
registry = FieldRegistry(drilldownFields=drilldownFields)
registry.registerDrilldownField(fieldname='mies', multiValued=False)
self.assertTrue(registry.isDrilldownField('aap'))
self.assertTrue(registry.isDrilldownField('noot'))
self.assertTrue(registry.isDrilldownField('mies'))
self.assertFalse(registry.isDrilldownField('vuur'))
self.assertFalse(registry.isHierarchicalDrilldown('aap'))
self.assertTrue(registry.isHierarchicalDrilldown('noot'))
self.assertTrue(registry.isMultivaluedDrilldown('aap'))
self.assertTrue(registry.isMultivaluedDrilldown('noot'))
self.assertFalse(registry.isMultivaluedDrilldown('mies'))
self.assertTrue(registry.isUntokenized('mies'))
field = registry.createFacetField("name", ["value"])
self.assertEqual({
"type": "FacetField",
"name": "name",
"path": ["value"]
}, field)
开发者ID:,项目名称:,代码行数:21,代码来源:
注:本文中的meresco.lucene.fieldregistry.FieldRegistry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论