de.tblsoft.solr.pipeline.ElasticJsonPathReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solr-cmd-utils Show documentation
Show all versions of solr-cmd-utils Show documentation
A command line util for solr.
The newest version!
package de.tblsoft.solr.pipeline;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import de.tblsoft.solr.http.ElasticHelper;
import de.tblsoft.solr.http.HTTPHelper;
import de.tblsoft.solr.pipeline.bean.Document;
import de.tblsoft.solr.pipeline.bean.Reader;
import de.tblsoft.solr.pipeline.filter.SimpleMapping;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by tblsoft on 14.05.16.
*/
public class ElasticJsonPathReader extends AbstractReader {
private String url;
private String scroll;
public void read() {
String response = "";
String pagedUrl = "";
String scrollId = "";
boolean hasHits = false;
SimpleMapping simpleMapping = new SimpleMapping(getPropertyAsList("mapping", new ArrayList()), getPropertyAsList("config", new ArrayList()));
Map> mapping = simpleMapping.getMapping();
try {
url = getProperty("url", null);
scroll = getProperty("scroll", "1m");
String scrollBaseUrl = ElasticHelper.getScrollUrl(url);
pagedUrl = url + "&scroll=" + scroll;
do {
response = HTTPHelper.get(pagedUrl);
DocumentContext context = JsonPath.parse(response);
scrollId = context.read("$['_scroll_id']");
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy