package org.codelibs.elasticsearch.qrcache.filter;

import org.codelibs.elasticsearch.extension.chain.EngineChain;
import org.codelibs.elasticsearch.extension.filter.BaseEngineFilter;
import org.codelibs.elasticsearch.qrcache.cache.QueryResultCache;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.engine.Engine.Refresh;
import org.elasticsearch.index.engine.EngineException;

public class RefreshEngineFilter extends BaseEngineFilter {

    private QueryResultCache queryResultCache;

    @Inject
    public RefreshEngineFilter(final QueryResultCache queryResultCache) {
        this.queryResultCache = queryResultCache;
    }

    @Override
    public int order() {
        return 100;
    }

    @Override
    public void doRefresh(final Refresh refresh, final EngineChain chain)
            throws EngineException {
        chain.doRefresh(refresh);
        queryResultCache.clear(chain.getEngine().shardId().getIndex());
    }

}

@@ -294,62 +294,8 @@
 ct;%0A
-import org.elasticsearch.index.engine.Engine.Refresh;%0A
 impo
@@ -714,23 +714,21 @@
 nal 
-Refresh refresh
+String source
 , fi
@@ -815,15 +815,14 @@
 esh(
-refresh
+source
 );%0A 
@@ -870,12 +870,21 @@
 gine
-().s
+Config().getS
 hard

fix #7