// Path: src/shadoworg/elasticsearch/common/xcontent/ToXContent.java
// @Deprecated
// public interface ToXContent {
// 
// }


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import shadoworg.elasticsearch.common.xcontent.ToXContent;
import com.winterwell.gson.FlexiGson;
import com.winterwell.utils.StrUtils;
import com.winterwell.utils.containers.ArrayMap;
import com.winterwell.utils.containers.Containers;
/**
 * 
 */
package com.winterwell.es;




/**
 * Elastic Search utils
 * 
 * @author daniel
 *
 */
public class ESUtils {

	
	/**
	 * See http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/
	 * mapping-core-types.html
	 * 
	 * @return an ElasticSearch type builder, which (being a Map) can be
	 *         submitted to PutMapping. This is just a convenience for <code>new ESType()</code>.
	 */
	public static ESType type() {
		return new ESType();
	}

	/**
	See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
		 */
	public static String escapeWord(String s) {
		if (s==null) return null;
		String chars = "+-&|!(){}[]^\"~*?:\\/";
		String s2 = StrUtils.escape(s, chars, '\\');
		// Note "&" will also have to be url-encoded!
		return s2;
	}
	
	/**
	 * HACK convert an ES class into a json object.
	 * TODO replace these ES classes with something nicer.
	 * Preferably auto-generated from the ES source
	 * @param qb
	 * @return
	 */
// Path: src/shadoworg/elasticsearch/common/xcontent/ToXContent.java
// @Deprecated
// public interface ToXContent {
// 
// }


// Path: src/com/winterwell/es/ESUtils.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import shadoworg.elasticsearch.common.xcontent.ToXContent;
import com.winterwell.gson.FlexiGson;
import com.winterwell.utils.StrUtils;
import com.winterwell.utils.containers.ArrayMap;
import com.winterwell.utils.containers.Containers;

/**
 * 
 */
package com.winterwell.es;




/**
 * Elastic Search utils
 * 
 * @author daniel
 *
 */
public class ESUtils {

	
	/**
	 * See http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/
	 * mapping-core-types.html
	 * 
	 * @return an ElasticSearch type builder, which (being a Map) can be
	 *         submitted to PutMapping. This is just a convenience for <code>new ESType()</code>.
	 */
	public static ESType type() {
		return new ESType();
	}

	/**
	See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
		 */
	public static String escapeWord(String s) {
		if (s==null) return null;
		String chars = "+-&|!(){}[]^\"~*?:\\/";
		String s2 = StrUtils.escape(s, chars, '\\');
		// Note "&" will also have to be url-encoded!
		return s2;
	}
	
	/**
	 * HACK convert an ES class into a json object.
	 * TODO replace these ES classes with something nicer.
	 * Preferably auto-generated from the ES source
	 * @param qb
	 * @return
	 */
	public static Map jobj(ToXContent qb) {