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
375f48a7
Commit
375f48a7
authored
May 01, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Index and query ES using english analyzer
parent
78c8e6b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
models/comment.rb
+1
-1
models/comment_thread.rb
+5
-4
No files found.
models/comment.rb
View file @
375f48a7
...
...
@@ -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 @
375f48a7
# -*- 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