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
6412c4ff
Commit
6412c4ff
authored
Mar 09, 2016
by
Muzaffar yousaf
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43 from edx/muzafar/bug-fixes
Setting number_of_fragments to 0
parents
9854af48
0ed256a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
notesapi/v1/tests/test_views.py
+30
-0
notesapi/v1/views.py
+1
-0
No files found.
notesapi/v1/tests/test_views.py
View file @
6412c4ff
...
...
@@ -717,6 +717,36 @@ class AnnotationSearchViewTests(BaseAnnotationViewTests):
'{elasticsearch_highlight_start}First{elasticsearch_highlight_end} note'
)
@unittest.skipIf
(
settings
.
ES_DISABLED
,
"MySQL does not do highlighing"
)
def
test_search_highlight_with_long_text
(
self
):
"""
Tests highlighting with long text.
"""
text
=
"Lorem "
+
"word "
*
100
+
" Lorem"
start_tag
=
"{elasticsearch_highlight_start}"
end_tag
=
"{elasticsearch_highlight_end}"
expected_text
=
"{start_tag}Lorem{end_tag} {word} {start_tag}Lorem{end_tag}"
.
format
(
start_tag
=
start_tag
,
end_tag
=
end_tag
,
word
=
"word "
*
100
)
self
.
_create_annotation
(
text
=
text
)
self
.
_create_annotation
(
text
=
u'Second note'
)
results
=
self
.
_get_search_results
()
self
.
assertEqual
(
results
[
'total'
],
2
)
results
=
self
.
_get_search_results
(
text
=
"Lorem"
,
highlight
=
True
)
self
.
assertEqual
(
results
[
'total'
],
1
)
self
.
assertEqual
(
len
(
results
[
'rows'
]),
1
)
self
.
assertEqual
(
results
[
'rows'
][
0
][
'text'
],
expected_text
)
@override_settings
(
ES_DISABLED
=
True
)
def
test_search_ordering_in_db
(
self
):
"""
...
...
notesapi/v1/views.py
View file @
6412c4ff
...
...
@@ -157,6 +157,7 @@ class AnnotationSearchView(GenericAPIView):
opts
=
{
'pre_tags'
:
[
'{elasticsearch_highlight_start}'
],
'post_tags'
:
[
'{elasticsearch_highlight_end}'
],
'number_of_fragments'
:
0
}
query
=
query
.
highlight
(
**
opts
)
...
...
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