Hi,
I'm having problems when upgrading to 0.18.* (tried all versions, did
not occur in <0.18) and it seems to me I was either bitten via:
or via my template:
{ "tweet" : {
"dynamic_templates" : [
{
"template_1" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : { "type" : "string", "omit_norms" :
"yes" }
}
}
],
(no mapping for my date field called 'dt')
}}
When I remove this template all is fine but when not and I'm sorting
by my date field 'dt' I do not get any documents**:
count:2
hits:2
hits sorted:0
But why is now a date object of type string? Or is this related to the
issue where Shay says: "Will revert this, as its tricky without
changing default behavior now that I think about it. Need to think of
a better way to suport optional timezone in this case." So is this
issue already reverted (as it is closed) or is it in the 0.18
releases?
Peter.
Settings s = ImmutableSettings.settingsBuilder().put("cluster.name",
CLUSTER).build();
TransportClient client = new TransportClient(s);
client.addTransportAddress(new InetSocketTransportAddress("127.0.0.1",
PORT));
try {
client.admin().indices().create(new
CreateIndexRequest("tmp")).actionGet();
} catch (IndexAlreadyExistsException ex) {
}
client.prepareDeleteByQuery("tmp").setTypes("tweet").setQuery(QueryBuilders.matchAllQuery());
client.admin().indices().refresh(new RefreshRequest("tmp"));
BulkRequest br = new BulkRequest();
XContentBuilder cb =
JsonXContent.contentBuilder().startObject();
cb.field("dt", new Date(new Date().getTime() - 10000));
cb.field("text", "java");
br.add(new IndexRequest("tmp").id("1").type("tweet").source(cb));
cb = JsonXContent.contentBuilder().startObject();
cb.field("dt", new Date());
cb.field("text", "java");
br.add(new IndexRequest("tmp").id("2").type("tweet").source(cb));
client.bulk(br).actionGet();
client.admin().indices().refresh(new RefreshRequest("tmp"));
System.out.println("count:" + client.prepareCount("tmp").
execute().actionGet().count());
System.out.println("hits:" + client.prepareSearch("tmp").
setQuery(QueryBuilders.queryString("java").field("text")).
execute().actionGet().hits().totalHits());
System.out.println("hits sorted:" + client.prepareSearch("tmp").
setQuery(QueryBuilders.queryString("java").field("text")).
addSort("dt", SortOrder.DESC).
execute().actionGet().hits().totalHits());