org.hibernate.search.elasticsearch.util.impl.ElasticsearchClientUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-elasticsearch Show documentation
Show all versions of hibernate-search-elasticsearch Show documentation
Hibernate Search backend which has indexing operations forwarded to Elasticsearch
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.search.elasticsearch.util.impl;
import java.util.List;
import org.apache.http.HttpEntity;
import org.hibernate.search.elasticsearch.client.impl.ElasticsearchRequest;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
/**
* @author Yoann Rodiere
*/
public class ElasticsearchClientUtils {
private ElasticsearchClientUtils() {
// Private constructor
}
public static boolean isSuccessCode(int code) {
return 200 <= code && code < 300;
}
public static HttpEntity toEntity(Gson gson, ElasticsearchRequest request) {
final List bodyParts = request.getBodyParts();
if ( bodyParts.isEmpty() ) {
return null;
}
return new GsonHttpEntity( gson, bodyParts );
}
}