diff --git a/core/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java b/core/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java index fc6e4a46125..d51288255ca 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java +++ b/core/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java @@ -32,6 +32,7 @@ import org.elasticsearch.index.engine.FlushNotAllowedEngineException; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.IndexingOperationListener; +import org.elasticsearch.index.translog.Translog; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.threadpool.ThreadPool; @@ -89,7 +90,6 @@ public class IndexingMemoryController extends AbstractComponent implements Index this(settings, threadPool, indexServices, JvmInfo.jvmInfo().getMem().getHeapMax().bytes()); } - // for testing IndexingMemoryController(Settings settings, ThreadPool threadPool, Iterable indexServices, long jvmMemoryInBytes) { super(settings); this.indexShards = indexServices; @@ -205,12 +205,20 @@ public class IndexingMemoryController extends AbstractComponent implements Index @Override public void postIndex(Engine.Index index, boolean created) { - bytesWritten(index.getTranslogLocation().size); + recordOperationBytes(index); } @Override public void postDelete(Engine.Delete delete) { - bytesWritten(delete.getTranslogLocation().size); + recordOperationBytes(delete); + } + + private void recordOperationBytes(Engine.Operation op) { + Translog.Location loc = op.getTranslogLocation(); + // This can be null on (harmless) version conflict during recovery: + if (loc != null) { + bytesWritten(loc.size); + } } private static final class ShardAndBytesUsed implements Comparable { diff --git a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java index 6608e341362..5bb20d0dd67 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java @@ -347,4 +347,16 @@ public class SimpleQueryStringIT extends ESIntegTestCase { assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); } + + public void testSimpleQueryStringUsesFieldAnalyzer() throws Exception { + client().prepareIndex("test", "type1", "1").setSource("foo", 123, "bar", "abc").get(); + client().prepareIndex("test", "type1", "2").setSource("foo", 234, "bar", "bcd").get(); + + refresh(); + + SearchResponse searchResponse = client().prepareSearch().setQuery( + simpleQueryStringQuery("123").field("foo").field("bar")).get(); + assertHitCount(searchResponse, 1L); + assertSearchHits(searchResponse, "1"); + } }