Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2017-03-26 19:34:53 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
0651eae7ecdeb3b0781ed1231d601d936603e07d
0651eae7
1 parent
15524175
Improve efficiency of single entity search indexing
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
app/Services/SearchService.php
app/Services/SearchService.php
View file @
0651eae
...
...
@@ -100,7 +100,11 @@ class SearchService
$nameTerms
=
$this
->
generateTermArrayFromText
(
$entity
->
name
,
5
);
$bodyTerms
=
$this
->
generateTermArrayFromText
(
$entity
->
getText
(),
1
);
$terms
=
array_merge
(
$nameTerms
,
$bodyTerms
);
$entity
->
searchTerms
()
->
createMany
(
$terms
);
foreach
(
$terms
as
$index
=>
$term
)
{
$terms
[
$index
][
'entity_type'
]
=
$entity
->
getMorphClass
();
$terms
[
$index
][
'entity_id'
]
=
$entity
->
id
;
}
$this
->
searchTerm
->
newQuery
()
->
insert
(
$terms
);
}
/**
...
...
@@ -121,7 +125,7 @@ class SearchService
$chunkedTerms
=
array_chunk
(
$terms
,
500
);
foreach
(
$chunkedTerms
as
$termChunk
)
{
$this
->
searchTerm
->
insert
(
$termChunk
);
$this
->
searchTerm
->
newQuery
()
->
insert
(
$termChunk
);
}
}
...
...
Please
register
or
sign in
to post a comment