Dear all,
I'm playing with facet of ES, it's very convenience for my sub navigation.
But here I meet a problem:
my data just like:
{"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}
{"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}
{"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}
{"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
{"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}
{"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}
{"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}
{"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}
{"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
//I just execute the es java api like below:
TermsFacetBuilder facetUN = new TermsFacetBuilder("username");
facetUN.fields("username");
TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");
facetMT.fields("mtype");
...
searchRequest.addFacet(facetUN);
searchRequest.addFacet(facetMT);
... execute search request and get the response
I just want to get a facet result like this:
username:
jacky sun(4)
yang sun(5)
media type:
mp4(4)
rmvb(5)
But the actual result is:
username:
sun(9)
jacky(4)
yang(5)
media type:
mp4(4)
rmvb(5)
Then I realized "jacky sun" had been tokenized.
After I saw the info under
http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html ,
it's telling me to set the field(username) as "not_analyzed".
Because I don't know how to set it via java client, I just execute the
setting request like this on Win7:
C:>curl -XPUT http://localhost:9200/_all/_mapping -d " {fullword :
{properties : {username : {type : """string""", index :
"""not_analyzed"""}}}}"
Then I got the error:
{"error":"ActionRequestValidationException[Validation Failed: 1: mapping
type is missing;]","status":500}
Could anybody tell me where could I put the "mapping type" or "type" in the
url above?
Or is there any other way to make "jacky sun" not to be tokenized?
thanks,
--
Yang