Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
862262bd
Commit
862262bd
authored
Jul 02, 2015
by
Dino Cikatic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SOL-974 make index and remove calls use ES bulk API
parent
29df7506
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
10 deletions
+15
-10
cms/djangoapps/contentstore/courseware_index.py
+14
-9
cms/djangoapps/contentstore/tests/test_courseware_index.py
+0
-0
requirements/edx/github.txt
+1
-1
No files found.
cms/djangoapps/contentstore/courseware_index.py
View file @
862262bd
...
...
@@ -111,8 +111,7 @@ class SearchIndexerBase(object):
exclude_dictionary
=
{
"id"
:
list
(
exclude_items
)}
)
result_ids
=
[
result
[
"data"
][
"id"
]
for
result
in
response
[
"results"
]]
for
result_id
in
result_ids
:
searcher
.
remove
(
cls
.
DOCUMENT_TYPE
,
result_id
)
searcher
.
remove
(
cls
.
DOCUMENT_TYPE
,
result_ids
)
@classmethod
def
index
(
cls
,
modulestore
,
structure_key
,
triggered_at
=
None
,
reindex_age
=
REINDEX_AGE
):
...
...
@@ -142,7 +141,7 @@ class SearchIndexerBase(object):
structure_key
=
cls
.
normalize_structure_key
(
structure_key
)
location_info
=
cls
.
_get_location_info
(
structure_key
)
# Wrap counter in dictionary - otherwise we seem to lose scope inside the embedded function `
index_item
`
# Wrap counter in dictionary - otherwise we seem to lose scope inside the embedded function `
prepare_item_index
`
indexed_count
=
{
"count"
:
0
}
...
...
@@ -153,15 +152,20 @@ class SearchIndexerBase(object):
# list - those are ready to be destroyed
indexed_items
=
set
()
# items_index is a list of all the items index dictionaries.
# it is used to collect all indexes and index them using bulk API,
# instead of per item index API call.
items_index
=
[]
def
get_item_location
(
item
):
"""
Gets the version agnostic item location
"""
return
item
.
location
.
version_agnostic
()
.
replace
(
branch
=
None
)
def
index_item
(
item
,
skip_index
=
False
,
groups_usage_info
=
None
):
def
prepare_item_index
(
item
,
skip_index
=
False
,
groups_usage_info
=
None
):
"""
Add this item to the
search
index and indexed_items list
Add this item to the
items_
index and indexed_items list
Arguments:
item - item to add to index, its children will be processed recursively
...
...
@@ -212,7 +216,7 @@ class SearchIndexerBase(object):
for
child_item
in
item
.
get_children
():
if
modulestore
.
has_published_version
(
child_item
):
children_groups_usage
.
append
(
index_item
(
prepare_item_index
(
child_item
,
skip_index
=
skip_child_index
,
groups_usage_info
=
groups_usage_info
...
...
@@ -234,7 +238,7 @@ class SearchIndexerBase(object):
item_index
[
'start_date'
]
=
item
.
start
item_index
[
'content_groups'
]
=
item_content_groups
if
item_content_groups
else
None
item_index
.
update
(
cls
.
supplemental_fields
(
item
))
searcher
.
index
(
cls
.
DOCUMENT_TYPE
,
item_index
)
items_index
.
append
(
item_index
)
indexed_count
[
"count"
]
+=
1
return
item_content_groups
except
Exception
as
err
:
# pylint: disable=broad-except
...
...
@@ -252,7 +256,8 @@ class SearchIndexerBase(object):
# Now index the content
for
item
in
structure
.
get_children
():
index_item
(
item
,
groups_usage_info
=
groups_usage_info
)
prepare_item_index
(
item
,
groups_usage_info
=
groups_usage_info
)
searcher
.
index
(
cls
.
DOCUMENT_TYPE
,
items_index
)
cls
.
remove_deleted_items
(
searcher
,
structure_key
,
indexed_items
)
except
Exception
as
err
:
# pylint: disable=broad-except
# broad exception so that index operation does not prevent the rest of the application from working
...
...
@@ -623,7 +628,7 @@ class CourseAboutSearchIndexer(object):
# Broad exception handler to protect around and report problems with indexing
try
:
searcher
.
index
(
cls
.
DISCOVERY_DOCUMENT_TYPE
,
course_info
)
searcher
.
index
(
cls
.
DISCOVERY_DOCUMENT_TYPE
,
[
course_info
]
)
except
:
# pylint: disable=bare-except
log
.
exception
(
"Course discovery indexing error encountered, course discovery index may be out of date
%
s"
,
...
...
cms/djangoapps/contentstore/tests/test_courseware_index.py
View file @
862262bd
This diff is collapsed.
Click to expand it.
requirements/edx/github.txt
View file @
862262bd
...
...
@@ -47,7 +47,7 @@ git+https://github.com/edx/ease.git@release-2015-07-14#egg=ease==0.1.3
git+https://github.com/edx/edx-oauth2-provider.git@0.5.2#egg=oauth2-provider==0.5.2
-e git+https://github.com/edx/edx-val.git@v0.0.5#egg=edx-val
-e git+https://github.com/pmitros/RecommenderXBlock.git@518234bc354edbfc2651b9e534ddb54f96080779#egg=recommender-xblock
-e git+https://github.com/edx/edx-search.git@release-2015-07-
03
#egg=edx-search
-e git+https://github.com/edx/edx-search.git@release-2015-07-
14
#egg=edx-search
-e git+https://github.com/edx/edx-milestones.git@release-2015-06-17#egg=edx-milestones
git+https://github.com/edx/edx-lint.git@ed8c8d2a0267d4d42f43642d193e25f8bd575d9b#egg=edx_lint==0.2.3
-e git+https://github.com/edx/xblock-utils.git@213a97a50276d6a2504d8133650b2930ead357a0#egg=xblock-utils
...
...
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