
io.searchbox.core.Search Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jest-common Show documentation
Show all versions of jest-common Show documentation
ElasticSearch Java REST client - shared library package
package io.searchbox.core;
import com.google.gson.Gson;
import io.searchbox.action.AbstractAction;
import io.searchbox.action.AbstractMultiTypeActionBuilder;
import io.searchbox.core.search.sort.Sort;
import io.searchbox.params.Parameters;
import io.searchbox.params.SearchType;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.*;
/**
* @author Dogukan Sonmez
* @author cihat keser
*/
public class Search extends AbstractAction {
private String query;
private List sortList = new LinkedList();
protected Search(Builder builder) {
super(builder);
this.query = builder.query;
this.sortList = builder.sortList;
setURI(buildURI());
}
protected Search(TemplateBuilder templatedBuilder) {
super(templatedBuilder);
//reuse query as it's just the request body of the POST
this.query = templatedBuilder.query;
this.sortList = templatedBuilder.sortList;
setURI(buildURI() + "/template");
}
@Override
public SearchResult createNewElasticSearchResult(String responseBody, int statusCode, String reasonPhrase, Gson gson) {
return createNewElasticSearchResult(new SearchResult(gson), responseBody, statusCode, reasonPhrase, gson);
}
public String getIndex() {
return this.indexName;
}
public String getType() {
return this.typeName;
}
@Override
protected String buildURI() {
return super.buildURI() + "/_search";
}
@Override
public String getPathToResult() {
return "hits/hits/_source";
}
@Override
public String getRestMethodName() {
return "POST";
}
@SuppressWarnings("unchecked")
@Override
public String getData(Gson gson) {
String data;
if (sortList.isEmpty()) {
data = query;
} else {
Map rootJson = gson.fromJson(query, Map.class);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy