關(guān)于Elasticsearch Query中的Query DSL問(wèn)題
老師,為什么我搜索name的值為大寫(xiě)開(kāi)頭的時(shí)候,返回的是這樣的結(jié)果呢?
GET?accounts/person/_search
{
??"query":?{
????"term":?{
??????"name":?{
????????"value":?"John"
??????}
????}
??}
}{
??"took":?2,
??"timed_out":?false,
??"_shards":?{
????"total":?5,
????"successful":?5,
????"skipped":?0,
????"failed":?0
??},
??"hits":?{
????"total":?0,
????"max_score":?null,
????"hits":?[]
??}
}把name的值改成小寫(xiě)開(kāi)頭的時(shí)候就能正確返回結(jié)果。
2018-04-08
哦,你用的是term查詢,是直接拿著這個(gè)term去匹配的,但是默認(rèn)分詞結(jié)果是小寫(xiě)的,所以會(huì)無(wú)法匹配,你用match就可以了
2018-04-08
哦,你用的是term查詢,是直接拿著這個(gè)term去匹配的,但是默認(rèn)分詞結(jié)果是小寫(xiě)的,所以會(huì)無(wú)法匹配,你用match就可以了
2018-04-07
你的 mapping 設(shè)置是什么?具體文檔是什么?
2018-04-08
我通過(guò)命令GET /accounts/person/_mapping?pretty 查看mapping得到的是
{ ??"accounts":?{ ????"mappings":?{ ??????"person":?{ ????????"properties":?{ ??????????"job_description":?{ ????????????"type":?"text", ????????????"fields":?{ ??????????????"keyword":?{ ????????????????"type":?"keyword", ????????????????"ignore_above":?256 ??????????????} ????????????} ??????????}, ??????????"lastname":?{ ????????????"type":?"text", ????????????"fields":?{ ??????????????"keyword":?{ ????????????????"type":?"keyword", ????????????????"ignore_above":?256 ??????????????} ????????????} ??????????}, ??????????"name":?{ ????????????"type":?"text", ????????????"fields":?{ ??????????????"keyword":?{ ????????????????"type":?"keyword", ????????????????"ignore_above":?256 ??????????????} ????????????} ??????????} ????????} ??????} ????} ??} }具體文檔是不是指我建立的index和type的內(nèi)容呢?
POST?/accounts/person/1 { ??"name":?"John", ??"lastname":?"Doe", ??"job_description":?"Systems?administrator?and?Linux?specialit" } POST?/accounts/person/2 { ??"name":?"Alfred", ??"lastname":?"Way", ??"job_description":?"teacher" }