Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-notes-api
Commits
78eb4d29
Commit
78eb4d29
authored
Dec 29, 2014
by
Tim Babych
Committed by
Oleg Marshev
Jan 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create-index command
parent
ae383066
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
notesapi/management/commands/create_index.py
+24
-3
notesapi/v1/models.py
+4
-4
notesapi/v1/tests/test_views.py
+3
-2
No files found.
notesapi/management/commands/create_index.py
View file @
78eb4d29
from
optparse
import
make_option
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
elasticutils.contrib.django
import
get_es
from
notesapi.v1.models
import
NoteMappingType
class
Command
(
BaseCommand
):
help
=
'Creates the mapping in the index.'
help
=
'Creates index and the mapping.'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--drop'
,
action
=
'store_true'
,
dest
=
'drop'
,
default
=
False
,
help
=
'Recreate index'
),
)
def
handle
(
self
,
*
args
,
**
options
):
#TODO: cretate mapping using elasticutils
pass
if
options
[
'drop'
]:
# drop existing
get_es
()
.
indices
.
delete
(
index
=
settings
.
ES_INDEXES
[
'default'
],
ignore
=
404
)
get_es
()
.
indices
.
create
(
index
=
settings
.
ES_INDEXES
[
'default'
],
body
=
{
'mappings'
:
{
NoteMappingType
.
get_mapping_type_name
():
NoteMappingType
.
get_mapping
()
}
},
ignore
=
400
# ignore when present
)
notesapi/v1/models.py
View file @
78eb4d29
...
...
@@ -111,10 +111,10 @@ class NoteMappingType(MappingType, Indexable):
'user'
:
charfield
,
'course_id'
:
charfield
,
'usage_id'
:
charfield
,
'text'
:
{
'type'
:
'string'
,
'
index
'
:
'snowball'
,
'store'
:
True
},
'quote'
:
{
'type'
:
'string'
,
'
index
'
:
'snowball'
,
'store'
:
True
},
'created'
:
charfield
,
'updated'
:
charfield
,
'text'
:
{
'type'
:
'string'
,
'
analyzer
'
:
'snowball'
,
'store'
:
True
},
'quote'
:
{
'type'
:
'string'
,
'
analyzer
'
:
'snowball'
,
'store'
:
True
},
'created'
:
{
'type'
:
'date'
,
'store'
:
True
}
,
'updated'
:
{
'type'
:
'date'
,
'store'
:
True
}
,
}
}
...
...
notesapi/v1/tests/test_views.py
View file @
78eb4d29
...
...
@@ -15,6 +15,7 @@ from rest_framework.test import APITestCase
from
elasticutils.contrib.django
import
get_es
from
.helpers
import
get_id_token
from
notesapi.v1.models
import
NoteMappingType
,
note_searcher
from
notesapi.management.commands.create_index
import
Command
as
CreateIndexCommand
TEST_USER
=
"test_user_id"
...
...
@@ -73,14 +74,14 @@ class BaseAnnotationViewTests(APITestCase):
@classmethod
def
setUpClass
(
cls
):
get_es
()
.
indices
.
create
(
index
=
settings
.
ES_INDEXES
[
'default'
],
ignore
=
400
)
CreateIndexCommand
()
.
handle
(
drop
=
True
)
get_es
()
.
indices
.
refresh
()
get_es
()
.
cluster
.
health
(
wait_for_status
=
'yellow'
)
@classmethod
def
tearDownClass
(
cls
):
"""
*
deletes the test index
deletes the test index
"""
get_es
()
.
indices
.
delete
(
index
=
settings
.
ES_INDEXES
[
'default'
])
get_es
()
.
indices
.
refresh
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment