Пример #1
0
 def testParseConfig(self):
     schema_xml = getData('schema.xml')
     schema = SolrSchema(schema_xml.split('\n\n', 1)[1])
     self.assertEqual(len(schema), 21) # 21 items defined in schema.xml
     self.assertEqual(schema['defaultSearchField'], 'text')
     self.assertEqual(schema['uniqueKey'], 'id')
     self.assertEqual(schema['solrQueryParser'].defaultOperator, 'OR')
     self.assertEqual(schema['requiredFields'], ['id', 'name'])
     self.assertEqual(schema['id'].type, 'string')
     self.assertEqual(schema['id'].class_, 'solr.StrField')
     self.assertEqual(schema['id'].required, True)
     self.assertEqual(schema['id'].omitNorms, True)
     self.assertEqual(schema['id'].multiValued, False)
     self.assertEqual(schema['cat'].class_, 'solr.TextField')
     self.assertEqual(schema['cat'].required, False)
     self.assertEqual(schema['cat'].multiValued, True)
     self.assertEqual(schema['cat'].termVectors, True)
     self.assertEqual(schema['sku'].positionIncrementGap, '100')
     self.assertEqual(schema.features.multiValued, True)
     self.assertEqual(schema.weight.class_, 'solr.SortableFloatField')
     self.assertEqual(schema.popularity.class_, 'solr.SortableIntField')
     self.assertEqual(schema.inStock.class_, 'solr.BoolField')
     self.assertEqual(schema.timestamp.class_, 'solr.DateField')
     self.assertEqual(schema.timestamp.default, 'NOW')
     self.assertEqual(schema.timestamp.multiValued, False)
     self.assertEqual(schema.timestamp.indexed, True)
     self.assertEqual(schema.word.indexed, False)
     fields = schema.values()
     self.assertEqual(len([f for f in fields if
         getattr(f, 'required', False)]), 2)
     self.assertEqual(len([f for f in fields if
         getattr(f, 'multiValued', False)]), 3)
Пример #2
0
 def testParseConfig(self):
     schema_xml = getData("schema.xml")
     schema = SolrSchema(schema_xml.split("\n\n", 1)[1])
     self.assertEqual(len(schema), 21)  # 21 items defined in schema.xml
     self.assertEqual(schema["defaultSearchField"], "text")
     self.assertEqual(schema["uniqueKey"], "id")
     self.assertEqual(schema["solrQueryParser"].defaultOperator, "OR")
     self.assertEqual(schema["requiredFields"], ["id", "name"])
     self.assertEqual(schema["id"].type, "string")
     self.assertEqual(schema["id"].class_, "solr.StrField")
     self.assertEqual(schema["id"].required, True)
     self.assertEqual(schema["id"].omitNorms, True)
     self.assertEqual(schema["id"].multiValued, False)
     self.assertEqual(schema["cat"].class_, "solr.TextField")
     self.assertEqual(schema["cat"].required, False)
     self.assertEqual(schema["cat"].multiValued, True)
     self.assertEqual(schema["cat"].termVectors, True)
     self.assertEqual(schema["sku"].positionIncrementGap, "100")
     self.assertEqual(schema.features.multiValued, True)
     self.assertEqual(schema.weight.class_, "solr.SortableFloatField")
     self.assertEqual(schema.popularity.class_, "solr.SortableIntField")
     self.assertEqual(schema.inStock.class_, "solr.BoolField")
     self.assertEqual(schema.timestamp.class_, "solr.DateField")
     self.assertEqual(schema.timestamp.default, "NOW")
     self.assertEqual(schema.timestamp.multiValued, False)
     self.assertEqual(schema.timestamp.indexed, True)
     self.assertEqual(schema.word.indexed, False)
     fields = schema.values()
     self.assertEqual(len([f for f in fields if getattr(f, "required", False)]), 2)
     self.assertEqual(len([f for f in fields if getattr(f, "multiValued", False)]), 3)
Пример #3
0
 def testParseConfig(self):
     schema_xml = getData("schema.xml").decode("utf-8")
     schema = SolrSchema(schema_xml.split("\n\n", 1)[1])
     self.assertEqual(len(schema), 21)  # 21 items defined in schema.xml
     self.assertEqual(schema["defaultSearchField"], "text")
     self.assertEqual(schema["uniqueKey"], "id")
     self.assertEqual(schema["solrQueryParser"].defaultOperator, "OR")
     self.assertEqual(schema["requiredFields"], ["id", "name"])
     self.assertEqual(schema["id"].type, "string")
     self.assertEqual(schema["id"].class_, "solr.StrField")
     self.assertEqual(schema["id"].required, True)
     self.assertEqual(schema["id"].omitNorms, True)
     self.assertEqual(schema["id"].multiValued, False)
     self.assertEqual(schema["cat"].class_, "solr.TextField")
     self.assertEqual(schema["cat"].required, False)
     self.assertEqual(schema["cat"].multiValued, True)
     self.assertEqual(schema["cat"].termVectors, True)
     self.assertEqual(schema["sku"].positionIncrementGap, "100")
     self.assertEqual(schema.features.multiValued, True)
     self.assertEqual(schema.weight.class_, "solr.SortableFloatField")
     self.assertEqual(schema.popularity.class_, "solr.SortableIntField")
     self.assertEqual(schema.inStock.class_, "solr.BoolField")
     self.assertEqual(schema.timestamp.class_, "solr.DateField")
     self.assertEqual(schema.timestamp.default, "NOW")
     self.assertEqual(schema.timestamp.multiValued, False)
     self.assertEqual(schema.timestamp.indexed, True)
     self.assertEqual(schema.word.indexed, False)
     fields = list(schema.values())
     self.assertEqual(len([f for f in fields if getattr(f, "required", False)]), 2)
     self.assertEqual(
         len([f for f in fields if getattr(f, "multiValued", False)]), 3
     )