// Path: src/main/java/crate/elasticsearch/action/searchinto/SearchIntoContext.java
// public class SearchIntoContext extends SearchContext {
// 
//     // currently we only support index targets
//     private String targetType = "index";
// 
//     private List<InetSocketTransportAddress> targetNodes;
// 
// 
//     public Map<String, String> outputNames() {
//         return outputNames;
//     }
// 
//     private final Map<String, String> outputNames = new HashMap<String,
//             String>();
// 
//     public SearchIntoContext(long id, ShardSearchRequest request,
//             SearchShardTarget shardTarget, Engine.Searcher engineSearcher,
//             IndexService indexService, IndexShard indexShard,
//             ScriptService scriptService, CacheRecycler cacheRecycler) {
//         super(id, request, shardTarget, engineSearcher, indexService,
//                 indexShard, scriptService, cacheRecycler);
//     }
// 
//     public String targetType() {
//         // this is currently the only type supported
//         return targetType;
//     }
// 
//     public List<InetSocketTransportAddress> targetNodes() {
//         if (targetNodes == null) {
//             targetNodes = Lists.newArrayList();
//         }
//         return targetNodes;
//     }
// 
//     public void emptyTargetNodes() {
//         this.targetNodes = ImmutableList.of();
//     }
// 
// }


import java.util.HashMap;
import java.util.Map;
import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.fetch.FetchPhase;
import org.elasticsearch.search.fetch.explain.ExplainParseElement;
import org.elasticsearch.search.query.QueryPhase;
import crate.elasticsearch.action.searchinto.SearchIntoContext;
package crate.elasticsearch.action.searchinto.parser;




/**
 * Parser for payload given to _search_into action.
 */
public class SearchIntoParser extends AbstractSearchIntoParser implements ISearchIntoParser {

    private final ImmutableMap<String, SearchParseElement> elementParsers;

    @Inject
    public SearchIntoParser(QueryPhase queryPhase, FetchPhase fetchPhase) {
        Map<String, SearchParseElement> elementParsers = new HashMap<String,
                SearchParseElement>();
        elementParsers.putAll(queryPhase.parseElements());
        elementParsers.put("fields", new FieldsParseElement());
        elementParsers.put("targetNodes", new TargetNodesParseElement());
        elementParsers.put("explain", new ExplainParseElement());
        this.elementParsers = ImmutableMap.copyOf(elementParsers);
    }

    @Override
// Path: src/main/java/crate/elasticsearch/action/searchinto/SearchIntoContext.java
// public class SearchIntoContext extends SearchContext {
// 
//     // currently we only support index targets
//     private String targetType = "index";
// 
//     private List<InetSocketTransportAddress> targetNodes;
// 
// 
//     public Map<String, String> outputNames() {
//         return outputNames;
//     }
// 
//     private final Map<String, String> outputNames = new HashMap<String,
//             String>();
// 
//     public SearchIntoContext(long id, ShardSearchRequest request,
//             SearchShardTarget shardTarget, Engine.Searcher engineSearcher,
//             IndexService indexService, IndexShard indexShard,
//             ScriptService scriptService, CacheRecycler cacheRecycler) {
//         super(id, request, shardTarget, engineSearcher, indexService,
//                 indexShard, scriptService, cacheRecycler);
//     }
// 
//     public String targetType() {
//         // this is currently the only type supported
//         return targetType;
//     }
// 
//     public List<InetSocketTransportAddress> targetNodes() {
//         if (targetNodes == null) {
//             targetNodes = Lists.newArrayList();
//         }
//         return targetNodes;
//     }
// 
//     public void emptyTargetNodes() {
//         this.targetNodes = ImmutableList.of();
//     }
// 
// }


// Path: src/main/java/crate/elasticsearch/action/searchinto/parser/SearchIntoParser.java
import java.util.HashMap;
import java.util.Map;
import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.fetch.FetchPhase;
import org.elasticsearch.search.fetch.explain.ExplainParseElement;
import org.elasticsearch.search.query.QueryPhase;
import crate.elasticsearch.action.searchinto.SearchIntoContext;

package crate.elasticsearch.action.searchinto.parser;




/**
 * Parser for payload given to _search_into action.
 */
public class SearchIntoParser extends AbstractSearchIntoParser implements ISearchIntoParser {

    private final ImmutableMap<String, SearchParseElement> elementParsers;

    @Inject
    public SearchIntoParser(QueryPhase queryPhase, FetchPhase fetchPhase) {
        Map<String, SearchParseElement> elementParsers = new HashMap<String,
                SearchParseElement>();
        elementParsers.putAll(queryPhase.parseElements());
        elementParsers.put("fields", new FieldsParseElement());
        elementParsers.put("targetNodes", new TargetNodesParseElement());
        elementParsers.put("explain", new ExplainParseElement());
        this.elementParsers = ImmutableMap.copyOf(elementParsers);
    }

    @Override
    protected void validate(SearchIntoContext context) {