Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
elasticsearch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
elasticsearch
Commits
4223ea3c88ce
Commit
4223ea3c88ce
authored
8 years ago
by
Katia Saurfelt
Browse files
Options
Downloads
Patches
Plain Diff
[index] do not index entities with empty IFullTextIndexSerializable
parent
a6137bc159fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ccplugin.py
+7
-3
7 additions, 3 deletions
ccplugin.py
hooks.py
+13
-2
13 additions, 2 deletions
hooks.py
with
20 additions
and
5 deletions
ccplugin.py
+
7
−
3
View file @
4223ea3c
...
...
@@ -105,6 +105,10 @@
for
entity
in
rset
.
entities
():
serializer
=
entity
.
cw_adapt_to
(
'
IFullTextIndexSerializable
'
)
json
=
serializer
.
serialize
()
if
not
dry_run
:
if
not
dry_run
and
json
:
# Entities with
# fulltext_containers relations return their container
# IFullTextIndex serializer , therefor the "id" and
# "doc_type" in kwargs bellow must be container data.
data
=
{
'
_op_type
'
:
'
index
'
,
'
_index
'
:
index_name
or
cnx
.
vreg
.
config
[
'
index-name
'
],
...
...
@@ -109,7 +113,7 @@
data
=
{
'
_op_type
'
:
'
index
'
,
'
_index
'
:
index_name
or
cnx
.
vreg
.
config
[
'
index-name
'
],
'
_type
'
:
etype
,
'
_id
'
:
entity
.
eid
,
'
_type
'
:
json
[
'
cw_
etype
'
]
,
'
_id
'
:
json
[
'
eid
'
]
,
'
_source
'
:
json
}
self
.
customize_data
(
data
)
...
...
This diff is collapsed.
Click to expand it.
hooks.py
+
13
−
2
View file @
4223ea3c
...
...
@@ -91,9 +91,20 @@
eid
=
entity
.
eid
)
indexable_entity
=
self
.
cnx
.
execute
(
rql
).
one
()
serializer
=
indexable_entity
.
cw_adapt_to
(
'
IFullTextIndexSerializable
'
)
kwargs
[
'
body
'
]
=
json
=
serializer
.
serialize
()
json
=
serializer
.
serialize
(
complete
=
True
)
if
not
json
:
# if en entity has been already indexed, we still
# keep the first indexation
# which is wrong. We should remove the existing es entry.
continue
kwargs
[
'
body
'
]
=
json
# Entities with fulltext_containers relations return their container
# IFullTextIndex serializer, therefore the "id" and "doc_type" in
# kwargs below must be container data.
kwargs
[
'
id
'
]
=
json
[
'
eid
'
]
kwargs
[
'
doc_type
'
]
=
json
[
'
cw_etype
'
]
if
json
.
get
(
'
parent
'
):
kwargs
[
'
parent
'
]
=
json
.
pop
(
'
parent
'
)
else
:
# TODO only for types that have parents
kwargs
[
'
routing
'
]
=
entity
.
eid
try
:
...
...
@@ -95,9 +106,9 @@
if
json
.
get
(
'
parent
'
):
kwargs
[
'
parent
'
]
=
json
.
pop
(
'
parent
'
)
else
:
# TODO only for types that have parents
kwargs
[
'
routing
'
]
=
entity
.
eid
try
:
# TODO option
pour coté
async ?
thread
# TODO option
for
async ?
es
.
index
(
**
kwargs
)
except
(
ConnectionError
,
ProtocolError
):
log
.
debug
(
'
Failed to index in hook, could not connect to ES
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment