Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Test case for copy_to metadata fields
Browse files Browse the repository at this point in the history
Related to #190
  • Loading branch information
dadoonet committed Nov 23, 2015
1 parent bd393e9 commit df1e894
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,23 @@ public void testCopyToSubField() throws Exception {
*/
@Test
public void testCopyToMetaData() throws Exception {
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/integration/simple/copy-to-subfield.json");
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/integration/simple/copy-to-metadata.json");
byte[] txt = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/attachment/test/sample-files/text-in-english.txt");

client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet();

index("test", "person", jsonBuilder().startObject().field("file", txt).endObject());
index("test", "person", jsonBuilder().startObject()
.startObject("file")
.field("_content", txt)
.field("_name", "name")
.endObject()
.endObject());
refresh();

CountResponse countResponse = client().prepareCount("test").setQuery(queryStringQuery("Queen").defaultField("file")).execute().get();
CountResponse countResponse = client().prepareCount("test").setQuery(queryStringQuery("name").defaultField("file.name")).execute().get();
assertThatWithError(countResponse.getCount(), equalTo(1l));

countResponse = client().prepareCount("test").setQuery(queryStringQuery("Queen").defaultField("copy")).execute().get();
countResponse = client().prepareCount("test").setQuery(queryStringQuery("name").defaultField("copy")).execute().get();
assertThatWithError(countResponse.getCount(), equalTo(1l));
}

Expand Down

0 comments on commit df1e894

Please sign in to comment.