Skip to content

Commit

Permalink
Add support for solr-5.5 in schema.xml and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aherlihy committed Apr 4, 2016
1 parent b6b4d76 commit cae9ee9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion mongo_connector/doc_managers/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@

<!-- required for gridfs support -->
<field name="content" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="_text_" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="filename" type="string" indexed="true" stored="true"/>
<field name="upload_date" type="date" indexed="true" stored="true"/>
<field name="md5" type="string" indexed="false" stored="true"/>
Expand Down Expand Up @@ -181,6 +182,11 @@
<dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
<dynamicField name="*_tdt" type="tdate" indexed="true" stored="true"/>

<fieldType name="tints" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tfloats" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tlongs" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tdoubles" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>

<dynamicField name="*_c" type="currency" indexed="true" stored="true"/>

<dynamicField name="ignored_*" type="ignored" multiValued="true"/>
Expand Down Expand Up @@ -221,9 +227,11 @@
single-valued and either required or have a default value.
-->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="strings" class="solr.StrField" sortMissingLast="true" multiValued="true"/>

<!-- boolean type: "true" or "false" -->
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="booleans" class="solr.BoolField" sortMissingLast="true" multiValued="true"/>

<!-- sortMissingLast and sortMissingFirst attributes are optional attributes are
currently supported on types that are sorted internally as strings
Expand Down Expand Up @@ -293,7 +301,7 @@

<!-- A Trie based date field for faster date range queries and date faceting. -->
<fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>

<fieldType name="tdates" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0" multiValued="true"/>

<!--Binary data type. The data should be sent/retrieved in as Base64 encoded Strings -->
<fieldType name="binary" class="solr.BinaryField"/>
Expand Down
7 changes: 6 additions & 1 deletion tests/test_solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ def test_insert_file(self):
test_data = "test_insert_file test file"
id = fs.put(test_data, filename="test.txt", encoding='utf8')
assert_soon(lambda: sum(1 for _ in self.solr_conn.search('*:*')) > 0)

res = list(self.solr_conn.search('content:*test_insert_file*'))
if not res:
res = list(self.solr_conn.search('_text_:*test_insert_file*'))
self.assertEqual(len(res), 1)
doc = res[0]
self.assertEqual(doc['filename'], "test.txt")
self.assertEqual(doc['_id'], str(id))
self.assertIn(test_data.strip(), doc['content'][0].strip())
content = doc.get('content', doc.get('_text_', None))
self.assertTrue(content)
self.assertIn(test_data.strip(), content[0].strip())

def test_remove_file(self):
"""Tests removing a gridfs file
Expand Down
4 changes: 3 additions & 1 deletion tests/test_solr_doc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ def test_insert_file(self):
for doc in res:
self.assertEqual(doc['_id'], docc['_id'])
self.assertEqual(doc['filename'], docc['filename'])
content = doc.get('content', doc.get('_text_', None))
self.assertTrue(content)
self.assertIn(test_data.strip(),
doc['content'][0].strip().encode('utf8'))
content[0].strip().encode('utf8'))

def test_remove_file(self):
test_data = b'hello world'
Expand Down

0 comments on commit cae9ee9

Please sign in to comment.