關于Elasticsearch Query中的Query DSL問題
老師,為什么我搜索name的值為大寫開頭的時候,返回的是這樣的結果呢?
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的值改成小寫開頭的時候就能正確返回結果。
2018-04-08
哦,你用的是term查詢,是直接拿著這個term去匹配的,但是默認分詞結果是小寫的,所以會無法匹配,你用match就可以了
2018-04-08
哦,你用的是term查詢,是直接拿著這個term去匹配的,但是默認分詞結果是小寫的,所以會無法匹配,你用match就可以了
2018-04-07
你的 mapping 設置是什么?具體文檔是什么?
2018-04-08
我通過命令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的內容呢?
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" }