日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ES中如何使用逗号来分词

發布時間:2023/12/31 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ES中如何使用逗号来分词 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

使用軟件版本:elasticsearch-2.2.0

1. setting:

curl?-XPOST?'http://localhost:9200/data'?-d?'{"settings":?{"analysis":?{"analyzer":?{"comma":?{"type":?"pattern","pattern":","}}}}} } '

return:

{"acknowledged":true}

2. view index:

curl?-XGET?'http://localhost:9200/data'

return:

{"data":?{"aliases":?{},"mappings":?{},"settings":?{"index":?{"creation_date":?"1456931889151","analysis":?{"analyzer":?{"comma":?{"pattern":?",","type":?"pattern"}}},"number_of_shards":?"5","number_of_replicas":?"1","uuid":?"aXyFMRzKQ0m_Ex8N2yJeSA","version":?{"created":?"2020099"}}},"warmers":?{}} }

3. mapping:

curl?-XPOST?'http://localhost:9200/data/_mapping/record'?-d?'{"properties":?{"id":?{?"type":?"string",?"index":?"not_analyzed"?},"number":?{?"type":?"string",?"analyzer":?"comma",?"search_analyzer":?"comma"?}} } '

return:

{"acknowledged":true}

4. view index:

curl?-XGET?'http://localhost:9200/data'

return:

{"data":?{"aliases":?{},"mappings":?{"record":?{"properties":?{"id":?{"type":?"string","index":?"not_analyzed"},"number":?{"type":?"string","analyzer":?"comma"}}}},"settings":?{"index":?{"creation_date":?"1456972030705","analysis":?{"analyzer":?{"comma":?{"pattern":?",","type":?"pattern"}}},"number_of_shards":?"5","number_of_replicas":?"1","uuid":?"A9Z76U9DR0OBqn29smtq8w","version":?{"created":?"2020099"}}},"warmers":?{}} }

5. verify analyze:

curl?-GET?'http://127.0.0.1:9200/data/_analyze?analyzer=comma&text=2,3,4,5,100-100'

return:

{"tokens":?[{"token":?"2","start_offset":?0,"end_offset":?1,"type":?"word","position":?0},{"token":?"3","start_offset":?2,"end_offset":?3,"type":?"word","position":?101},{"token":?"4","start_offset":?4,"end_offset":?5,"type":?"word","position":?202},{"token":?"5","start_offset":?6,"end_offset":?7,"type":?"word","position":?303},{"token":?"100-100","start_offset":?8,"end_offset":?15,"type":?"word","position":?404}] }

6. post data:

curl?-PUT?'http://localhost:9200/data/record'?-d?'{"id"?:?"001CV","number"?:?"2,3,4,5,100-100,1010" } '

return:

{"_index":?"data","_type":?"record","_id":?"AVM3kt-GiEDWd2i_MREb","_version":?1,"_shards":?{"total":?2,"successful":?1,"failed":?0},"created":?true }

7. post data:

curl?-PUT?'http://localhost:9200/data/record'?-d?'{"id"?:?"002CV","number"?:?"9999,8888" } '

return:

{"_index":?"data","_type":?"record","_id":?"AVM3k7vIiEDWd2i_MREc","_version":?1,"_shards":?{"total":?2,"successful":?1,"failed":?0},"created":?true }

8. post data:

curl?-PUT?'http://localhost:9200/data/record'?-d?'{"id"?:?"002CV","number"?:?"2,8888" } '

return:

{"_index":?"data","_type":?"record","_id":?"AVM3mCGMiEDWd2i_MREh","_version":?1,"_shards":?{"total":?2,"successful":?1,"failed":?0},"created":?true }

9. search data:

curl?-XGET?'http://localhost:9200/data/record/_search?q=number:9999'

return:

{"took":?41,"timed_out":?false,"_shards":?{"total":?5,"successful":?5,"failed":?0},"hits":?{"total":?1,"max_score":?0.19178301,"hits":?[{"_index":?"data","_type":?"record","_id":?"AVM3k7vIiEDWd2i_MREc","_score":?0.19178301,"_source":?{"id":?"002CV","number":?"9999,8888"}}]} }

10. search data:

curl?-XGET?'http://localhost:9200/data/record/_search?q=number:2'

return:

{"took":?2,"timed_out":?false,"_shards":?{"total":?5,"successful":?5,"failed":?0},"hits":?{"total":?2,"max_score":?0.37158427,"hits":?[{"_index":?"data","_type":?"record","_id":?"AVM3mCGMiEDWd2i_MREh","_score":?0.37158427,"_source":?{"id":?"002CV","number":?"2,8888"}},{"_index":?"data","_type":?"record","_id":?"AVM3kt-GiEDWd2i_MREb","_score":?0.22295055,"_source":?{"id":?"001CV","number":?"2,3,4,5,100-100,1010"}}]} }

11. search data:

curl?-XGET?'http://localhost:9200/data/record/_search?q=number:8888,100-100'

return:

{"took":?3,"timed_out":?false,"_shards":?{"total":?5,"successful":?5,"failed":?0},"hits":?{"total":?3,"max_score":?0.22097087,"hits":?[{"_index":?"data","_type":?"record","_id":?"AVM3mCGMiEDWd2i_MREh","_score":?0.22097087,"_source":?{"id":?"002CV","number":?"2,8888"}},{"_index":?"data","_type":?"record","_id":?"AVM3kt-GiEDWd2i_MREb","_score":?0.13258252,"_source":?{"id":?"001CV","number":?"2,3,4,5,100-100,1010"}},{"_index":?"data","_type":?"record","_id":?"AVM3k7vIiEDWd2i_MREc","_score":?0.028130025,"_source":?{"id":?"002CV","number":?"9999,8888"}}]} }

12. search data:

curl?-XPOST?'http://localhost:9200/data/record/_search'?-d?'{"query":?{"bool":?{"must":?[{"term":?{"number":?"2"}}],"must_not":?[{"term":?{"number":?"8888"}}]}} }'

return:

{"took":?3,"timed_out":?false,"_shards":?{"total":?5,"successful":?5,"failed":?0},"hits":?{"total":?1,"max_score":?0.22295055,"hits":?[{"_index":?"data","_type":?"record","_id":?"AVM3kt-GiEDWd2i_MREb","_score":?0.22295055,"_source":?{"id":?"001CV","number":?"2,3,4,5,100-100,1010"}}]} }



轉載于:https://my.oschina.net/apdplat/blog/628889

總結

以上是生活随笔為你收集整理的ES中如何使用逗号来分词的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。