The Search API in Drupal 8
Thomas Seidl (drunken monkey)
The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer - - PowerPoint PPT Presentation
The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0 release. B a s i c a r c h i t e c t u r e S e r v e r I n d e x V
Thomas Seidl (drunken monkey)
Everything shown here is still a work in progress. Details might change until 8.0 release.
e n e r i c i n f
m a t i
a t a s
r c e s
i e l d s
r
e s s i n g
e a r c h w h a t ?
S e r v e r I n d e x V i e w s … F a c e t s
e c h n i c a l i m p l e m e n t a t i
s e s d a t a b a s e / S
r / …
e a r c h h
?
f i g u r a t i
e n t i t y
s e s „ b a c k e n d “ p l u g i n f
e r a t i
s
t
e s p l u g i n a n d s p e c i f i c s e t t i n g s
l u g i n f
s e r v e r s
m p l e m e n t a t i
s e r v e r
e r a t i
s
n d e x i n g , d e l e t i n g , s e a r c h i n g
e a c t i
t
h a n g e d i n d e x e s
u s t
c
f i g u r a t i
f
m
n e c t s t
t
a g e ( D B , S
r , … )
f i g u r a t i
e n t i t y
a i n c
n e c t i
t
h e r m
u l e s
l u g i n s :
D a t a s
r c e s “ p r
i d e d a t a
T r a c k e r “ t r a c k s i n d e x e d d a t a
P r
e s s
s “ a l t e r d a t a / w
k f l
n d e x p l u g i n p r
i d i n g a s p e c i f i c k i n d
d a t a
. g . , n
e s , c
m e n t s , e x t e r n a l d a t a
d i n g , v i e w i n g , m e t a d a t a f
t y p e s
a t a s
r c e
p e c i f i c c
f i g u r a t i
n d e x p l u g i n t r a c k i n g s t a t e
i t e m s
e a c t s t
e w / c h a n g e d / d e l e t e d i t e m s
i c h i t e m s s t i l l n e e d t
e i n d e x e d ?
n d e x p l u g i n c h a n g i n g d a t a / w
k f l
l t e r i n d e x e d i t e m s a n d s e a r c h q u e r i e s
f i g u r a b l e
F u s e d w i t h D 7 „ d a t a a l t e r a t i
s “ )
D a t a s
r c e s P r
e s s
s S e r v e r I n d e x
1 . D e t e r m i n e s c h a n g e d i t e m s 2 . L
d i t e m s 5 . E x t r a c t s f i e l d s 4 . A l t e r m e t a d a t a 6 . P r e p r
e s s f i e l d s / i t e m s 3 . P r
i d e m e t a d a t a 7 . S e n d s i t e m s t
e r v e r 8 . I n d e x e s i t e m s 9 . R e t u r n s i n d e x e d i t e m s 1 . M a r k s i t e m s a s i n d e x e d
T r a c k e r
Q u e r y P r
e s s
s S e r v e r S e a r c h
3 . P a r s e s k e y w
d s 1 . C r e a t e s q u e r y 6 . P r e p r
e s s q u e r y 8 . P
t p r
e s s s e a r c h r e s u l t s 4 . A d d s f i l t e r s , s
t , e t c . 7 . R e t r i e v e s r e s u l t s 5 . E x e c u t e s q u e r y 2 . A d d s k e y w
d s 9 . D i s p l a y s r e s u l t s
n t e g r a t e S e a r c h A P I w i t h n e w e n g i n e s
/** * @SearchApiBackend( * id = "MODULE_my_service", * label = @Translation("My backend"), * description = @Translation("Really cool!") * ) */ class MyService extends BackendPluginBase { function indexItems($index, $items) {} function deleteItems($index, $ids) {} function deleteAllIndexItems($index) {} function search($query) {} }
l s
v a i l a b l e :
f i g u r a t i
f
m
e a c t t
e w / c h a n g e d / r e m
e d i n d e x e s
R U D „ h
s “
supportsDatatype()
d d b a c k e n d
p e c i f i c f u n c t i
a l i t y
e f i n e d b y c
t r i b m
u l e s
s i n g m
u l e s c h e c k f
s u p p
t
r e a t i
: N
e , j u s t d
u m e n t a t i
. g . : f a c e t s , M L T , a u t
p l e t e , s p e l l c h e c k
e t b a c k e n d s s u p p
t n
e f a u l t d a t a t y p e s
. g . , l
a t i
c
d i n a t e s , s p e c i a l t e x t f
m a t s
a c k e n d s s t a t e s u p p
t s i m i l a r t
e a t u r e s
r
i d e d a s p l u g i n s
u m e n t a t i
i m p
t a n t
u p p
t f
c u s t
i t e m t y p e s
/** * @SearchApiDatasource( * id = "MODULE_my_datasource", * name = @Translation("My datasource"), * description = @Translation("My great type.") * ) */ class MyDatasource extends DatasourcePluginBase { function getPropertyDefinitions() {} function loadMultiple($ids) {} function getItemId($item) {} function getItemIds() {} // … }
l s
v a i l a b l e :
f i g u r a t i
f
m
i e w i n g a n d v i e w m
e s
e t i t e m ' s I D , l a b e l , U R L
a l l search_api_track_item_*()!
h a n g e t r a c k i n g i m p l e m e n t a t i
/** * @SearchApiTracker( * id = "MODULE_my_tracker", * name = @Translation("My tracker"), * description = @Translation("It tracks.") * ) */ class MyTracker extends TrackerPluginBase { function trackItemsInserted($ids) {} function getRemainingItems($limit, $datasource) {} function getTotalItemsCount() {} // … }
s u a l l y d e f a u l t t r a c k e r w i l l s u f f i c e
a n a l s
a v e a c
f i g u r a t i
f
m
r e
p
t p r
e s s i n d e x e d i t e m s a n d r e s u l t s
/** * @SearchApiProcessor( * id = "MODULE_my_processor", * label = @Translation("My processor"), * description = @Translation("Does stuff."), * stages = { * "preprocess_query" = 0 * } * ) */ class MyProcessor extends ProcessorPluginBase { function alterPropertyDefinitions(&$info) {} function preprocessIndexItems(&$items) {} function preprocessSearchQuery($query) {} function postprocessSearchResults(&$response, $query) {} }
l s
v a i l a b l e :
f i g u r a t i
f
m
e f a u l t i m p l e m e n t a t i
FieldsProcessorPluginBase
processFieldValue(), processKey(), processFilterValue(), testField(), testType()
n t e r p r e t a t i
k e y w
d s
y d e f a u l t : „ d i r e c t “ , „ s i n g l e t e r m “ , „ m u l t i p l e t e r m s “
e l e c t i
w h e n c r e a t i n g s e a r c h
d
e y e t , b u t w i l l b e p l u g g a b l e
7 : P l u g g a b l e i n
d w a y
8 : T B D
e v e r a l d a t a s
r c e s p e r i n d e x
e q u e r y f u n c t i
a l i t y ( l i k e D B l a y e r )
a j
c h a n g e s f
p r
e s s
s
s i b l y : „ q u e r y e x t e n d e r s “ / p e r
u e r y p r
e s s
c
f i g
d s
h e r s t u f f