Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
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
cs_comments_service
Commits
e7247d13
Commit
e7247d13
authored
May 08, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #98 from edx/gprice/english-analyzer
Index and query ES using english analyzer
parents
2d73b67f
1bf32e99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
Rakefile
+4
-0
models/comment.rb
+1
-1
models/comment_thread.rb
+5
-4
No files found.
Rakefile
View file @
e7247d13
...
...
@@ -359,6 +359,10 @@ namespace :db do
do_reindex
(
"Comment"
)
end
task
:create_search_indexes
=>
:environment
do
[
CommentThread
,
Comment
].
each
{
|
klass
|
create_index_for_class
(
klass
)
}
end
task
:add_anonymous_to_peers
=>
:environment
do
Content
.
collection
.
find
(
:anonymous_to_peers
=>
nil
).
update_all
({
"$set"
=>
{
'anonymous_to_peers'
=>
false
}})
end
...
...
models/comment.rb
View file @
e7247d13
...
...
@@ -31,7 +31,7 @@ class Comment < Content
include
Tire
::
Model
::
Callbacks
mapping
do
indexes
:body
,
type: :string
,
analyzer: :
snowball
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:body
,
type: :string
,
analyzer: :
english
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:course_id
,
type: :string
,
index: :not_analyzed
,
included_in_all:
false
#indexes :comment_thread_id, type: :string, stored: true, index: :not_analyzed, included_in_all: false
#current prod tire doesn't support indexing BSON ids, will reimplement when we upgrade
...
...
models/comment_thread.rb
View file @
e7247d13
# -*- coding: utf-8 -*-
require
'new_relic/agent/method_tracer'
require_relative
'content'
...
...
@@ -26,8 +27,8 @@ class CommentThread < Content
include
Tire
::
Model
::
Callbacks
mapping
do
indexes
:title
,
type: :string
,
analyzer: :
snowball
,
boost:
5.0
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:body
,
type: :string
,
analyzer: :
snowball
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:title
,
type: :string
,
analyzer: :
english
,
boost:
5.0
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:body
,
type: :string
,
analyzer: :
english
,
stored:
true
,
term_vector: :with_positions_offsets
indexes
:created_at
,
type: :date
,
included_in_all:
false
indexes
:updated_at
,
type: :date
,
included_in_all:
false
indexes
:last_activity_at
,
type: :date
,
included_in_all:
false
...
...
@@ -98,7 +99,7 @@ class CommentThread < Content
search
=
Tire
::
Search
::
Search
.
new
'comment_threads'
search
.
query
{
|
query
|
query
.
match
:_all
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
query
{
|
query
|
query
.
match
[
:title
,
:body
]
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
highlight
({
title:
{
number_of_fragments:
0
}
}
,
{
body:
{
number_of_fragments:
0
}
},
options:
{
tag:
"<highlight>"
})
search
.
filter
(
:term
,
commentable_id:
params
[
"commentable_id"
])
if
params
[
"commentable_id"
]
search
.
filter
(
:terms
,
commentable_id:
params
[
"commentable_ids"
])
if
params
[
"commentable_ids"
]
...
...
@@ -126,7 +127,7 @@ class CommentThread < Content
if
params
[
"text"
]
search
=
Tire
::
Search
::
Search
.
new
'comments'
search
.
query
{
|
query
|
query
.
match
:
_all
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
query
{
|
query
|
query
.
match
:
body
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
filter
(
:term
,
course_id:
params
[
"course_id"
])
if
params
[
"course_id"
]
search
.
size
CommentService
.
config
[
"max_deep_search_comment_count"
].
to_i
...
...
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