當前位置: 首頁>>代碼示例>>Python>>正文


Python fieldregistry.FieldRegistry類代碼示例

本文整理匯總了Python中meresco.lucene.fieldregistry.FieldRegistry的典型用法代碼示例。如果您正苦於以下問題:Python FieldRegistry類的具體用法?Python FieldRegistry怎麽用?Python FieldRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FieldRegistry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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,代碼來源:


注:本文中的meresco.lucene.fieldregistry.FieldRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。