Hi,
I'm trying to run elasticsearch locally inside a unit testing framework,
and running into a bit of trouble. The behavior I am seeing is that Get
requests work fine, but Search requests for some reason give me 0 results
always. here's an example:
// first, try a get request, to make sure there is something in the
index
GetResponse results = client.prepareGet(INDEX_NAME, INDEX_TYPE,
testID).execute().actionGet();
// this assertion succeeds, as we expect it to.
assertThat(results.getId()).isEqualTo(testID);
// next, try the simplest possible search
SearchResponse s1 =
client.prepareSearch(INDEX_NAME).setQuery(matchAllQuery()).setTypes(INDEX_TYPE).execute().get();
-
// this assertion fails. why?* assertThat(s1.getHits().totalHits()).isGreaterThanOrEqualTo(1);
When I run the same code against a "real" elastic search index, it gives me
all the documents in my index, which is what I would expect. I think that
the problem is how I am configuring my local node. Does anyone see any red
flags in the below Node configuration?
@BeforeMethod
public void setup() {
Settings settings = ImmutableSettings.settingsBuilder()
.put("node.http.enabled", true)
.put("path.logs","target/elasticsearch/logs")
.put("path.data","target/elasticsearch/data")
.put("gateway.type", "none")
.put("index.store.type", "memory")
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1).build();
node =
NodeBuilder.nodeBuilder().local(true).settings(settings).node();
client = node.client();
}
thanks in advance for your help!
--paul
--