Hi,
I created an index, which was named test_all, and it has a "table" :
type1. I want to test the usage of "_all" and "_source". Now , I change
their status to false. The mapping as follows:
$ curl -XGET 'localhost:9200/test_all/_mapping/type1?pretty'
{
"test_all" : {
"mappings" : {
"type1" : {
"_all" : {
"enabled" :false
},
"_source" : {
"enabled" : false
},
"properties" : {
"content" : {
"type" : "string",
"analyzer" : "ik"
},
"title" : {
"type" : "string",
"store" : true,
"analyzer" : "ik"
}
}
}
}
}
}
In the table "type1", I store thetitle information. I insert five
document in type1. But, when retrievaling them, I could not find the
field "title" information.
$ curl -XGET 'localhost:9200/test_all/type1/_search?pretty'
{
"took" : 16,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 1.0,
"hits" : [ {
"_index" : "test_all",
"_type" : "type1",
"_id" : "zWQno3rLS56hkwJ_Y108Dg",
"_score" : 1.0
}, {
"_index" : "test_all",
"_type" : "type1",
"_id" : "BDKa-IP7TDK_iM2VNGFPYw",
"_score" : 1.0
}, {
"_index" : "test_all",
"_type" : "type1",
"_id" : "n97suWSwQACgx35APTOqPg",
"_score" : 1.0
}, {
"_index" : "test_all",
"_type" : "type1",
"_id" : "2P7OblUiQB2Y8ZCtWWWTdg",
"_score" : 1.0
}, {
"_index" : "test_all",
"_type" : "type1",
"_id" : "Lo_PFVeKTEWazwCLbyKAqQ",
"_score" : 1.0
} ]
}
}
Then, I try to resolve it by JAVA API:
public static void indexSearch(Client client){
SearchRequestBuilder searchRequestBuilder=client.prepareSearch("test_all");
searchRequestBuilder.setTypes("type1");
SearchResponse searchResponse=searchRequestBuilder.execute().actionGet();
SearchHit[]hits=searchResponse.getHits().getHits();
System.out.println("count: "+hits.length);
for(SearchHit hit:hits){
System.out.println("----------------------------");
System.out.println("docID: "+hit.getId());
System.out.println("score: "+hit.getScore());
System.out.println("title: "+hit.getFields().get("title").toString());
}
}
and it shows:
Exception in thread "main" count: 5
java.lang.NullPointerException
at es.api.Test_All.indexSearch(Test_All.java:64)
at es.api.Test_All.main(Test_All.java:73)
docID: zWQno3rLS56hkwJ_Y108Dg
score: 1.0
I guess the value doesn't exist.
Can you call me why?
Many Thanks.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/53FAE834.1090000%40gmail.com.
For more options, visit https://groups.google.com/d/optout.