mohabshihab
(Mohab Shihab)
September 21, 2018, 1:20pm
1
I have an under development springboot application and need to use elastic search for items search for items search
I am using spring data elastic search repository implementation
my question is what's the best practice to insert and update data at the elastic search repository
should I apply this via aspect programming or modify the business logic implementation and add the repository save function all
dadoonet
(David Pilato)
September 21, 2018, 2:04pm
2
I'd modify the business logic.
An example here:
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package fr.pilato.demo.legacysearch.service;
This file has been truncated. show original
(Look at the save
method).
mohabshihab
(Mohab Shihab)
September 21, 2018, 3:57pm
3
Thanks @dadoonet
I see many implementation the as you said, but
Doesn't this with the single responsibility principle ?
Why not selecting to implement JPA entity listener and call save at persist event or user aspect oriented programming
dadoonet
(David Pilato)
September 21, 2018, 4:20pm
4
It can work. But I honestly prefer to decouple the storage logic vs the search logic.
system
(system)
Closed
October 20, 2018, 4:14am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.