Skip to content

Commit

Permalink
Update ES to version 2.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
ackermann committed Apr 24, 2016
1 parent 90aaad3 commit a606436
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
23 changes: 12 additions & 11 deletions annotator/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
'created': {'type': 'date'},
'updated': {'type': 'date'},
'quote': {'type': 'string', 'analyzer': 'standard'},
'tags': {'type': 'string', 'index_name': 'tag'},
'tag': {'type': 'string'},
'tags': {'type': 'string', 'copy_to': 'tag'},
'text': {'type': 'string', 'analyzer': 'standard'},
'uri': {'type': 'string'},
'user': {'type': 'string'},
'consumer': {'type': 'string'},
'range': {'type': 'string'},
'ranges': {
'index_name': 'range',
'properties': {
'start': {'type': 'string'},
'end': {'type': 'string'},
'startOffset': {'type': 'integer'},
'endOffset': {'type': 'integer'},
'start': {'type': 'string', 'copy_to': 'range'},
'end': {'type': 'string', 'copy_to': 'range'},
'startOffset': {'type': 'integer', 'copy_to': 'range'},
'endOffset': {'type': 'integer', 'copy_to': 'range'},
}
},
'permission': {'type': 'string'},
'permissions': {
'index_name': 'permission',
'properties': {
'read': {'type': 'string'},
'update': {'type': 'string'},
'delete': {'type': 'string'},
'admin': {'type': 'string'}
'read': {'type': 'string', 'copy_to': 'permission'},
'update': {'type': 'string', 'copy_to': 'permission'},
'delete': {'type': 'string', 'copy_to': 'permission'},
'admin': {'type': 'string', 'copy_to': 'permission'}
}
},
'document': {
Expand Down
9 changes: 1 addition & 8 deletions annotator/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class _Model(dict):
def create_all(cls):
log.info("Creating index '%s'.", cls.es.index)
conn = cls.es.conn
conn.indices.create(cls.es.index, ignore=400)
conn.indices.create(cls.es.index, ignore=400, body={'settings': {'analyzer': 'keyword'}})
mapping = cls.get_mapping()
conn.indices.put_mapping(index=cls.es.index,
doc_type=cls.__type__,
Expand All @@ -99,13 +99,6 @@ def create_all(cls):
def get_mapping(cls):
return {
cls.__type__: {
'_id': {
'path': 'id',
},
'_source': {
'excludes': ['id'],
},
'analyzer': 'keyword',
'properties': cls.__mapping__,
}
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

requires = [
'elasticsearch>=1.0,<2',
'elasticsearch>=2.0.0,<3.0.0',
'PyJWT>=0.1.4',
'iso8601>=0.1.4',
'six',
Expand Down

0 comments on commit a606436

Please sign in to comment.