Created
December 20, 2012 20:30
-
-
Save anonymous/4348293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void thisShouldWork() throws Exception { | |
Node node = NodeBuilder.nodeBuilder().local(true).node(); | |
client = node.client(); | |
// delete the index | |
try { | |
client.admin().indices().delete(new DeleteIndexRequest("test-index")).actionGet(); | |
} catch (Exception e) { | |
} | |
String works = "{ \"stringValue\" : \"World Demo\", \"_id\" : { \"$oid\" : \"12345\"} }"; | |
String doesntWork = "{ \"_id\" : { \"$oid\" : \"12345\"}, \"stringValue\" : \"World Demo\"}"; | |
client.prepareIndex("test-index", "test-type", "12345").setSource(works).execute().actionGet(); | |
client.admin().indices().flush(new FlushRequest("test-index").refresh(true)).actionGet(); | |
SearchResponse response = client.prepareSearch("test-index").setSearchType(SearchType.DFS_QUERY_AND_FETCH).execute().actionGet(); | |
assertEquals(1, response.getHits().getTotalHits()); | |
response = client.prepareSearch("test-index").setSearchType(SearchType.DFS_QUERY_AND_FETCH).setQuery(termQuery("stringValue", "world")).execute().actionGet(); | |
assertEquals(1, response.getHits().getTotalHits()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment