com.shopizer.search.services.worker.DeleteObjectImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sm-search Show documentation
Show all versions of sm-search Show documentation
Search module for shopizer using elasticsearch 5.6.12
package com.shopizer.search.services.worker;
import javax.inject.Inject;
import com.shopizer.search.services.impl.SearchDelegate;
import com.shopizer.search.utils.SearchClient;
public class DeleteObjectImpl implements DeleteObjectWorker {
@Inject
private SearchDelegate searchDelegate;
public void deleteObject(SearchClient client, String collection, String object, String id,
ExecutionContext context) throws Exception {
// need to get the original entry
com.shopizer.search.services.GetResponse r = searchDelegate.getObject(collection, object, id);
if (r != null) {
if (context == null) {
context = new ExecutionContext();
}
if (r.getFieldMap() != null && r.getFieldMap().size() > 0) {
// ObjectMapper mapper = new ObjectMapper();
// Map indexData = mapper.readValue(r.getResponseAsString(), Map.class);
context.setObject("indexData", r.getFieldMap());
}
}
/*
* String query = new StringBuilder() .append("{\"query\":{\"term\" : {\"_id\" : \"")
* .append(id) .append("\" }}}").toString();
*
* SearchRequest r = new SearchRequest(); r.setCollection(collection); r.setJson(query);
*/
// SearchResponse resp =s.search(r);
// if(resp.getSearchHits()!=null && resp.getSearchHits().size()>0) {
// List hits = (List)resp.getSearchHits();
// SearchHit hit = hits.get(0);
// Map obj = hit.getSource();
/*
* Map indexData = (Map)context.getObject("indexData"); if(indexData==null) {
* ObjectMapper mapper = new ObjectMapper(); indexData = mapper.readValue(json, Map.class); }
*/
// if(context==null) {
// context = new ExecutionContext();
// }
// context.setObject("indexData", obj);
// }
// SearchServiceImpl search = new SearchServiceImpl(client);
searchDelegate.delete(collection, object, id);
}
public void deleteObject(SearchClient client, String collection, String object, String id)
throws Exception {
throw new Exception("Not implemented");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy