-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
853efe2
commit 7f48bda
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dog,hound,pooch,canis familiaris,man's best friend | ||
back pack=>backpack | ||
e-commerce,electronic commerce,e commerce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Basic unit tests for HON-Lucene-Synonyms | ||
# | ||
# This one tests some of the problems found in issues #28 and #32 | ||
# | ||
|
||
import unittest, solr, urllib | ||
|
||
class TestBasic(unittest.TestCase): | ||
|
||
url = 'http://localhost:8983/solr' | ||
test_data = [ \ | ||
{'id': '1', 'name': "e-commerce"}, \ | ||
{'id': '2', 'name': "electronic commerce"}, \ | ||
] | ||
solr_connection = None | ||
|
||
def setUp(self): | ||
self.solr_connection = solr.SolrConnection(self.url) | ||
self.solr_connection.delete_query('*:*') | ||
self.solr_connection.add_many(self.test_data) | ||
self.solr_connection.commit() | ||
|
||
def tearDown(self): | ||
self.solr_connection.delete_query('*:*') | ||
self.solr_connection.commit() | ||
|
||
def test_queries(self): | ||
|
||
self.tst_query({}, 'commerce', 2) | ||
self.tst_query({}, 'electronic commerce', 2) | ||
self.tst_query({}, 'e-commerce', 2) | ||
|
||
# means "shouldn't contain the word commerce" | ||
self.tst_query({}, 'e -commerce', 0) | ||
|
||
def tst_query(self, extra_params, query, expected_num_docs): | ||
|
||
params = {'q': query, 'qf' : 'name', 'mm' : '100%', 'defType' : 'synonym_edismax', 'synonyms' : 'true'} | ||
params.update(extra_params) | ||
|
||
response = self.solr_connection.query(**params) | ||
results = response.results | ||
print '\ntesting ',self.url + '/select?' + urllib.urlencode(params),\ | ||
'\n',map(lambda x: x['name'],results),'\nActual: %s, Expected: %s' % (len(results), expected_num_docs) | ||
|
||
self.assertEqual(len(results), expected_num_docs) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |